gpuShaderStageOf function

int gpuShaderStageOf(
  1. WebGpuVisibility visibility
)

Which stages a binding is visible to, as this API's flag word.

The one line that turns webgpu_shaders.dart's two booleans into GPUShaderStage bits, which is the whole of what that file gave up by refusing to import a browser binding.

Named, exported and tested rather than inlined into the descriptor, because of what dropping a stage here costs. A layout that claims a binding is vertex-only when the fragment stage samples it is not a wrong picture and not an exception: createRenderPipeline accepts the descriptor, hands back an object marked invalid, and every pass that sets that object draws nothing. The readback is then black or empty, with no line anywhere naming a visibility — one word lost here reads exactly like a texture that failed to upload. webgpu_types_test.dart asks this function the question directly, and asks it again of a whole stage pair's group shapes, so the answer cannot go back to being a constant while the tests stay green.

Implementation

int gpuShaderStageOf(WebGpuVisibility visibility) =>
    (visibility.vertex ? GpuShaderStage.vertex : 0) |
    (visibility.fragment ? GpuShaderStage.fragment : 0);