wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Possible f32 to u32 conversion bug

Open JMS55 opened this issue 1 year ago • 3 comments

Description Using renderdoc, the conversion from f32 to u32 seems wrong in my shader.

Repro steps

_385 = -1.07374E+08
uint _396 = ConvertFToU(_395);
_396 = 4187593120 // Shouldn't this be 0?

Expected vs observed behavior I think the result should be 0u. It's not even u32::MAX, so something's weird.

Extra materials https://gpuweb.github.io/gpuweb/wgsl/#floating-point-conversion

Platform

2024-07-28T20:58:02.528730Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "AMD Ryzen 5 2600 Six-Core Processor", core_count: "6", memory: "15.9 GiB" }
2024-07-28T20:58:03.450199Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3080", vendor: 4318, device: 8710, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.61", backend: Vulkan }

wgpu 0.21

JMS55 avatar Jul 28 '24 21:07 JMS55

This might be a weird renderdoc bug, not sure. I'd like confirmation though that u32(negative_float) is always 0, or if that's not what the spec is saying.

JMS55 avatar Jul 28 '24 22:07 JMS55

u32(negative_float) should be 0. But why do the repro steps contain ConvertFToU(_395)? that should be u32(_395).

This might be a weird renderdoc bug, not sure.

It would be worth investigating.

teoxoy avatar Jul 29 '24 09:07 teoxoy

FYI this is naga's spirv output from a wgsl shader.

JMS55 avatar Jul 29 '24 18:07 JMS55

Any way to get a reproduction on this?

cwfitzgerald avatar Jan 11 '25 09:01 cwfitzgerald