-
Notifications
You must be signed in to change notification settings - Fork 345
Open
Labels
feature requestA request for a new GPU feature exposed in the APIA request for a new GPU feature exposed in the APIwgslWebGPU Shading Language IssuesWebGPU Shading Language Issues
Milestone
Description
WGSL does not provide a NaN constant.
However, many behaviours around NaN are defined by the specification and one developer might want to use them on purpose.
In particular, it is defined behaviour to set a position to NaN from the vertex shader -> that results in the primitive culling.
My concern is that if I want to provoke this behaviour I would write something like:
const NaN: f32 = 0. / 0.; // or bitcast<f32>(0x7fc00000u)
fn vs_main(in: VertexInput, @builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
var out: VertexOutput;
if (...my cull condition...) {
out.position.x = NaN;
return out;
}
... normal behaviour ...
}
That does not compile because it is not legal to create a NaN at compile time.
Of course I can make it runtime but it is a waste of performance...
Can a NaN constant be introduced ? or what workround can I use to create it ?
Thank you.
Metadata
Metadata
Assignees
Labels
feature requestA request for a new GPU feature exposed in the APIA request for a new GPU feature exposed in the APIwgslWebGPU Shading Language IssuesWebGPU Shading Language Issues