Open kainino0x opened 5 days ago
Additionally, we could optionally skip validation of
arrayStride
ifattributes.length==0
, but this doesn't matter.
Actually it would be preferable to skip the validation of arrayStride
when there are no attributes, to make null
and { attributes: [] }
behave the same. Otherwise the C API still needs some distinction in order to implement the JS API correctly.
When creating a
GPURenderPipeline
, it is possible to specify vertex buffers that have noattributes
, and therefore is not actually used by the pipeline. However, in draw-time validation, we still require a vertex buffer to be bound to that slot.We could normalize the descriptor such that
{ arrayStride, attributes: [] }
does the same thing asnull
.Additionally, we could ~optionally~ skip validation of
arrayStride
ifattributes.length==0
, ~but this doesn't matter~.The motivation for revisiting this is for language bindings such as C: https://github.com/webgpu-native/webgpu-headers/issues/432 We previously discussed this in gpuweb #2864, in which we conservatively chose not to change the JS spec, and decided that
webgpu.h
should indicate a hole with something other thanattributes=[]
(we used aWGPUVertexStepMode_VertexBufferNotUsed
sentinel value).Revisiting this with the benefit of time, though, it is very strange that the JS API will validate this thing that is totally unused. I don't really think there's any reasonable bug that this could usefully catch; for example if you forgot to specify any attributes and forgot to bind a vertex buffer, you would still get an error in
createRenderPipeline()
, as long as the shader attempted to use those attributes.