Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,39 @@ event happens. Our new log policy is as follows:

By @cwfitzgerald in [#8579](https://github.com/gfx-rs/wgpu/pull/8579).

#### Push constants renamed immediates, API brought in line with spec.

As the "immediate data" api is getting close to stabilization in the WebGPU specification,
we're bringing our implementation in line with what the spec dictates.

First, in the `PipelineLayoutDescriptor`, you now pass a unified size for all stages:

```diff
- push_constant_ranges: &[wgpu::PushConstantRange {
- stages: wgpu::ShaderStages::VERTEX_FRAGMENT,
- range: 0..12,
- }]
+ immediate_size: 12,
```

Second, on the command encoder you no longer specify a shader stage, uploads apply
to all shader stages that use immediate data.

```diff
- rpass.set_push_constants(wgpu::ShaderStages::FRAGMENT, 0, bytes);
+ rpass.set_immediates(0, bytes);
```

Finally, our implementation currently still zero-initializes the immediate data
range you declared in the pipeline layout. This is not spec compliant and failing
to populate immediate "slots" that are used in the shader will be a validation error
in a future version. See [the proposal][immediate-data-spec] for details for determining
which slots are populated in a given shader.

By @cwfitzgerald in [#8724](https://github.com/gfx-rs/wgpu/pull/8724).

[immediate-data-spec]: https://github.com/gpuweb/gpuweb/blob/main/proposals/immediate-data.md#immediate-slots

#### `subgroup_{min,max}_size` renamed and moved from `Limits` -> `AdapterInfo`

To bring our code in line with the WebGPU spec, we have moved information about subgroup size
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/wgpu-benchmark/computepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl ComputepassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let pipeline =
Expand Down Expand Up @@ -346,7 +346,7 @@ impl ComputepassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bindless_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let bindless_pipeline =
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/wgpu-benchmark/renderpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl RenderpassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let mut vertex_buffers = Vec::with_capacity(vertex_buffer_count as usize);
Expand Down Expand Up @@ -287,7 +287,7 @@ impl RenderpassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bindless_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

bindless_pipeline = Some(device_state.device.create_render_pipeline(
Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl GPUDevice {
let wgpu_descriptor = wgpu_core::binding_model::PipelineLayoutDescriptor {
label: crate::transform_label(descriptor.label.clone()),
bind_group_layouts: Cow::Owned(bind_group_layouts),
immediates_ranges: Default::default(),
immediate_size: 0,
};

let (id, err) = self.instance.device_create_pipeline_layout(
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/big_compute_buffers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn setup_pipeline(
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Compute Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/boids/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("compute"),
bind_group_layouts: &[&compute_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

// create render pipeline with empty bind group layout
Expand All @@ -116,7 +116,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("render"),
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});

let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/bunnymark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&global_bind_group_layout, &local_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/conservative_raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});

let shader_triangle_and_lines =
Expand Down Expand Up @@ -195,7 +195,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});
let shader = device.create_shader_module(wgpu::include_wgsl!("upscale.wgsl"));
(
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/cube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

// Create the texture
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/hello_synchronization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async fn execute(
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});
let patient_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/hello_triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});

let swapchain_capabilities = surface.get_capabilities(&adapter);
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/hello_workgroups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async fn run() {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/mesh_shader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/msaa_line/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});

let multisampled_framebuffer =
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/multiple_render_targets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl MultiTargetRenderer {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&texture_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
Expand Down Expand Up @@ -232,7 +232,7 @@ impl TargetRenderer {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&texture_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
Expand Down
11 changes: 4 additions & 7 deletions examples/features/src/ray_shadows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::FRAGMENT,
range: 0..12,
}],
immediate_size: 12,
});

let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
Expand Down Expand Up @@ -331,9 +328,9 @@ impl crate::framework::Example for Example {

rpass.set_pipeline(&self.pipeline);
rpass.set_bind_group(0, Some(&self.bind_group), &[]);
rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 0, &0.0_f32.to_ne_bytes());
rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 4, &cos.to_ne_bytes());
rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 8, &sin.to_ne_bytes());
rpass.set_immediates(0, &0.0_f32.to_ne_bytes());
rpass.set_immediates(4, &cos.to_ne_bytes());
rpass.set_immediates(8, &sin.to_ne_bytes());
rpass.set_vertex_buffer(0, self.vertex_buf.slice(..));
rpass.set_index_buffer(self.index_buf.slice(..), IndexFormat::Uint16);
rpass.draw_indexed(0..12, 0, 0..1);
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/ray_traced_triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline layout for shader.wgsl"),
bind_group_layouts: &[&bgl],
immediates_ranges: &[],
immediate_size: 0,
});

let compute_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
Expand All @@ -284,7 +284,7 @@ impl crate::framework::Example for Example {
let blit_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline layout for blit.wgsl"),
bind_group_layouts: &[&blit_bgl],
immediates_ranges: &[],
immediate_size: 0,
});

let blit_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/repeated_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl WgpuContext {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/shadow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("shadow"),
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
Expand Down Expand Up @@ -582,7 +582,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("main"),
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let mx_total = Self::generate_matrix(config.width as f32 / config.height as f32);
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

// Create the render pipelines
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/srgb_blend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

// Create bind group
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/stencil_triangles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});

let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/storage_texture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async fn run(_path: Option<String>) {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/texture_arrays/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("main"),
bind_group_layouts: &[&bind_group_layout, &uniform_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let index_format = wgpu::IndexFormat::Uint16;
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/timestamp_queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn render_pass(
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
immediates_ranges: &[],
immediate_size: 0,
});

let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/uniform_values/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl WgpuContext {
label: None,
// (4)
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let swapchain_capabilities = surface.get_capabilities(&adapter);
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/water/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,14 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("water"),
bind_group_layouts: &[&water_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let terrain_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("terrain"),
bind_group_layouts: &[&terrain_bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

let water_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion examples/standalone/01_hello_compute/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn main() {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
immediates_ranges: &[],
immediate_size: 0,
});

// The pipeline is the ready-to-go program state for the GPU. It contains the shader modules,
Expand Down
4 changes: 1 addition & 3 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Player {
let resolved_desc = wgc::binding_model::ResolvedPipelineLayoutDescriptor {
label: desc.label.clone(),
bind_group_layouts: Cow::from(&bind_group_layouts),
immediates_ranges: Cow::Borrowed(&*desc.immediates_ranges),
immediate_size: desc.immediate_size,
};

let pipeline_layout = device
Expand Down Expand Up @@ -1058,12 +1058,10 @@ impl Player {
},
C::SetScissor(rect) => C::SetScissor(rect),
C::SetImmediate {
stages,
offset,
size_bytes,
values_offset,
} => C::SetImmediate {
stages,
offset,
size_bytes,
values_offset,
Expand Down
Loading