[wgt] split ShaderStages into WGPU and WebGPU parts

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev authored and mergify[bot] committed 2026-09-15 14:59:41 +00:00
1 parent 1b3473981b
commit b7a23d6ed7
4 files changed
+37 -19

No files matched your search

+1
View File
@@ -151,6 +151,7 @@ By @sagudev in [#10109](https://github.com/gfx-rs/wgpu/pull/10109).
- `Buffer::unmap` will not raise any validation errors anymore per specification. By @sagudev in [#10242](https://github.com/gfx-rs/wgpu/pull/10242).
- `wgpu::Error::Validation::description` from `Device::create_shader_module` no longer include the shader source text and detailed compiler messages, per the WebGPU specification. These details remain accessible via `ShaderModule::get_compilation_info`. By @beicause and @sagudev in [#10173](https://github.com/gfx-rs/wgpu/pull/10173).
- `BufferUsages` is now composed of `BufferUsagesWebGPU` and `BufferUsagesWGPU`, similarly to `Features`. In most cases this is not expected to be a breaking change, but changes might be required for converting `BufferUsages` to/from `u32`. By @sagudev in [#10195](https://github.com/gfx-rs/wgpu/pull/10195).
- `ShaderStages` is now composed of `ShaderStagesWebGPU` and `ShaderStagesWGPU`, similarly to `Features`. In most cases this is not expected to be a breaking change, but changes might be required for converting `ShaderStages` to/from `u32`. By @sagudev in [#10313](https://github.com/gfx-rs/wgpu/pull/10313).
#### naga
+4 -8
View File
@@ -475,14 +475,10 @@ impl<'a> WebIdlConverter<'a> for GPUShaderStageFlags {
},
)?;
let flags =
wgpu_types::ShaderStages::from_bits(flags_value).ok_or_else(|| {
WebIdlError::other(
prefix,
context,
JsErrorBox::type_error("shader stage is not valid"),
)
})?;
let flags = wgpu_types::ShaderStages::from_internal_flags(
wgpu_types::ShaderStagesWebGPU::from_bits_retain(flags_value),
wgpu_types::ShaderStagesWGPU::empty(),
);
Ok(GPUShaderStageFlags(flags))
}
+27 -9
View File
@@ -193,7 +193,7 @@ impl BindingType {
}
}
bitflags::bitflags! {
crate::bitflags_array! {
/// Describes the shader stages that a binding will be visible from.
///
/// These can be combined so something that is visible from both vertex and fragment shaders can be defined as:
@@ -202,11 +202,20 @@ bitflags::bitflags! {
///
/// Corresponds to [WebGPU `GPUShaderStageFlags`](
/// https://gpuweb.github.io/gpuweb/#typedefdef-gpushaderstageflags).
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct (ShaderStages, ShaderStagesBits): [u32; 2];
/// Shader stages that are defined in the WebGPU specification.
/// For all usages, see [`ShaderStages`].
///
/// Corresponds to [WebGPU `GPUShaderStageFlags`](
/// https://gpuweb.github.io/gpuweb/#typedefdef-gpushaderstageflags).
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ShaderStages: u32 {
pub struct ShaderStagesWebGPU features_webgpu {
/// Binding is not visible from any shader stage.
const NONE = 0;
/// Binding is visible from the vertex shader of a render pipeline.
@@ -216,19 +225,28 @@ bitflags::bitflags! {
/// Binding is visible from the compute shader of a compute pipeline.
const COMPUTE = 1 << 2;
/// Binding is visible from the vertex and fragment shaders of a render pipeline.
const VERTEX_FRAGMENT = Self::VERTEX.bits() | Self::FRAGMENT.bits();
const VERTEX_FRAGMENT = ShaderStagesWebGPU::VERTEX.bits() | ShaderStagesWebGPU::FRAGMENT.bits();
}
/// Shader stages that are available in WGPU only when targeting native.
/// For all usages, see [`ShaderStages`].
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ShaderStagesWGPU features_wgpu {
/// Binding is visible from the task shader of a mesh pipeline.
const TASK = 1 << 3;
const TASK = 1 << 0;
/// Binding is visible from the mesh shader of a mesh pipeline.
const MESH = 1 << 4;
const MESH = 1 << 1;
/// Binding is visible from the ray generation shader of a ray tracing pipeline.
const RAY_GENERATION = 1 << 5;
const RAY_GENERATION = 1 << 2;
/// Binding is visible from the ray any hit shader of a ray tracing pipeline.
const ANY_HIT = 1 << 6;
const ANY_HIT = 1 << 3;
/// Binding is visible from the ray closest hit shader of a ray tracing pipeline.
const CLOSEST_HIT = 1 << 7;
const CLOSEST_HIT = 1 << 4;
/// Binding is visible from the ray miss shader of a ray tracing pipeline.
const MISS = 1 << 8;
const MISS = 1 << 5;
}
}
+5 -2
View File
@@ -2247,8 +2247,11 @@ impl dispatch::DeviceInterface for WebDevice {
.entries
.iter()
.map(|bind| {
let mapped_entry =
webgpu_sys::GpuBindGroupLayoutEntry::new(bind.binding, bind.visibility.bits());
assert!(bind.visibility.features_wgpu.is_empty());
let mapped_entry = webgpu_sys::GpuBindGroupLayoutEntry::new(
bind.binding,
bind.visibility.features_webgpu.bits(),
);
match bind.ty {
wgt::BindingType::Buffer {