gpuweb icon indicating copy to clipboard operation
gpuweb copied to clipboard

Validation for setViewport should be `minDepth <= maxDepth`

Open mwyrzykowski opened this issue 1 year ago • 6 comments

The validation for setViewport says:

If any of the following conditions are unsatisfied, make this invalid and stop. ... minDepth < maxDepth

However, based on the discussion in https://github.com/gpuweb/cts/issues/3307#issuecomment-1908832369:

This seems like a bug in the WebGPU spec. I can't exactly recall exactly the discussions around this, but it seems the only constraint was reverse depth, not < vs <=. The D3D11 functional spec require <=, not < and that's the only constraint I have found (Vulkan doesn't have a constraint even in 1.0, and Metal docs say the two can be reversed).

it seems like that line should read:

minDepth <= maxDepth

mwyrzykowski avatar Jan 24 '24 20:01 mwyrzykowski

I'm honestly not sure which is the correct answer. If the range is zero-sized, it might cause division by zero somewhere in the rasterization step?

kainino0x avatar Jan 24 '24 20:01 kainino0x

cc @Kangz for insight

mwyrzykowski avatar Jan 24 '24 20:01 mwyrzykowski

maxDepth - minDepth is used as a scaling factor for the Z coordinate, but not as a divider so we're ok I think.

Kangz avatar Jan 25 '24 14:01 Kangz

I don't see anything in the Vulkan spec either which divides by pz := (maxDepth - minDepth)

kainino0x avatar Jan 25 '24 22:01 kainino0x

LGTM to make this change - I've added it to the meeting agenda in case we don't resolve this before then.

kainino0x avatar Jan 25 '24 22:01 kainino0x

I probably could have put this in Milestone 1 (as a request to loosen validation), but the CTS has already done the correct thing for 4 years (and Dawn didn't have any trouble implementing that) so I don't think this needs WG approval - since the tests were already enforcing it, it's effectively a spec typo (and thus milestone 0). https://github.com/gpuweb/cts/blame/9c8e5ba09314be2cec8a5cbd69b7b2f0fec7f89f/src/webgpu/api/validation/encoding/cmds/render/dynamic_state.spec.ts#L219

kainino0x avatar Jul 02 '24 21:07 kainino0x