Sitelet https://github.com/gpuweb/gpuweb/pull/152
Skip to content

IndexFormat, VertexFormat and InputStepMode should be enums - #152

Merged
grorg merged 3 commits into
gpuweb:masterfrom
grorg:inputstate-others-enum
Dec 14, 2018
Merged

grorg merged 3 commits into
gpuweb:masterfrom
grorg:inputstate-others-enum

Conversation

@grorg

@grorg grorg commented Dec 14, 2018

Copy link
Copy Markdown
Contributor

Since all these values are exclusive, they should be enums in the IDL.

This way implementations can possibly validate in their bindings code.

@grorg

grorg commented Dec 14, 2018

Copy link
Copy Markdown
Contributor Author

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 kainino0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@magcius

magcius commented Dec 14, 2018

Copy link
Copy Markdown

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

@magcius

magcius commented Dec 14, 2018

Copy link
Copy Markdown

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.

@grorg

grorg commented Dec 14, 2018

Copy link
Copy Markdown
Contributor Author

@magcius can you raise issues for those?

@grorg
grorg merged commit 48b08eb into gpuweb:master Dec 14, 2018
@grorg
grorg deleted the inputstate-others-enum branch December 14, 2018 23:54
@kainino0x kainino0x mentioned this pull request Oct 30, 2019
13 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants