IndexFormat, VertexFormat and InputStepMode should be enums - #152
Conversation
|
Added benefit - it means we don't have to create instances of these classes in binding code (just to expose static values). Unless I'm forgetting some decision which explained why it is more convenient to use u32 for these values? It doesn't make any difference in WebKit and, like I mentioned, allows us to validate in generated code easier. |
kainino0x
left a comment
There was a problem hiding this comment.
It might have been because these are used in performance-critical code paths, and the exact performance of string enums is highly questionable (even if theoretically optimizable). Aside from that complex topic, lgtm.
|
WebGPUVertexFormat should likely be composable out of fields (so, bits for UNORM/SNORM, bits for component type like F32/U8/U16/U32/S8/S16/S32, bits for component count like 1/2/3/4). This way, client won't have a giant switch statement or require string concatenation but instead can just compose out of existing fields. See something like this in my platform layer: https://github.com/magcius/model-viewer/blob/master/src/gfx/platform/GfxPlatformFormat.ts#L40-L64 |
|
I would also like to encourage merging WebGPUVertexFormat and WebGPUTextureFormat as vertex attribute fetch and texture fetch are getting more similar all the time, but that is less important. |
|
@magcius can you raise issues for those? |
Since all these values are exclusive, they should be enums in the IDL.
This way implementations can possibly validate in their bindings code.