diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7b86dc1..e1c31731a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,8 @@ Bottom level categories: - Validate that the arguments are within the indirect buffer when encoding an indirect draw to a render bundle. Moves some indirect draw errors from `RenderPassErrorInner` to `RenderCommandError`. By @andyleiserson in [#9871](https://github.com/gfx-rs/wgpu/pull/9871). - When creating render pipelines, validate that a corresponding shader output is present for each color attachment with non-zero write mask, and that shader output includes alpha when the blend operation uses source alpha. By @andyleiserson in [#9939](https://github.com/gfx-rs/wgpu/pull/9939). +- Reject bind group layout entries with `TASK` or `MESH` visibility unless `Features::EXPERIMENTAL_MESH_SHADER` is enabled. By @teoxoy in [#10042](https://github.com/gfx-rs/wgpu/issues/10042). +- Reject bind group layout entries with `RAY_GENERATION`, `ANY_HIT`, `CLOSEST_HIT`, or `MISS` visibility unless `Features::EXPERIMENTAL_RAY_TRACING_PIPELINES` is enabled. By @teoxoy in [#10042](https://github.com/gfx-rs/wgpu/issues/10042). #### Naga diff --git a/tests/tests/wgpu-validation/api/mesh_shader.rs b/tests/tests/wgpu-validation/api/mesh_shader.rs new file mode 100644 index 000000000..4f7cad7a2 --- /dev/null +++ b/tests/tests/wgpu-validation/api/mesh_shader.rs @@ -0,0 +1,36 @@ +use wgpu::*; +use wgpu_test::fail; + +fn check_visibility_requires_mesh_shader_feature(visibility: ShaderStages) { + let (device, _queue) = wgpu::Device::noop(&DeviceDescriptor::default()); + + fail( + &device, + || { + device.create_bind_group_layout(&BindGroupLayoutDescriptor { + label: Some("mesh shader visibility"), + entries: &[BindGroupLayoutEntry { + binding: 0, + visibility, + ty: BindingType::Buffer { + ty: BufferBindingType::Storage { read_only: true }, + has_dynamic_offset: false, + min_binding_size: None, + }, + count: None, + }], + }) + }, + Some("EXPERIMENTAL_MESH_SHADER"), + ); +} + +#[test] +fn task_visibility_requires_mesh_shader_feature() { + check_visibility_requires_mesh_shader_feature(ShaderStages::TASK); +} + +#[test] +fn mesh_visibility_requires_mesh_shader_feature() { + check_visibility_requires_mesh_shader_feature(ShaderStages::MESH); +} diff --git a/tests/tests/wgpu-validation/api/mod.rs b/tests/tests/wgpu-validation/api/mod.rs index b7919d8d1..a7ef7c84d 100644 --- a/tests/tests/wgpu-validation/api/mod.rs +++ b/tests/tests/wgpu-validation/api/mod.rs @@ -10,5 +10,7 @@ mod experimental; mod external_texture; mod immediates; mod instance; +mod mesh_shader; +mod ray_tracing_pipeline; mod render_pipeline; mod texture; diff --git a/tests/tests/wgpu-validation/api/ray_tracing_pipeline.rs b/tests/tests/wgpu-validation/api/ray_tracing_pipeline.rs new file mode 100644 index 000000000..9023b3ab7 --- /dev/null +++ b/tests/tests/wgpu-validation/api/ray_tracing_pipeline.rs @@ -0,0 +1,46 @@ +use wgpu::*; +use wgpu_test::fail; + +fn check_visibility_requires_ray_tracing_pipelines_feature(visibility: ShaderStages) { + let (device, _queue) = wgpu::Device::noop(&DeviceDescriptor::default()); + + fail( + &device, + || { + device.create_bind_group_layout(&BindGroupLayoutDescriptor { + label: Some("ray tracing pipeline visibility"), + entries: &[BindGroupLayoutEntry { + binding: 0, + visibility, + ty: BindingType::Buffer { + ty: BufferBindingType::Storage { read_only: true }, + has_dynamic_offset: false, + min_binding_size: None, + }, + count: None, + }], + }) + }, + Some("EXPERIMENTAL_RAY_TRACING_PIPELINES"), + ); +} + +#[test] +fn ray_generation_visibility_requires_ray_tracing_pipelines_feature() { + check_visibility_requires_ray_tracing_pipelines_feature(ShaderStages::RAY_GENERATION); +} + +#[test] +fn any_hit_visibility_requires_ray_tracing_pipelines_feature() { + check_visibility_requires_ray_tracing_pipelines_feature(ShaderStages::ANY_HIT); +} + +#[test] +fn closest_hit_visibility_requires_ray_tracing_pipelines_feature() { + check_visibility_requires_ray_tracing_pipelines_feature(ShaderStages::CLOSEST_HIT); +} + +#[test] +fn miss_visibility_requires_ray_tracing_pipelines_feature() { + check_visibility_requires_ray_tracing_pipelines_feature(ShaderStages::MISS); +} diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 9f2767194..f63efae4d 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -3095,6 +3095,22 @@ impl Device { )); } + if entry + .visibility + .intersects(wgt::ShaderStages::TASK | wgt::ShaderStages::MESH) + { + required_features |= wgt::Features::EXPERIMENTAL_MESH_SHADER; + } + + if entry.visibility.intersects( + wgt::ShaderStages::RAY_GENERATION + | wgt::ShaderStages::ANY_HIT + | wgt::ShaderStages::CLOSEST_HIT + | wgt::ShaderStages::MISS, + ) { + required_features |= wgt::Features::EXPERIMENTAL_RAY_TRACING_PIPELINES; + } + if entry.visibility.contains(wgt::ShaderStages::VERTEX) { if writable_storage == WritableStorage::Yes { required_features |= wgt::Features::VERTEX_WRITABLE_STORAGE;