Repository navigation
Allocation of implementation-specific enum values #214
Description
This issue is no longer maintained. Please see https://webgpu-native.github.io/webgpu-headers/Extensions.html instead.
We should have a "registry" of allocated ranges to use for enums, especially WGPUSType and WGPUFeatureName
Per #212 the end of the name of the new values will be the name of the implementation.
In the webgpu.h meeting we agreed to use the top 16 bits for the implementation namespace. I think we can use this for all of the (non-bitflag) enums.
No one really cares about the actual IDs so here's an arbitrary assignment of ranges:
-
0x0000_????: core, required to implement
Prefix: none.Should be in all implementations, both native and Wasm. Used for features added to WebGPU core after this header stabilizes.
-
0x0001_????: non-core (multi-implementation) extensions, optional to implement (though maybe they could become required in the future, or maybe we then alias them into block0x0000_????, TBD)
Prefix: none.May be native-specific or Wasm-specific, both can go in this block.
-
0x0002_????: WebGPU Compat
Prefix: none? TBD.Special: implementations that don't support compat should ignore these instead of error. This is to be used only for Compat additions that don't affect semantics of a valid program if a non-compat implementation ignores them.
-
0x0003_????: wgpu-native
Prefix:Wgpu? (see Naming conventions for extension structs and implementation-specific extensions #212 (comment)) -
0x0004_????: Emscripten
Prefix:Emscripten -
0x0005_????: Dawn
Prefix:Dawn
EDIT: Per #212 (comment) (in which we switched from suffixes to prefixes), prefixes work like so:
wgpuPrefixNewFunction WGPUPrefixNewObject wgpuPrefixNewObjectNewMethod wgpuOldObjectPrefixNewMethod WGPUPrefixNewEnum WGPUPrefixNewEnum_NewValue WGPUOldEnum_PrefixNewValue WGPUPrefixNewStruct WGPUPrefixNewBitflagType WGPUPrefixNewBitflagType_NewValue WGPUOldBitflagType_PrefixNewValue WGPUPrefixNewCallback WGPU_PREFIX_NEW_CONSTANT
EDIT: For bitflags (becoming uint64_t in #273):
- The least-significant 53 bits are reserved for core - that is, bits defined by the JS API, since it can only represent 53 bits.
- The most-significant 11 bits are for native-only and implementation-specific bits, then overflows into the most-significant end of the least-significant 53 bits if we run out. The allocation of these bits is ad hoc for now.
- Only bits specified in this header will be stable; implementation-specific bits can overlap or change value for now. Eventually for ABI compatibility we'll probably need a registry of these.
Activity
New enum values for wgpu-native specific enums.
New enum values for wgpu-native specific enums.
New enum values for wgpu-native specific enums (#294)
rajveermalviya commentedon Sep 20, 2023
wgpu-nativenow uses the0x0003_????namespaceKangz commentedon Sep 22, 2023
Shouldn't this be reserved for native-only and not upstream WebGPU (as in the JS spec) features? If we need another reserved block Dawn can move to
0x0005_????so0x0002_????is free.kainino0x commentedon Oct 11, 2023
Good idea. We don't really need another reserved block so I'll just change what
0x0001_????is, above.kainino0x commentedon Oct 11, 2023
We need to decide where WebGPU Compat values live (for
STypes in particular). They could be in the Core block, but we might also want to give them special semantics - ignore them, rather than error, if the implementation doesn't understand them. See:https://dawn-review.googlesource.com/c/dawn/+/155780/comment/4e84af8f_54c41233/
kainino0x commentedon Oct 12, 2023
meeting: Decided tentatively to do that: make a block for Compat so the whole block can be treated specially. If either compat isn't enabled, on the implementation doesn't implement compat at all (but knows that it exists), it should ignore chained structs in this block, rather than error on them.
This raises the question of what to do in an implementation that implements compat, if an SType is passed that's in the compat block but not recognized. This is an edge case since we don't provide ABI compatibility. But I think it should error, regardless of whether compat is enabled on the device.
I'm going to make 0x0002 Compat, and move Dawn to 0x0005 since we haven't started using it yet.
kainino0x commentedon Feb 15, 2024
For bitflags enums, which are becoming 64 bits, the first 10-11 extensions should be allocated (still ad hoc) in the top 11 bits that JS can't represent. (10 because might need to skip the MSB because if C enums don't like being u64.)
kainino0x commentedon Mar 16, 2024
Mar 14 meeting:
kainino0x commentedon Mar 16, 2024
Updated top post.
kainino0x commentedon Jun 27, 2024
Do we need a block for multi-implementation wasm-only extensions?
WGPUSType_SurfaceDescriptorFromCanvasHTMLSelectorcould belong in that block. (Its actual behavior in Emscripten is a bit Emscripten-specific because of how it handles looking up canvases from workers, but that doesn't mean the extension has to be in the Emscripten block.)kainino0x commentedon Jun 27, 2024
(Relatedly we are assuming
WGPUSType_SurfaceDescriptorFromMetalLayerbelongs in the "multi-implementation native-only extensions" block: https://dawn-review.googlesource.com/c/dawn/+/196174)kainino0x commentedon Jul 18, 2024
Jul 18 meeting:
WGPUSurfaceDescriptorFromCanvasHTMLSelectorprovides a string to pass toquerySelector()DOM API. In Emscripten it also has some special behavior.kainino0x commentedon Jul 18, 2024
See also the Jul 18 notes for #212 (comment)
I have updated the top comment on this issue for both resolutions.
kainino0x commentedon Nov 9, 2024
Closing, nothing to do in this repo until we start using block
0x0001(e.g. in #200, EDIT: and #420).(except for add docs, so we keep the
needs docslabel for that.)kainino0x commentedon Nov 26, 2024
Updated for #212 (comment)
kainino0x commentedon Dec 13, 2024
Updated description of block 0x0001 for #420 (comment)
kainino0x commentedon Dec 21, 2024
Added this note about block 1.