Bug 278946
Summary: | [WGSL] Default initialization of [[position]] can lead to division by zero depending on the hardware implementation | ||
---|---|---|---|
Product: | WebKit | Reporter: | Mike Wyrzykowski <mwyrzykowski> |
Component: | WebGPU | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | mwyrzykowski, tzagallo, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Mike Wyrzykowski
Since position performs an effective division https://www.w3.org/TR/WGSL/#position-builtin-value
its default initializer should be 0,0,0,1 instead of 0,0,0,0. Otherwise this result is undefined, as v.position is not written to. Specifically, on Apple Silicon it renders the pixel but on AMD / Intel, the render is skipped because (x,y,z)/w = (0,0,0)/0 = inf:
struct VertexOutput {
@builtin(position) position : vec4f,
@location(0) @interpolate(flat) something: u32,
}
@vertex
fn v(@location(0) fromVertexBuffer: u32) -> VertexOutput {
var v = VertexOutput();
v.something = fromVertexBuffer;
return v;
}
@fragment
fn f(@location(0) @interpolate(flat) something: u32) -> @location(0) u32 {
return something;
}
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Mike Wyrzykowski
Related: https://github.com/gpuweb/gpuweb/issues/4845
Instead of changing the initializer, we may want to insert a clamp at the end, like:
position.w = select(position.w, 1., position.w == 0)
Radar WebKit Bug Importer
<rdar://problem/135039804>