WebAssembly / WebAssembly/component-model
flags: support flags that are just combinations of other flags, not taking a new bit.
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 1.4k
- Forks
- 130
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 15
Description
This came up in https://github.com/WebAssembly/wasi-gfx/pull/71#discussion_r3358530577
where WebGpu has a C definition:
https://github.com/webgpu-native/webgpu-headers/blob/bf8ddb91dc38ea11ec1b727dae1fa965c4207d22/webgpu.h#L1334
/**
* `Red | Green | Blue | Alpha`.
*/
static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F;
the generated WIT in https://github.com/WebAssembly/wasi-gfx/pull/71 as of writing is:
flags gpu-color-write {
red,
green,
blue,
alpha,
all,
}
which is incorrect in that all shouldn't be a new flag, just a shorthand for a combination of all the other flags.
I think WIT should be changed to allow expressing named flag values that are just combinations of zero or more existing flags by allowing assigning flag values to either 0 or the bitwise or of one or more other named flags:
flags colors {
black = 0,
red,
green,
yellow = red | green,
blue,
magenta = red | blue,
purple = magenta,
cyan = green | blue,
white = red | green | blue,
}
note: I'm not planning on implementing this myself, so whoever's interested feel free to implement it whenever ready.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the linked wasi-gfx discussion and PR 71, then trace how WIT flag declarations are specified and generated. The work is done when named flag values can be zero or combinations of existing flags, including aliases such as all, without allocating new bits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100