Add support for gaps in bind group layouts & update relevant validation (#9034)

* [wgpu-core] add support for optional BG & BGL entries

* [wgpu] allow gaps in bind group layouts

And allow unbinding in the web backend.

* adapt tests

* add changelog entry

* [wgpu] remove generic from `PipelineLayoutDescriptor`
This commit is contained in:
Teodor Tanasoaia authored and GitHub committed 2026-02-25 19:47:36 +01:00
1 parent aad2a00f4d
commit e114d2f0a7
90 files changed
+567 -397

No files matched your search

+1 -1
View File
@@ -346,7 +346,7 @@ fn copy_via_compute(
let pll = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
+1 -1
View File
@@ -88,7 +88,7 @@ static BGRA8_UNORM_STORAGE: GpuTestConfiguration = GpuTestConfiguration::new()
let pl = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
@@ -80,7 +80,7 @@ async fn bgl_dedupe(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl_1b],
bind_group_layouts: &[Some(&bgl_1b)],
immediate_size: 0,
});
@@ -144,7 +144,7 @@ fn bgl_dedupe_with_dropped_user_handle(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl_1],
bind_group_layouts: &[Some(&bgl_1)],
immediate_size: 0,
});
+1 -1
View File
@@ -69,7 +69,7 @@ fn multiple_bindings_with_differing_sizes(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
@@ -227,7 +227,7 @@ async fn binding_array_buffers(
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
@@ -180,7 +180,7 @@ async fn binding_array_sampled_textures(ctx: TestingContext, partially_bound: bo
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
@@ -213,7 +213,7 @@ async fn binding_array_samplers(ctx: TestingContext, partially_bound: bool) {
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
@@ -173,7 +173,7 @@ async fn binding_array_storage_textures(ctx: TestingContext, partially_bound: bo
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
+2 -2
View File
@@ -232,7 +232,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_LAYOUT: GpuTestConfiguration = GpuTestConfigu
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
@@ -306,7 +306,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_DISPATCH: GpuTestConfiguration = GpuTestConfi
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
@@ -322,7 +322,7 @@ fn resource_setup(ctx: &TestingContext) -> ResourceSetup {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
+1 -1
View File
@@ -439,7 +439,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
ctx.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&invalid_bind_group_layout],
bind_group_layouts: &[Some(&invalid_bind_group_layout)],
immediate_size: 0,
});
@@ -206,7 +206,7 @@ impl TestResources {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 4,
});
+1 -1
View File
@@ -100,7 +100,7 @@ async fn test_format(
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
let shader = ctx.device.create_shader_module(desc);
+3 -3
View File
@@ -98,7 +98,7 @@ async fn partial_update_test(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 32,
});
@@ -267,9 +267,9 @@ async fn render_pass_test(ctx: &TestingContext, use_render_bundle: bool) {
let render_pipeline_layout = ctx
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
bind_group_layouts: &[&bind_group_layout],
label: None,
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 8 * size_of::<u32>() as u32,
..Default::default()
});
let pipeline = ctx
+1 -1
View File
@@ -91,7 +91,7 @@ async fn draw_test_with_reports(
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
+2 -2
View File
@@ -177,7 +177,7 @@ impl TestResources {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
@@ -341,7 +341,7 @@ async fn d3d12_restrict_dynamic_buffers(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
+4 -4
View File
@@ -92,9 +92,9 @@ static COMPUTE_PIPELINE_DEFAULT_LAYOUT_BAD_BGL_INDEX: GpuTestConfiguration =
cache: None,
});
pipeline.get_bind_group_layout(0);
pipeline.get_bind_group_layout(u32::MAX);
},
Some("Invalid group index 0"),
Some("Bind group layout index 4294967295 is greater than the device's configured `max_bind_groups` limit"),
);
});
@@ -178,9 +178,9 @@ static RENDER_PIPELINE_DEFAULT_LAYOUT_BAD_BGL_INDEX: GpuTestConfiguration =
cache: None,
});
pipeline.get_bind_group_layout(0);
pipeline.get_bind_group_layout(u32::MAX);
},
Some("Invalid group index 0"),
Some("Bind group layout index 4294967295 is greater than the device's configured `max_bind_groups` limit"),
);
});
+1 -1
View File
@@ -97,7 +97,7 @@ async fn pipeline_cache_test(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
@@ -92,7 +92,7 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pll"),
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 16,
});
@@ -463,7 +463,7 @@ fn resource_setup(ctx: &TestingContext) -> ResourceSetup {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
+2 -2
View File
@@ -326,9 +326,9 @@ fn sampler_bind_group(ctx: TestingContext, group_type: GroupType) {
}],
});
let mut bgl_references: Vec<_> = bind_group_layouts.iter().collect();
let mut bgl_references: Vec<_> = bind_group_layouts.iter().map(Some).collect();
bgl_references.push(&output_bgl);
bgl_references.push(Some(&output_bgl));
let pipeline_layout = ctx
.device
+1 -1
View File
@@ -279,7 +279,7 @@ async fn shader_input_output_test(
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: match storage_type {
InputStorageType::Immediate => MAX_BUFFER_SIZE as u32,
_ => 0,
@@ -69,7 +69,7 @@ static ZERO_INIT_WORKGROUP_MEMORY: GpuTestConfiguration = GpuTestConfiguration::
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
@@ -68,7 +68,7 @@ static SUBGROUP_OPERATIONS: GpuTestConfiguration = GpuTestConfiguration::new()
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("main"),
bind_group_layouts: &[&bind_group_layout],
bind_group_layouts: &[Some(&bind_group_layout)],
immediate_size: 0,
});
+1 -1
View File
@@ -253,7 +253,7 @@ async fn vertex_formats_common(ctx: TestingContext, tests: &[Test<'_>]) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});
+1 -1
View File
@@ -233,7 +233,7 @@ async fn vertex_index_common(ctx: TestingContext) {
.device
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
bind_group_layouts: &[Some(&bgl)],
immediate_size: 0,
});