gpuweb / gpuweb

Where the GPU for the Web work happens!

Home Page:http://webgpu.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues in "validating GPUDepthStencilState" algorithm

Kangz opened this issue · comments

The above phrasing states that if depthCompare != "always", then format must have a depth component.

Now that depthCompare is optional, should that be interpreted as if depthCompare != undefined && depthCompare != "always", then format must have a depth component?

I.e. what should happen if I don't fill in depthCompare, or I fill in .depthCompare = undefined;? It seems like the above rules are saying that in that case the format should have a depth component, which might be a bit odd?

Originally posted by @juj in #4318 (comment)

This is clearly a spec bug and the intent is that undefined is allowed when there is no depth aspect on the format.

The spec language as written is correct, because of a confusing WebIDL detail:
Since depthCompare is an optional dictionary member, if depthCompare: undefined in JS, then depthCompare does not appear at all in the ordered map that the spec "sees". At the algorithm level, we can't tell the difference between {} and {depthCompare: undefined}.
The language "is provided" checks if the key is the ordered map, so it implies "not undefined".

  • We should consider clearer language than "is provided". I think I picked that assuming undefined sounds like 'explicitly not providing' something, but I'm sure there's a better word.
  • @jimblandy points out a separate minor issue here though which is that we neglected to check "depthWriteEnabled is provided" before accessing it.