Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Explainer: mini-section on bitflags
  • Loading branch information
kainino0x committed Apr 9, 2021
commit 3f25a8b3ea221a4c711aa307596a18316e8bb89a
22 changes: 22 additions & 0 deletions explainer/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -730,5 +730,27 @@ When using advanced methods to transfer data to the GPU (with a rolling list of

## Bitflags ## {#bitflags}

WebGPU uses C-style bitflags in several places.
(Search `GPUFlagsConstant` in the spec for instances.)
A typical bitflag definition looks like this:

<xmp highlight=idl>
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
[Exposed=Window]
interface GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
const GPUFlagsConstant BLUE = 0x4;
const GPUFlagsConstant ALPHA = 0x8;
const GPUFlagsConstant ALL = 0xF;
};
</xmp>

This was chosen because there is no other particularly ergonomic way to describe
"enum sets" in JavaScript today.
The closest option is `sequence<enum type>`, but it doesn't naturally describe
an unordered set of unique items and doesn't easily allow things like
`GPUColorWrite.ALL` above.


# WebGPU Shading Language # {#wgsl}