Rename push constants to immediates (#8586)

This commit is contained in:
Connor Fitzgerald 2025-12-01 09:20:02 -05:00 committed by GitHub
parent 37c38e0741
commit 5895de82b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
158 changed files with 829 additions and 837 deletions

View File

@ -251,7 +251,7 @@ impl ComputepassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = let pipeline =
@ -346,7 +346,7 @@ impl ComputepassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bindless_bind_group_layout], bind_group_layouts: &[&bindless_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let bindless_pipeline = let bindless_pipeline =

View File

@ -151,7 +151,7 @@ impl RenderpassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let mut vertex_buffers = Vec::with_capacity(vertex_buffer_count as usize); let mut vertex_buffers = Vec::with_capacity(vertex_buffer_count as usize);
@ -287,7 +287,7 @@ impl RenderpassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bindless_bind_group_layout], bind_group_layouts: &[&bindless_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
bindless_pipeline = Some(device_state.device.create_render_pipeline( bindless_pipeline = Some(device_state.device.create_render_pipeline(

View File

@ -372,7 +372,7 @@ impl GPUDevice {
let wgpu_descriptor = wgpu_core::binding_model::PipelineLayoutDescriptor { let wgpu_descriptor = wgpu_core::binding_model::PipelineLayoutDescriptor {
label: crate::transform_label(descriptor.label.clone()), label: crate::transform_label(descriptor.label.clone()),
bind_group_layouts: Cow::Owned(bind_group_layouts), bind_group_layouts: Cow::Owned(bind_group_layouts),
push_constant_ranges: Default::default(), immediates_ranges: Default::default(),
}; };
let (id, err) = self.instance.device_create_pipeline_layout( let (id, err) = self.instance.device_create_pipeline_layout(

View File

@ -430,8 +430,8 @@ pub enum GPUFeatureName {
PartiallyBoundBindingArray, PartiallyBoundBindingArray,
#[webidl(rename = "multi-draw-indirect-count")] #[webidl(rename = "multi-draw-indirect-count")]
MultiDrawIndirectCount, MultiDrawIndirectCount,
#[webidl(rename = "push-constants")] #[webidl(rename = "immediate-data")]
PushConstants, ImmediateData,
#[webidl(rename = "address-mode-clamp-to-zero")] #[webidl(rename = "address-mode-clamp-to-zero")]
AddressModeClampToZero, AddressModeClampToZero,
#[webidl(rename = "address-mode-clamp-to-border")] #[webidl(rename = "address-mode-clamp-to-border")]
@ -500,7 +500,7 @@ pub fn feature_names_to_features(
GPUFeatureName::UniformBufferBindingArrays => Features::UNIFORM_BUFFER_BINDING_ARRAYS, GPUFeatureName::UniformBufferBindingArrays => Features::UNIFORM_BUFFER_BINDING_ARRAYS,
GPUFeatureName::PartiallyBoundBindingArray => Features::PARTIALLY_BOUND_BINDING_ARRAY, GPUFeatureName::PartiallyBoundBindingArray => Features::PARTIALLY_BOUND_BINDING_ARRAY,
GPUFeatureName::MultiDrawIndirectCount => Features::MULTI_DRAW_INDIRECT_COUNT, GPUFeatureName::MultiDrawIndirectCount => Features::MULTI_DRAW_INDIRECT_COUNT,
GPUFeatureName::PushConstants => Features::PUSH_CONSTANTS, GPUFeatureName::ImmediateData => Features::IMMEDIATES,
GPUFeatureName::AddressModeClampToZero => Features::ADDRESS_MODE_CLAMP_TO_ZERO, GPUFeatureName::AddressModeClampToZero => Features::ADDRESS_MODE_CLAMP_TO_ZERO,
GPUFeatureName::AddressModeClampToBorder => Features::ADDRESS_MODE_CLAMP_TO_BORDER, GPUFeatureName::AddressModeClampToBorder => Features::ADDRESS_MODE_CLAMP_TO_BORDER,
GPUFeatureName::PolygonModeLine => Features::POLYGON_MODE_LINE, GPUFeatureName::PolygonModeLine => Features::POLYGON_MODE_LINE,
@ -631,8 +631,8 @@ pub fn features_to_feature_names(
if features.contains(wgpu_types::Features::MULTI_DRAW_INDIRECT_COUNT) { if features.contains(wgpu_types::Features::MULTI_DRAW_INDIRECT_COUNT) {
return_features.insert(MultiDrawIndirectCount); return_features.insert(MultiDrawIndirectCount);
} }
if features.contains(wgpu_types::Features::PUSH_CONSTANTS) { if features.contains(wgpu_types::Features::IMMEDIATES) {
return_features.insert(PushConstants); return_features.insert(ImmediateData);
} }
if features.contains(wgpu_types::Features::ADDRESS_MODE_CLAMP_TO_ZERO) { if features.contains(wgpu_types::Features::ADDRESS_MODE_CLAMP_TO_ZERO) {
return_features.insert(AddressModeClampToZero); return_features.insert(AddressModeClampToZero);

View File

@ -42,7 +42,7 @@ These examples use a common framework to handle wgpu init, window creation, and
- `render_to_texture` - Renders to an image texture offscreen, demonstrating both off-screen rendering as well as how to add a sort of resolution-agnostic screenshot feature to an engine. This example either outputs an image file of your naming (pass command line arguments after specifying a `--` like `cargo run --bin wgpu-examples -- render_to_texture "test.png"`) or adds an `img` element containing the image to the page in WASM. - `render_to_texture` - Renders to an image texture offscreen, demonstrating both off-screen rendering as well as how to add a sort of resolution-agnostic screenshot feature to an engine. This example either outputs an image file of your naming (pass command line arguments after specifying a `--` like `cargo run --bin wgpu-examples -- render_to_texture "test.png"`) or adds an `img` element containing the image to the page in WASM.
- `ray_cube_fragment` - Demonstrates using ray queries with a fragment shader. - `ray_cube_fragment` - Demonstrates using ray queries with a fragment shader.
- `ray_scene` - Demonstrates using ray queries and model loading - `ray_scene` - Demonstrates using ray queries and model loading
- `ray_shadows` - Demonstrates a simple use of ray queries - high quality shadows - uses a light set with push constants to raytrace through an untransformed scene and detect whether there is something obstructing the light. - `ray_shadows` - Demonstrates a simple use of ray queries - high quality shadows - uses a light set with immediates to raytrace through an untransformed scene and detect whether there is something obstructing the light.
- `mesh_shader` - Renders a triangle to a window with mesh shaders, while showcasing most mesh shader related features(task shaders, payloads, per primitive data). - `mesh_shader` - Renders a triangle to a window with mesh shaders, while showcasing most mesh shader related features(task shaders, payloads, per primitive data).
#### Compute #### Compute

View File

@ -127,7 +127,7 @@ fn setup_pipeline(
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Compute Pipeline Layout"), label: Some("Compute Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {

View File

@ -107,7 +107,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("compute"), label: Some("compute"),
bind_group_layouts: &[&compute_bind_group_layout], bind_group_layouts: &[&compute_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
// create render pipeline with empty bind group layout // create render pipeline with empty bind group layout
@ -116,7 +116,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("render"), label: Some("render"),
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {

View File

@ -201,7 +201,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&global_bind_group_layout, &local_bind_group_layout], bind_group_layouts: &[&global_bind_group_layout, &local_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {

View File

@ -78,7 +78,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let shader_triangle_and_lines = let shader_triangle_and_lines =
@ -195,7 +195,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let shader = device.create_shader_module(wgpu::include_wgsl!("upscale.wgsl")); let shader = device.create_shader_module(wgpu::include_wgsl!("upscale.wgsl"));
( (

View File

@ -158,7 +158,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
// Create the texture // Create the texture

View File

@ -91,7 +91,7 @@ async fn execute(
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let patient_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { let patient_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None, label: None,

View File

@ -47,7 +47,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let swapchain_capabilities = surface.get_capabilities(&adapter); let swapchain_capabilities = surface.get_capabilities(&adapter);

View File

@ -100,7 +100,7 @@ async fn run() {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None, label: None,

View File

@ -104,7 +104,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor { let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None, label: None,

View File

@ -161,7 +161,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let multisampled_framebuffer = let multisampled_framebuffer =

View File

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

View File

@ -104,7 +104,7 @@ fn create_matrix(config: &wgpu::SurfaceConfiguration) -> Uniforms {
impl crate::framework::Example for Example { impl crate::framework::Example for Example {
fn required_features() -> wgpu::Features { fn required_features() -> wgpu::Features {
wgpu::Features::EXPERIMENTAL_RAY_QUERY | wgpu::Features::PUSH_CONSTANTS wgpu::Features::EXPERIMENTAL_RAY_QUERY | wgpu::Features::IMMEDIATES
} }
fn required_downlevel_capabilities() -> wgpu::DownlevelCapabilities { fn required_downlevel_capabilities() -> wgpu::DownlevelCapabilities {
@ -116,7 +116,7 @@ impl crate::framework::Example for Example {
fn required_limits() -> wgpu::Limits { fn required_limits() -> wgpu::Limits {
wgpu::Limits { wgpu::Limits {
max_push_constant_size: 12, max_immediate_size: 12,
..wgpu::Limits::default() ..wgpu::Limits::default()
} }
.using_minimum_supported_acceleration_structure_values() .using_minimum_supported_acceleration_structure_values()
@ -208,7 +208,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[wgpu::PushConstantRange { immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::FRAGMENT, stages: wgpu::ShaderStages::FRAGMENT,
range: 0..12, range: 0..12,
}], }],
@ -353,9 +353,9 @@ impl crate::framework::Example for Example {
rpass.set_pipeline(&self.pipeline); rpass.set_pipeline(&self.pipeline);
rpass.set_bind_group(0, Some(&self.bind_group), &[]); rpass.set_bind_group(0, Some(&self.bind_group), &[]);
rpass.set_push_constants(wgpu::ShaderStages::FRAGMENT, 0, &0.0_f32.to_ne_bytes()); rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 0, &0.0_f32.to_ne_bytes());
rpass.set_push_constants(wgpu::ShaderStages::FRAGMENT, 4, &cos.to_ne_bytes()); rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 4, &cos.to_ne_bytes());
rpass.set_push_constants(wgpu::ShaderStages::FRAGMENT, 8, &sin.to_ne_bytes()); rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 8, &sin.to_ne_bytes());
rpass.set_vertex_buffer(0, self.vertex_buf.slice(..)); rpass.set_vertex_buffer(0, self.vertex_buf.slice(..));
rpass.set_index_buffer(self.index_buf.slice(..), IndexFormat::Uint16); rpass.set_index_buffer(self.index_buf.slice(..), IndexFormat::Uint16);
rpass.draw_indexed(0..12, 0, 0..1); rpass.draw_indexed(0..12, 0, 0..1);

View File

@ -35,10 +35,10 @@ var<uniform> uniforms: Uniforms;
@group(0) @binding(1) @group(0) @binding(1)
var acc_struct: acceleration_structure; var acc_struct: acceleration_structure;
struct PushConstants { struct ImmediateData {
light: vec3<f32>, light: vec3<f32>,
} }
var<push_constant> pc: PushConstants; var<immediate> pc: ImmediateData;
const SURFACE_BRIGHTNESS = 0.5; const SURFACE_BRIGHTNESS = 0.5;

View File

@ -269,7 +269,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline layout for shader.wgsl"), label: Some("pipeline layout for shader.wgsl"),
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let compute_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { let compute_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
@ -284,7 +284,7 @@ impl crate::framework::Example for Example {
let blit_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let blit_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline layout for blit.wgsl"), label: Some("pipeline layout for blit.wgsl"),
bind_group_layouts: &[&blit_bgl], bind_group_layouts: &[&blit_bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let blit_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let blit_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {

View File

@ -229,7 +229,7 @@ impl WgpuContext {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None, label: None,

View File

@ -466,7 +466,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("shadow"), label: Some("shadow"),
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout], bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
@ -582,7 +582,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("main"), label: Some("main"),
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout], bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let mx_total = Self::generate_matrix(config.width as f32 / config.height as f32); let mx_total = Self::generate_matrix(config.width as f32 / config.height as f32);

View File

@ -187,7 +187,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
// Create the render pipelines // Create the render pipelines

View File

@ -92,7 +92,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
// Create bind group // Create bind group

View File

@ -48,7 +48,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl")); let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));

View File

@ -90,7 +90,7 @@ async fn run(_path: Option<String>) {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None, label: None,

View File

@ -328,7 +328,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("main"), label: Some("main"),
bind_group_layouts: &[&bind_group_layout, &uniform_bind_group_layout], bind_group_layouts: &[&bind_group_layout, &uniform_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let index_format = wgpu::IndexFormat::Uint16; let index_format = wgpu::IndexFormat::Uint16;

View File

@ -351,7 +351,7 @@ fn render_pass(
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {

View File

@ -162,7 +162,7 @@ impl WgpuContext {
label: None, label: None,
// (4) // (4)
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let swapchain_capabilities = surface.get_capabilities(&adapter); let swapchain_capabilities = surface.get_capabilities(&adapter);

View File

@ -428,14 +428,14 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("water"), label: Some("water"),
bind_group_layouts: &[&water_bind_group_layout], bind_group_layouts: &[&water_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let terrain_pipeline_layout = let terrain_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("terrain"), label: Some("terrain"),
bind_group_layouts: &[&terrain_bind_group_layout], bind_group_layouts: &[&terrain_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let water_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { let water_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {

View File

@ -168,7 +168,7 @@ fn main() {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
// The pipeline is the ready-to-go program state for the GPU. It contains the shader modules, // The pipeline is the ready-to-go program state for the GPU. It contains the shader modules,

View File

@ -439,7 +439,7 @@ impl<W> Writer<'_, W> {
} }
} }
let mut push_constant_used = false; let mut immediates_used = false;
for (handle, global) in self.module.global_variables.iter() { for (handle, global) in self.module.global_variables.iter() {
if ep_info[handle].is_empty() { if ep_info[handle].is_empty() {
@ -448,11 +448,11 @@ impl<W> Writer<'_, W> {
match global.space { match global.space {
AddressSpace::WorkGroup => self.features.request(Features::COMPUTE_SHADER), AddressSpace::WorkGroup => self.features.request(Features::COMPUTE_SHADER),
AddressSpace::Storage { .. } => self.features.request(Features::BUFFER_STORAGE), AddressSpace::Storage { .. } => self.features.request(Features::BUFFER_STORAGE),
AddressSpace::PushConstant => { AddressSpace::Immediate => {
if push_constant_used { if immediates_used {
return Err(Error::MultiplePushConstants); return Err(Error::MultipleImmediateData);
} }
push_constant_used = true; immediates_used = true;
} }
_ => {} _ => {}
} }

View File

@ -139,7 +139,7 @@ impl crate::AddressSpace {
| crate::AddressSpace::Uniform | crate::AddressSpace::Uniform
| crate::AddressSpace::Storage { .. } | crate::AddressSpace::Storage { .. }
| crate::AddressSpace::Handle | crate::AddressSpace::Handle
| crate::AddressSpace::PushConstant | crate::AddressSpace::Immediate
| crate::AddressSpace::TaskPayload => false, | crate::AddressSpace::TaskPayload => false,
} }
} }
@ -376,8 +376,8 @@ pub struct ReflectionInfo {
pub uniforms: crate::FastHashMap<Handle<crate::GlobalVariable>, String>, pub uniforms: crate::FastHashMap<Handle<crate::GlobalVariable>, String>,
/// Mapping between names and attribute locations. /// Mapping between names and attribute locations.
pub varying: crate::FastHashMap<String, VaryingLocation>, pub varying: crate::FastHashMap<String, VaryingLocation>,
/// List of push constant items in the shader. /// List of immediate data items in the shader.
pub push_constant_items: Vec<PushConstantItem>, pub immediates_items: Vec<ImmediateItem>,
/// Number of user-defined clip planes. Only applicable to vertex shaders. /// Number of user-defined clip planes. Only applicable to vertex shaders.
pub clip_distance_count: u32, pub clip_distance_count: u32,
} }
@ -401,14 +401,14 @@ pub struct TextureMapping {
/// All information to bind a single uniform value to the shader. /// All information to bind a single uniform value to the shader.
/// ///
/// Push constants are emulated using traditional uniforms in OpenGL. /// Immediates are emulated using traditional uniforms in OpenGL.
/// ///
/// These are composed of a set of primitives (scalar, vector, matrix) that /// These are composed of a set of primitives (scalar, vector, matrix) that
/// are given names. Because they are not backed by the concept of a buffer, /// are given names. Because they are not backed by the concept of a buffer,
/// we must do the work of calculating the offset of each primitive in the /// we must do the work of calculating the offset of each primitive in the
/// push constant block. /// immediate data block.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct PushConstantItem { pub struct ImmediateItem {
/// GL uniform name for the item. This name is the same as if you were /// GL uniform name for the item. This name is the same as if you were
/// to access it directly from a GLSL shader. /// to access it directly from a GLSL shader.
/// ///
@ -420,24 +420,24 @@ pub struct PushConstantItem {
/// value: f32, /// value: f32,
/// } /// }
/// ///
/// struct PushConstant { /// struct ImmediateData {
/// InnerStruct inner; /// InnerStruct inner;
/// vec4 array[2]; /// vec4 array[2];
/// } /// }
/// ///
/// uniform PushConstants _push_constant_binding_cs; /// uniform ImmediateData _immediates_binding_cs;
/// ``` /// ```
/// ///
/// ```text /// ```text
/// - _push_constant_binding_cs.inner.value /// - _immediates_binding_cs.inner.value
/// - _push_constant_binding_cs.array[0] /// - _immediates_binding_cs.array[0]
/// - _push_constant_binding_cs.array[1] /// - _immediates_binding_cs.array[1]
/// ``` /// ```
/// ///
pub access_path: String, pub access_path: String,
/// Type of the uniform. This will only ever be a scalar, vector, or matrix. /// Type of the uniform. This will only ever be a scalar, vector, or matrix.
pub ty: Handle<crate::Type>, pub ty: Handle<crate::Type>,
/// The offset in the push constant memory block this uniform maps to. /// The offset in the immediate data memory block this uniform maps to.
/// ///
/// The size of the uniform can be derived from the type. /// The size of the uniform can be derived from the type.
pub offset: u32, pub offset: u32,
@ -540,10 +540,10 @@ pub enum Error {
/// Contains the missing [`Features`]. /// Contains the missing [`Features`].
#[error("The selected version doesn't support {0:?}")] #[error("The selected version doesn't support {0:?}")]
MissingFeatures(Features), MissingFeatures(Features),
/// [`AddressSpace::PushConstant`](crate::AddressSpace::PushConstant) was used more than /// [`AddressSpace::Immediate`](crate::AddressSpace::Immediate) was used more than
/// once in the entry point, which isn't supported. /// once in the entry point, which isn't supported.
#[error("Multiple push constants aren't supported")] #[error("Multiple immediates aren't supported")]
MultiplePushConstants, MultipleImmediateData,
/// The specified [`Version`] isn't supported. /// The specified [`Version`] isn't supported.
#[error("The specified version isn't supported")] #[error("The specified version isn't supported")]
VersionNotSupported, VersionNotSupported,
@ -668,7 +668,7 @@ impl<'a, W: Write> Writer<'a, W> {
&[ &[
"gl_", // all GL built-in variables "gl_", // all GL built-in variables
"_group", // all normal bindings "_group", // all normal bindings
"_push_constant_binding_", // all push constant bindings "_immediates_binding_", // all immediate data bindings
], ],
&mut names, &mut names,
); );
@ -1292,7 +1292,7 @@ impl<'a, W: Write> Writer<'a, W> {
crate::AddressSpace::WorkGroup => { crate::AddressSpace::WorkGroup => {
self.write_simple_global(handle, global)?; self.write_simple_global(handle, global)?;
} }
crate::AddressSpace::PushConstant => { crate::AddressSpace::Immediate => {
self.write_simple_global(handle, global)?; self.write_simple_global(handle, global)?;
} }
crate::AddressSpace::Uniform => { crate::AddressSpace::Uniform => {
@ -1338,7 +1338,7 @@ impl<'a, W: Write> Writer<'a, W> {
writeln!(self.out, ";")?; writeln!(self.out, ";")?;
if let crate::AddressSpace::PushConstant = global.space { if let crate::AddressSpace::Immediate = global.space {
let global_name = self.get_global_name(handle, global); let global_name = self.get_global_name(handle, global);
self.reflection_names_globals.insert(handle, global_name); self.reflection_names_globals.insert(handle, global_name);
} }
@ -1528,8 +1528,8 @@ impl<'a, W: Write> Writer<'a, W> {
self.entry_point.stage.to_str() self.entry_point.stage.to_str()
) )
} }
(&None, crate::AddressSpace::PushConstant) => { (&None, crate::AddressSpace::Immediate) => {
format!("_push_constant_binding_{}", self.entry_point.stage.to_str()) format!("_immediates_binding_{}", self.entry_point.stage.to_str())
} }
(&None, _) => self.names[&NameKey::GlobalVariable(handle)].clone(), (&None, _) => self.names[&NameKey::GlobalVariable(handle)].clone(),
} }
@ -1549,9 +1549,9 @@ impl<'a, W: Write> Writer<'a, W> {
br.binding, br.binding,
self.entry_point.stage.to_str() self.entry_point.stage.to_str()
)?, )?,
(&None, crate::AddressSpace::PushConstant) => write!( (&None, crate::AddressSpace::Immediate) => write!(
self.out, self.out,
"_push_constant_binding_{}", "_immediates_binding_{}",
self.entry_point.stage.to_str() self.entry_point.stage.to_str()
)?, )?,
(&None, _) => write!( (&None, _) => write!(
@ -5022,7 +5022,7 @@ impl<'a, W: Write> Writer<'a, W> {
} }
} }
let mut push_constant_info = None; let mut immediates_info = None;
for (handle, var) in self.module.global_variables.iter() { for (handle, var) in self.module.global_variables.iter() {
if info[handle].is_empty() { if info[handle].is_empty() {
continue; continue;
@ -5047,19 +5047,19 @@ impl<'a, W: Write> Writer<'a, W> {
let name = self.reflection_names_globals[&handle].clone(); let name = self.reflection_names_globals[&handle].clone();
uniforms.insert(handle, name); uniforms.insert(handle, name);
} }
crate::AddressSpace::PushConstant => { crate::AddressSpace::Immediate => {
let name = self.reflection_names_globals[&handle].clone(); let name = self.reflection_names_globals[&handle].clone();
push_constant_info = Some((name, var.ty)); immediates_info = Some((name, var.ty));
} }
_ => (), _ => (),
}, },
} }
} }
let mut push_constant_segments = Vec::new(); let mut immediates_segments = Vec::new();
let mut push_constant_items = vec![]; let mut immediates_items = vec![];
if let Some((name, ty)) = push_constant_info { if let Some((name, ty)) = immediates_info {
// We don't have a layouter available to us, so we need to create one. // We don't have a layouter available to us, so we need to create one.
// //
// This is potentially a bit wasteful, but the set of types in the program // This is potentially a bit wasteful, but the set of types in the program
@ -5068,15 +5068,15 @@ impl<'a, W: Write> Writer<'a, W> {
layouter.update(self.module.to_ctx()).unwrap(); layouter.update(self.module.to_ctx()).unwrap();
// We start with the name of the binding itself. // We start with the name of the binding itself.
push_constant_segments.push(name); immediates_segments.push(name);
// We then recursively collect all the uniform fields of the push constant. // We then recursively collect all the uniform fields of the immediate data.
self.collect_push_constant_items( self.collect_immediates_items(
ty, ty,
&mut push_constant_segments, &mut immediates_segments,
&layouter, &layouter,
&mut 0, &mut 0,
&mut push_constant_items, &mut immediates_items,
); );
} }
@ -5084,18 +5084,18 @@ impl<'a, W: Write> Writer<'a, W> {
texture_mapping, texture_mapping,
uniforms, uniforms,
varying: mem::take(&mut self.varying), varying: mem::take(&mut self.varying),
push_constant_items, immediates_items,
clip_distance_count: self.clip_distance_count, clip_distance_count: self.clip_distance_count,
}) })
} }
fn collect_push_constant_items( fn collect_immediates_items(
&mut self, &mut self,
ty: Handle<crate::Type>, ty: Handle<crate::Type>,
segments: &mut Vec<String>, segments: &mut Vec<String>,
layouter: &proc::Layouter, layouter: &proc::Layouter,
offset: &mut u32, offset: &mut u32,
items: &mut Vec<PushConstantItem>, items: &mut Vec<ImmediateItem>,
) { ) {
// At this point in the recursion, `segments` contains the path // At this point in the recursion, `segments` contains the path
// needed to access `ty` from the root. // needed to access `ty` from the root.
@ -5107,7 +5107,7 @@ impl<'a, W: Write> Writer<'a, W> {
TypeInner::Scalar { .. } | TypeInner::Vector { .. } | TypeInner::Matrix { .. } => { TypeInner::Scalar { .. } | TypeInner::Vector { .. } | TypeInner::Matrix { .. } => {
// Build the full name, by combining all current segments. // Build the full name, by combining all current segments.
let name: String = segments.iter().map(String::as_str).collect(); let name: String = segments.iter().map(String::as_str).collect();
items.push(PushConstantItem { items.push(ImmediateItem {
access_path: name, access_path: name,
offset: *offset, offset: *offset,
ty, ty,
@ -5117,13 +5117,13 @@ impl<'a, W: Write> Writer<'a, W> {
// Arrays are recursed into. // Arrays are recursed into.
TypeInner::Array { base, size, .. } => { TypeInner::Array { base, size, .. } => {
let crate::ArraySize::Constant(count) = size else { let crate::ArraySize::Constant(count) = size else {
unreachable!("Cannot have dynamic arrays in push constants"); unreachable!("Cannot have dynamic arrays in immediates");
}; };
for i in 0..count.get() { for i in 0..count.get() {
// Add the array accessor and recurse. // Add the array accessor and recurse.
segments.push(format!("[{i}]")); segments.push(format!("[{i}]"));
self.collect_push_constant_items(base, segments, layouter, offset, items); self.collect_immediates_items(base, segments, layouter, offset, items);
segments.pop(); segments.pop();
} }
@ -5137,7 +5137,7 @@ impl<'a, W: Write> Writer<'a, W> {
".{}", ".{}",
self.names[&NameKey::StructMember(ty, index as u32)] self.names[&NameKey::StructMember(ty, index as u32)]
)); ));
self.collect_push_constant_items(member.ty, segments, layouter, offset, items); self.collect_immediates_items(member.ty, segments, layouter, offset, items);
segments.pop(); segments.pop();
} }
@ -5286,7 +5286,7 @@ const fn glsl_storage_qualifier(space: crate::AddressSpace) -> Option<&'static s
As::Uniform => Some("uniform"), As::Uniform => Some("uniform"),
As::Handle => Some("uniform"), As::Handle => Some("uniform"),
As::WorkGroup => Some("shared"), As::WorkGroup => Some("shared"),
As::PushConstant => Some("uniform"), As::Immediate => Some("uniform"),
As::TaskPayload => unreachable!(), As::TaskPayload => unreachable!(),
} }
} }

View File

@ -177,15 +177,15 @@ use crate::{back, ir, proc};
/// ///
/// The [`back::hlsl::Options`] structure provides `BindTarget`s for various /// The [`back::hlsl::Options`] structure provides `BindTarget`s for various
/// situations in which Naga may need to generate an HLSL global variable, like /// situations in which Naga may need to generate an HLSL global variable, like
/// [`binding_map`] for Naga global variables, or [`push_constants_target`] for /// [`binding_map`] for Naga global variables, or [`immediates_target`] for
/// a module's sole [`PushConstant`] variable. See those fields' documentation /// a module's sole [`Immediate`] variable. See those fields' documentation
/// for details. /// for details.
/// ///
/// [`Storage`]: crate::ir::AddressSpace::Storage /// [`Storage`]: crate::ir::AddressSpace::Storage
/// [`back::hlsl::Options`]: Options /// [`back::hlsl::Options`]: Options
/// [`binding_map`]: Options::binding_map /// [`binding_map`]: Options::binding_map
/// [`push_constants_target`]: Options::push_constants_target /// [`immediates_target`]: Options::immediates_target
/// [`PushConstant`]: crate::ir::AddressSpace::PushConstant /// [`Immediate`]: crate::ir::AddressSpace::Immediate
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
@ -498,16 +498,16 @@ pub struct Options {
/// to make them work like in Vulkan/Metal, with help of the host. /// to make them work like in Vulkan/Metal, with help of the host.
pub special_constants_binding: Option<BindTarget>, pub special_constants_binding: Option<BindTarget>,
/// HLSL binding information for the [`PushConstant`] global, if present. /// HLSL binding information for the [`Immediate`] global, if present.
/// ///
/// If a module contains a global in the [`PushConstant`] address space, the /// If a module contains a global in the [`Immediate`] address space, the
/// `dx12` backend stores its value directly in the root signature as a /// `dx12` backend stores its value directly in the root signature as a
/// series of [`D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS`], whose binding /// series of [`D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS`], whose binding
/// information is given here. /// information is given here.
/// ///
/// [`PushConstant`]: crate::ir::AddressSpace::PushConstant /// [`Immediate`]: crate::ir::AddressSpace::Immediate
/// [`D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS`]: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_root_parameter_type /// [`D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS`]: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_root_parameter_type
pub push_constants_target: Option<BindTarget>, pub immediates_target: Option<BindTarget>,
/// HLSL binding information for the sampler heap and comparison sampler heap. /// HLSL binding information for the sampler heap and comparison sampler heap.
pub sampler_heap_target: SamplerHeapBindTargets, pub sampler_heap_target: SamplerHeapBindTargets,
@ -554,7 +554,7 @@ impl Default for Options {
special_constants_binding: None, special_constants_binding: None,
sampler_heap_target: SamplerHeapBindTargets::default(), sampler_heap_target: SamplerHeapBindTargets::default(),
sampler_buffer_binding_map: alloc::collections::BTreeMap::default(), sampler_buffer_binding_map: alloc::collections::BTreeMap::default(),
push_constants_target: None, immediates_target: None,
dynamic_storage_buffer_offsets_targets: alloc::collections::BTreeMap::new(), dynamic_storage_buffer_offsets_targets: alloc::collections::BTreeMap::new(),
external_texture_binding_map: ExternalTextureBindingMap::default(), external_texture_binding_map: ExternalTextureBindingMap::default(),
zero_initialize_workgroup_memory: true, zero_initialize_workgroup_memory: true,

View File

@ -1003,16 +1003,16 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
self.write_type(module, global.ty)?; self.write_type(module, global.ty)?;
register register
} }
crate::AddressSpace::PushConstant => { crate::AddressSpace::Immediate => {
// The type of the push constants will be wrapped in `ConstantBuffer` // The type of the immediates will be wrapped in `ConstantBuffer`
write!(self.out, "ConstantBuffer<")?; write!(self.out, "ConstantBuffer<")?;
"b" "b"
} }
}; };
// If the global is a push constant write the type now because it will be a // If the global is a immediate data write the type now because it will be a
// generic argument to `ConstantBuffer` // generic argument to `ConstantBuffer`
if global.space == crate::AddressSpace::PushConstant { if global.space == crate::AddressSpace::Immediate {
self.write_global_type(module, global.ty)?; self.write_global_type(module, global.ty)?;
// need to write the array size if the type was emitted with `write_type` // need to write the array size if the type was emitted with `write_type`
@ -1027,9 +1027,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
let name = &self.names[&NameKey::GlobalVariable(handle)]; let name = &self.names[&NameKey::GlobalVariable(handle)];
write!(self.out, " {name}")?; write!(self.out, " {name}")?;
// Push constants need to be assigned a binding explicitly by the consumer // Immediates need to be assigned a binding explicitly by the consumer
// since naga has no way to know the binding from the shader alone // since naga has no way to know the binding from the shader alone
if global.space == crate::AddressSpace::PushConstant { if global.space == crate::AddressSpace::Immediate {
match module.types[global.ty].inner { match module.types[global.ty].inner {
TypeInner::Struct { .. } => {} TypeInner::Struct { .. } => {}
_ => { _ => {
@ -1041,9 +1041,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
let target = self let target = self
.options .options
.push_constants_target .immediates_target
.as_ref() .as_ref()
.expect("No bind target was defined for the push constants block"); .expect("No bind target was defined for the immediates block");
write!(self.out, ": register(b{}", target.register)?; write!(self.out, ": register(b{}", target.register)?;
if target.space != 0 { if target.space != 0 {
write!(self.out, ", space{}", target.space)?; write!(self.out, ", space{}", target.space)?;
@ -3085,7 +3085,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
crate::AddressSpace::Function crate::AddressSpace::Function
| crate::AddressSpace::Private | crate::AddressSpace::Private
| crate::AddressSpace::WorkGroup | crate::AddressSpace::WorkGroup
| crate::AddressSpace::PushConstant | crate::AddressSpace::Immediate
| crate::AddressSpace::TaskPayload, | crate::AddressSpace::TaskPayload,
) )
| None => true, | None => true,

View File

@ -155,7 +155,7 @@ pub struct EntryPointResources {
)] )]
pub resources: BindingMap, pub resources: BindingMap,
pub push_constant_buffer: Option<Slot>, pub immediates_buffer: Option<Slot>,
/// The slot of a buffer that contains an array of `u32`, /// The slot of a buffer that contains an array of `u32`,
/// one for the size of each bound buffer that contains a runtime array, /// one for the size of each bound buffer that contains a runtime array,
@ -247,8 +247,8 @@ pub enum EntryPointError {
MissingBinding(String), MissingBinding(String),
#[error("mapping of {0:?} is missing")] #[error("mapping of {0:?} is missing")]
MissingBindTarget(crate::ResourceBinding), MissingBindTarget(crate::ResourceBinding),
#[error("mapping for push constants is missing")] #[error("mapping for immediates is missing")]
MissingPushConstants, MissingImmediateData,
#[error("mapping for sizes buffer is missing")] #[error("mapping for sizes buffer is missing")]
MissingSizesBuffer, MissingSizesBuffer,
} }
@ -618,13 +618,13 @@ impl Options {
} }
} }
fn resolve_push_constants( fn resolve_immediates(
&self, &self,
ep: &crate::EntryPoint, ep: &crate::EntryPoint,
) -> Result<ResolvedBinding, EntryPointError> { ) -> Result<ResolvedBinding, EntryPointError> {
let slot = self let slot = self
.get_entry_point_resources(ep) .get_entry_point_resources(ep)
.and_then(|res| res.push_constant_buffer); .and_then(|res| res.immediates_buffer);
match slot { match slot {
Some(slot) => Ok(ResolvedBinding::Resource(BindTarget { Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
buffer: Some(slot), buffer: Some(slot),
@ -635,7 +635,7 @@ impl Options {
index: 0, index: 0,
interpolation: None, interpolation: None,
}), }),
None => Err(EntryPointError::MissingPushConstants), None => Err(EntryPointError::MissingImmediateData),
} }
} }

View File

@ -594,7 +594,7 @@ impl crate::AddressSpace {
| Self::Storage { .. } | Self::Storage { .. }
| Self::Private | Self::Private
| Self::WorkGroup | Self::WorkGroup
| Self::PushConstant | Self::Immediate
| Self::Handle | Self::Handle
| Self::TaskPayload => true, | Self::TaskPayload => true,
Self::Function => false, Self::Function => false,
@ -613,7 +613,7 @@ impl crate::AddressSpace {
// These should always be read-write. // These should always be read-write.
Self::Private | Self::WorkGroup => false, Self::Private | Self::WorkGroup => false,
// These translate to `constant` address space, no need for qualifiers. // These translate to `constant` address space, no need for qualifiers.
Self::Uniform | Self::PushConstant => false, Self::Uniform | Self::Immediate => false,
// Not applicable. // Not applicable.
Self::Handle | Self::Function => false, Self::Handle | Self::Function => false,
} }
@ -622,7 +622,7 @@ impl crate::AddressSpace {
const fn to_msl_name(self) -> Option<&'static str> { const fn to_msl_name(self) -> Option<&'static str> {
match self { match self {
Self::Handle => None, Self::Handle => None,
Self::Uniform | Self::PushConstant => Some("constant"), Self::Uniform | Self::Immediate => Some("constant"),
Self::Storage { .. } => Some("device"), Self::Storage { .. } => Some("device"),
Self::Private | Self::Function => Some("thread"), Self::Private | Self::Function => Some("thread"),
Self::WorkGroup => Some("threadgroup"), Self::WorkGroup => Some("threadgroup"),
@ -6732,8 +6732,8 @@ template <typename A>
break; break;
} }
} }
crate::AddressSpace::PushConstant => { crate::AddressSpace::Immediate => {
if let Err(e) = options.resolve_push_constants(ep) { if let Err(e) = options.resolve_immediates(ep) {
ep_error = Some(e); ep_error = Some(e);
break; break;
} }
@ -7164,7 +7164,7 @@ template <typename A>
// the resolves have already been checked for `!fake_missing_bindings` case // the resolves have already been checked for `!fake_missing_bindings` case
let resolved = match var.space { let resolved = match var.space {
crate::AddressSpace::PushConstant => options.resolve_push_constants(ep).ok(), crate::AddressSpace::Immediate => options.resolve_immediates(ep).ok(),
crate::AddressSpace::WorkGroup => None, crate::AddressSpace::WorkGroup => None,
_ => options _ => options
.resolve_resource_binding(ep, var.binding.as_ref().unwrap()) .resolve_resource_binding(ep, var.binding.as_ref().unwrap())

View File

@ -53,7 +53,7 @@ pub(super) const fn map_storage_class(space: crate::AddressSpace) -> spirv::Stor
crate::AddressSpace::Storage { .. } => spirv::StorageClass::StorageBuffer, crate::AddressSpace::Storage { .. } => spirv::StorageClass::StorageBuffer,
crate::AddressSpace::Uniform => spirv::StorageClass::Uniform, crate::AddressSpace::Uniform => spirv::StorageClass::Uniform,
crate::AddressSpace::WorkGroup => spirv::StorageClass::Workgroup, crate::AddressSpace::WorkGroup => spirv::StorageClass::Workgroup,
crate::AddressSpace::PushConstant => spirv::StorageClass::PushConstant, crate::AddressSpace::Immediate => spirv::StorageClass::PushConstant,
crate::AddressSpace::TaskPayload => unreachable!(), crate::AddressSpace::TaskPayload => unreachable!(),
} }
} }
@ -98,7 +98,7 @@ pub fn global_needs_wrapper(ir_module: &crate::Module, var: &crate::GlobalVariab
match var.space { match var.space {
crate::AddressSpace::Uniform crate::AddressSpace::Uniform
| crate::AddressSpace::Storage { .. } | crate::AddressSpace::Storage { .. }
| crate::AddressSpace::PushConstant => {} | crate::AddressSpace::Immediate => {}
_ => return false, _ => return false,
}; };
match ir_module.types[var.ty].inner { match ir_module.types[var.ty].inner {

View File

@ -358,7 +358,7 @@ pub const fn address_space_str(
"storage" "storage"
} }
} }
As::PushConstant => "push_constant", As::Immediate => "immediate",
As::WorkGroup => "workgroup", As::WorkGroup => "workgroup",
As::Handle => return (None, None), As::Handle => return (None, None),
As::Function => "function", As::Function => "function",

View File

@ -555,7 +555,7 @@ impl Frontend {
TypeInner::Sampler { .. } => space = AddressSpace::Handle, TypeInner::Sampler { .. } => space = AddressSpace::Handle,
_ => { _ => {
if qualifiers.none_layout_qualifier("push_constant", &mut self.errors) { if qualifiers.none_layout_qualifier("push_constant", &mut self.errors) {
space = AddressSpace::PushConstant space = AddressSpace::Immediate
} }
} }
}, },

View File

@ -182,7 +182,7 @@ pub(super) fn map_storage_class(word: spirv::Word) -> Result<super::ExtendedClas
// we expect the `Storage` case to be filtered out before calling this function. // we expect the `Storage` case to be filtered out before calling this function.
Some(Sc::Uniform) => Ec::Global(crate::AddressSpace::Uniform), Some(Sc::Uniform) => Ec::Global(crate::AddressSpace::Uniform),
Some(Sc::Workgroup) => Ec::Global(crate::AddressSpace::WorkGroup), Some(Sc::Workgroup) => Ec::Global(crate::AddressSpace::WorkGroup),
Some(Sc::PushConstant) => Ec::Global(crate::AddressSpace::PushConstant), Some(Sc::PushConstant) => Ec::Global(crate::AddressSpace::Immediate),
_ => return Err(Error::UnsupportedStorageClass(word)), _ => return Err(Error::UnsupportedStorageClass(word)),
}) })
} }

View File

@ -18,7 +18,7 @@ pub fn map_address_space<'a>(
"storage" => Ok(crate::AddressSpace::Storage { "storage" => Ok(crate::AddressSpace::Storage {
access: crate::StorageAccess::default(), access: crate::StorageAccess::default(),
}), }),
"push_constant" => Ok(crate::AddressSpace::PushConstant), "immediate" => Ok(crate::AddressSpace::Immediate),
"function" => Ok(crate::AddressSpace::Function), "function" => Ok(crate::AddressSpace::Function),
"task_payload" => { "task_payload" => {
if enable_extensions.contains(ImplementedEnableExtension::WgpuMeshShader) { if enable_extensions.contains(ImplementedEnableExtension::WgpuMeshShader) {

View File

@ -356,21 +356,21 @@ pub enum AddressSpace {
/// Opaque handles, such as samplers and images. /// Opaque handles, such as samplers and images.
Handle, Handle,
/// Push constants. /// Immediate data.
/// ///
/// A [`Module`] may contain at most one [`GlobalVariable`] in /// A [`Module`] may contain at most one [`GlobalVariable`] in
/// this address space. Its contents are provided not by a buffer /// this address space. Its contents are provided not by a buffer
/// but by `SetPushConstant` pass commands, allowing the CPU to /// but by `SetImmediates` pass commands, allowing the CPU to
/// establish different values for each draw/dispatch. /// establish different values for each draw/dispatch.
/// ///
/// `PushConstant` variables may not contain `f16` values, even if /// `Immediate` variables may not contain `f16` values, even if
/// the [`SHADER_FLOAT16`] capability is enabled. /// the [`SHADER_FLOAT16`] capability is enabled.
/// ///
/// Backends generally place tight limits on the size of /// Backends generally place tight limits on the size of
/// `PushConstant` variables. /// `Immediate` variables.
/// ///
/// [`SHADER_FLOAT16`]: crate::valid::Capabilities::SHADER_FLOAT16 /// [`SHADER_FLOAT16`]: crate::valid::Capabilities::SHADER_FLOAT16
PushConstant, Immediate,
/// Task shader to mesh shader payload /// Task shader to mesh shader payload
TaskPayload, TaskPayload,
} }

View File

@ -182,7 +182,7 @@ impl super::AddressSpace {
crate::AddressSpace::Uniform => Sa::LOAD, crate::AddressSpace::Uniform => Sa::LOAD,
crate::AddressSpace::Storage { access } => access, crate::AddressSpace::Storage { access } => access,
crate::AddressSpace::Handle => Sa::LOAD, crate::AddressSpace::Handle => Sa::LOAD,
crate::AddressSpace::PushConstant => Sa::LOAD, crate::AddressSpace::Immediate => Sa::LOAD,
// TaskPayload isn't always writable, but this is checked for elsewhere, // TaskPayload isn't always writable, but this is checked for elsewhere,
// when not using multiple payloads and matching the entry payload is checked. // when not using multiple payloads and matching the entry payload is checked.
crate::AddressSpace::TaskPayload => Sa::LOAD | Sa::STORE, crate::AddressSpace::TaskPayload => Sa::LOAD | Sa::STORE,

View File

@ -654,7 +654,7 @@ impl FunctionInfo {
// task payload memory is very similar to workgroup memory // task payload memory is very similar to workgroup memory
As::WorkGroup | As::TaskPayload => true, As::WorkGroup | As::TaskPayload => true,
// uniform data // uniform data
As::Uniform | As::PushConstant => true, As::Uniform | As::Immediate => true,
// storage data is only uniform when read-only // storage data is only uniform when read-only
As::Storage { access } => !access.contains(crate::StorageAccess::STORE), As::Storage { access } => !access.contains(crate::StorageAccess::STORE),
As::Handle => false, As::Handle => false,

View File

@ -4,7 +4,7 @@ use bit_set::BitSet;
use super::{ use super::{
analyzer::{FunctionInfo, GlobalUse}, analyzer::{FunctionInfo, GlobalUse},
Capabilities, Disalignment, FunctionError, ModuleInfo, PushConstantError, Capabilities, Disalignment, FunctionError, ImmediateError, ModuleInfo,
}; };
use crate::arena::{Handle, UniqueArena}; use crate::arena::{Handle, UniqueArena};
use crate::span::{AddSpan as _, MapErrWithSpan as _, SpanProvider as _, WithSpan}; use crate::span::{AddSpan as _, MapErrWithSpan as _, SpanProvider as _, WithSpan};
@ -41,8 +41,8 @@ pub enum GlobalVariableError {
InitializerNotAllowed(crate::AddressSpace), InitializerNotAllowed(crate::AddressSpace),
#[error("Storage address space doesn't support write-only access")] #[error("Storage address space doesn't support write-only access")]
StorageAddressSpaceWriteOnlyNotSupported, StorageAddressSpaceWriteOnlyNotSupported,
#[error("Type is not valid for use as a push constant")] #[error("Type is not valid for use as a immediate data")]
InvalidPushConstantType(#[source] PushConstantError), InvalidImmediateType(#[source] ImmediateError),
#[error("Task payload must not be zero-sized")] #[error("Task payload must not be zero-sized")]
ZeroSizedTaskPayload, ZeroSizedTaskPayload,
} }
@ -117,8 +117,8 @@ pub enum EntryPointError {
ForbiddenStageOperations, ForbiddenStageOperations,
#[error("Global variable {0:?} is used incorrectly as {1:?}")] #[error("Global variable {0:?} is used incorrectly as {1:?}")]
InvalidGlobalUsage(Handle<crate::GlobalVariable>, GlobalUse), InvalidGlobalUsage(Handle<crate::GlobalVariable>, GlobalUse),
#[error("More than 1 push constant variable is used")] #[error("More than 1 immediate data variable is used")]
MoreThanOnePushConstantUsed, MoreThanOneImmediateUsed,
#[error("Bindings for {0:?} conflict with other resource")] #[error("Bindings for {0:?} conflict with other resource")]
BindingCollision(Handle<crate::GlobalVariable>), BindingCollision(Handle<crate::GlobalVariable>),
#[error("Argument {0} varying error")] #[error("Argument {0} varying error")]
@ -740,14 +740,14 @@ impl super::Validator {
} }
(TypeFlags::DATA | TypeFlags::SIZED, false) (TypeFlags::DATA | TypeFlags::SIZED, false)
} }
crate::AddressSpace::PushConstant => { crate::AddressSpace::Immediate => {
if !self.capabilities.contains(Capabilities::PUSH_CONSTANT) { if !self.capabilities.contains(Capabilities::IMMEDIATES) {
return Err(GlobalVariableError::UnsupportedCapability( return Err(GlobalVariableError::UnsupportedCapability(
Capabilities::PUSH_CONSTANT, Capabilities::IMMEDIATES,
)); ));
} }
if let Err(ref err) = type_info.push_constant_compatibility { if let Err(ref err) = type_info.immediates_compatibility {
return Err(GlobalVariableError::InvalidPushConstantType(err.clone())); return Err(GlobalVariableError::InvalidImmediateType(err.clone()));
} }
( (
TypeFlags::DATA TypeFlags::DATA
@ -1031,16 +1031,16 @@ impl super::Validator {
} }
{ {
let mut used_push_constants = module let mut used_immediates = module
.global_variables .global_variables
.iter() .iter()
.filter(|&(_, var)| var.space == crate::AddressSpace::PushConstant) .filter(|&(_, var)| var.space == crate::AddressSpace::Immediate)
.map(|(handle, _)| handle) .map(|(handle, _)| handle)
.filter(|&handle| !info[handle].is_empty()); .filter(|&handle| !info[handle].is_empty());
// Check if there is more than one push constant, and error if so. // Check if there is more than one immediate data, and error if so.
// Use a loop for when returning multiple errors is supported. // Use a loop for when returning multiple errors is supported.
if let Some(handle) = used_push_constants.nth(1) { if let Some(handle) = used_immediates.nth(1) {
return Err(EntryPointError::MoreThanOnePushConstantUsed return Err(EntryPointError::MoreThanOneImmediateUsed
.with_span_handle(handle, &module.global_variables)); .with_span_handle(handle, &module.global_variables));
} }
} }
@ -1094,7 +1094,7 @@ impl super::Validator {
GlobalUse::empty() GlobalUse::empty()
} }
} }
crate::AddressSpace::PushConstant => GlobalUse::READ, crate::AddressSpace::Immediate => GlobalUse::READ,
}; };
if !allowed_usage.contains(usage) { if !allowed_usage.contains(usage) {
log::warn!("\tUsage error for: {var:?}"); log::warn!("\tUsage error for: {var:?}");

View File

@ -31,7 +31,7 @@ pub use expression::{check_literal_value, LiteralError};
pub use expression::{ConstExpressionError, ExpressionError}; pub use expression::{ConstExpressionError, ExpressionError};
pub use function::{CallError, FunctionError, LocalVariableError, SubgroupError}; pub use function::{CallError, FunctionError, LocalVariableError, SubgroupError};
pub use interface::{EntryPointError, GlobalVariableError, VaryingError}; pub use interface::{EntryPointError, GlobalVariableError, VaryingError};
pub use r#type::{Disalignment, PushConstantError, TypeError, TypeFlags, WidthError}; pub use r#type::{Disalignment, ImmediateError, TypeError, TypeFlags, WidthError};
use self::handles::InvalidHandleError; use self::handles::InvalidHandleError;
@ -84,10 +84,10 @@ bitflags::bitflags! {
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Capabilities: u32 { pub struct Capabilities: u32 {
/// Support for [`AddressSpace::PushConstant`][1]. /// Support for [`AddressSpace::Immediate`][1].
/// ///
/// [1]: crate::AddressSpace::PushConstant /// [1]: crate::AddressSpace::Immediate
const PUSH_CONSTANT = 1 << 0; const IMMEDIATES = 1 << 0;
/// Float values with width = 8. /// Float values with width = 8.
const FLOAT64 = 1 << 1; const FLOAT64 = 1 << 1;
/// Support for [`BuiltIn::PrimitiveIndex`][1]. /// Support for [`BuiltIn::PrimitiveIndex`][1].

View File

@ -173,14 +173,14 @@ pub enum WidthError {
#[derive(Clone, Debug, thiserror::Error)] #[derive(Clone, Debug, thiserror::Error)]
#[cfg_attr(test, derive(PartialEq))] #[cfg_attr(test, derive(PartialEq))]
pub enum PushConstantError { pub enum ImmediateError {
#[error("The scalar type {0:?} is not supported in push constants")] #[error("The scalar type {0:?} is not supported in immediates")]
InvalidScalar(crate::Scalar), InvalidScalar(crate::Scalar),
} }
// Only makes sense if `flags.contains(HOST_SHAREABLE)` // Only makes sense if `flags.contains(HOST_SHAREABLE)`
type LayoutCompatibility = Result<Alignment, (Handle<crate::Type>, Disalignment)>; type LayoutCompatibility = Result<Alignment, (Handle<crate::Type>, Disalignment)>;
type PushConstantCompatibility = Result<(), PushConstantError>; type ImmediateCompatibility = Result<(), ImmediateError>;
fn check_member_layout( fn check_member_layout(
accum: &mut LayoutCompatibility, accum: &mut LayoutCompatibility,
@ -223,7 +223,7 @@ const fn ptr_space_argument_flag(space: crate::AddressSpace) -> TypeFlags {
As::Uniform As::Uniform
| As::Storage { .. } | As::Storage { .. }
| As::Handle | As::Handle
| As::PushConstant | As::Immediate
| As::WorkGroup | As::WorkGroup
| As::TaskPayload => TypeFlags::empty(), | As::TaskPayload => TypeFlags::empty(),
} }
@ -234,7 +234,7 @@ pub(super) struct TypeInfo {
pub flags: TypeFlags, pub flags: TypeFlags,
pub uniform_layout: LayoutCompatibility, pub uniform_layout: LayoutCompatibility,
pub storage_layout: LayoutCompatibility, pub storage_layout: LayoutCompatibility,
pub push_constant_compatibility: PushConstantCompatibility, pub immediates_compatibility: ImmediateCompatibility,
} }
impl TypeInfo { impl TypeInfo {
@ -243,7 +243,7 @@ impl TypeInfo {
flags: TypeFlags::empty(), flags: TypeFlags::empty(),
uniform_layout: Ok(Alignment::ONE), uniform_layout: Ok(Alignment::ONE),
storage_layout: Ok(Alignment::ONE), storage_layout: Ok(Alignment::ONE),
push_constant_compatibility: Ok(()), immediates_compatibility: Ok(()),
} }
} }
@ -252,7 +252,7 @@ impl TypeInfo {
flags, flags,
uniform_layout: Ok(alignment), uniform_layout: Ok(alignment),
storage_layout: Ok(alignment), storage_layout: Ok(alignment),
push_constant_compatibility: Ok(()), immediates_compatibility: Ok(()),
} }
} }
} }
@ -271,15 +271,15 @@ impl super::Validator {
/// If `scalar` is not a width allowed by the selected [`Capabilities`], /// If `scalar` is not a width allowed by the selected [`Capabilities`],
/// return an error explaining why. /// return an error explaining why.
/// ///
/// If `scalar` is allowed, return a [`PushConstantCompatibility`] result /// If `scalar` is allowed, return a [`ImmediateCompatibility`] result
/// that says whether `scalar` is allowed specifically in push constants. /// that says whether `scalar` is allowed specifically in immediates.
/// ///
/// [`Capabilities`]: crate::valid::Capabilities /// [`Capabilities`]: crate::valid::Capabilities
pub(super) const fn check_width( pub(super) const fn check_width(
&self, &self,
scalar: crate::Scalar, scalar: crate::Scalar,
) -> Result<PushConstantCompatibility, WidthError> { ) -> Result<ImmediateCompatibility, WidthError> {
let mut push_constant_compatibility = Ok(()); let mut immediates_compatibility = Ok(());
let good = match scalar.kind { let good = match scalar.kind {
crate::ScalarKind::Bool => scalar.width == crate::BOOL_WIDTH, crate::ScalarKind::Bool => scalar.width == crate::BOOL_WIDTH,
crate::ScalarKind::Float => match scalar.width { crate::ScalarKind::Float => match scalar.width {
@ -300,7 +300,7 @@ impl super::Validator {
}); });
} }
push_constant_compatibility = Err(PushConstantError::InvalidScalar(scalar)); immediates_compatibility = Err(ImmediateError::InvalidScalar(scalar));
true true
} }
@ -337,7 +337,7 @@ impl super::Validator {
} }
}; };
if good { if good {
Ok(push_constant_compatibility) Ok(immediates_compatibility)
} else { } else {
Err(WidthError::Invalid(scalar.kind, scalar.width)) Err(WidthError::Invalid(scalar.kind, scalar.width))
} }
@ -357,7 +357,7 @@ impl super::Validator {
use crate::TypeInner as Ti; use crate::TypeInner as Ti;
Ok(match gctx.types[handle].inner { Ok(match gctx.types[handle].inner {
Ti::Scalar(scalar) => { Ti::Scalar(scalar) => {
let push_constant_compatibility = self.check_width(scalar)?; let immediates_compatibility = self.check_width(scalar)?;
let shareable = if scalar.kind.is_numeric() { let shareable = if scalar.kind.is_numeric() {
TypeFlags::IO_SHAREABLE | TypeFlags::HOST_SHAREABLE TypeFlags::IO_SHAREABLE | TypeFlags::HOST_SHAREABLE
} else { } else {
@ -373,11 +373,11 @@ impl super::Validator {
| shareable, | shareable,
Alignment::from_width(scalar.width), Alignment::from_width(scalar.width),
); );
type_info.push_constant_compatibility = push_constant_compatibility; type_info.immediates_compatibility = immediates_compatibility;
type_info type_info
} }
Ti::Vector { size, scalar } => { Ti::Vector { size, scalar } => {
let push_constant_compatibility = self.check_width(scalar)?; let immediates_compatibility = self.check_width(scalar)?;
let shareable = if scalar.kind.is_numeric() { let shareable = if scalar.kind.is_numeric() {
TypeFlags::IO_SHAREABLE | TypeFlags::HOST_SHAREABLE TypeFlags::IO_SHAREABLE | TypeFlags::HOST_SHAREABLE
} else { } else {
@ -393,7 +393,7 @@ impl super::Validator {
| shareable, | shareable,
Alignment::from(size) * Alignment::from_width(scalar.width), Alignment::from(size) * Alignment::from_width(scalar.width),
); );
type_info.push_constant_compatibility = push_constant_compatibility; type_info.immediates_compatibility = immediates_compatibility;
type_info type_info
} }
Ti::Matrix { Ti::Matrix {
@ -404,7 +404,7 @@ impl super::Validator {
if scalar.kind != crate::ScalarKind::Float { if scalar.kind != crate::ScalarKind::Float {
return Err(TypeError::MatrixElementNotFloat); return Err(TypeError::MatrixElementNotFloat);
} }
let push_constant_compatibility = self.check_width(scalar)?; let immediates_compatibility = self.check_width(scalar)?;
let mut type_info = TypeInfo::new( let mut type_info = TypeInfo::new(
TypeFlags::DATA TypeFlags::DATA
| TypeFlags::SIZED | TypeFlags::SIZED
@ -415,7 +415,7 @@ impl super::Validator {
| TypeFlags::CREATION_RESOLVED, | TypeFlags::CREATION_RESOLVED,
Alignment::from(rows) * Alignment::from_width(scalar.width), Alignment::from(rows) * Alignment::from_width(scalar.width),
); );
type_info.push_constant_compatibility = push_constant_compatibility; type_info.immediates_compatibility = immediates_compatibility;
type_info type_info
} }
Ti::Atomic(scalar) => { Ti::Atomic(scalar) => {
@ -597,7 +597,7 @@ impl super::Validator {
flags: base_info.flags & type_info_mask, flags: base_info.flags & type_info_mask,
uniform_layout, uniform_layout,
storage_layout, storage_layout,
push_constant_compatibility: base_info.push_constant_compatibility.clone(), immediates_compatibility: base_info.immediates_compatibility.clone(),
} }
} }
Ti::Struct { ref members, span } => { Ti::Struct { ref members, span } => {
@ -678,9 +678,8 @@ impl super::Validator {
base_info.storage_layout, base_info.storage_layout,
handle, handle,
); );
if base_info.push_constant_compatibility.is_err() { if base_info.immediates_compatibility.is_err() {
ti.push_constant_compatibility = ti.immediates_compatibility = base_info.immediates_compatibility.clone();
base_info.push_constant_compatibility.clone();
} }
// Validate rule: If a structure member itself has a structure type S, // Validate rule: If a structure member itself has a structure type S,

View File

@ -4,7 +4,7 @@ targets = "SPIRV | HLSL | WGSL"
[hlsl] [hlsl]
shader_model = "V6_6" shader_model = "V6_6"
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -10,7 +10,7 @@ zero_initialize_workgroup_memory = true
[hlsl] [hlsl]
shader_model = "V6_6" shader_model = "V6_6"
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -4,7 +4,7 @@ targets = "SPIRV | HLSL | WGSL"
[hlsl] [hlsl]
shader_model = "V6_6" shader_model = "V6_6"
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -10,7 +10,7 @@ zero_initialize_workgroup_memory = true
[hlsl] [hlsl]
shader_model = "V6_6" shader_model = "V6_6"
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -8,7 +8,7 @@ zero_initialize_workgroup_memory = true
[hlsl] [hlsl]
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -8,7 +8,7 @@ spirv_cross_compatibility = false
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true
[msl.per_entry_point_map.main] [msl.per_entry_point_map.main]
push_constant_buffer = 1 immediates_buffer = 1
[spv] [spv]
version = [1, 2] version = [1, 2]

View File

@ -1,8 +1,8 @@
struct PushConstants { struct ImmediateData {
index: u32, index: u32,
double: vec2<f32>, double: vec2<f32>,
} }
var<push_constant> pc: PushConstants; var<immediate> im: ImmediateData;
struct FragmentIn { struct FragmentIn {
@location(0) color: vec4<f32>, @location(0) color: vec4<f32>,
@ -11,7 +11,7 @@ struct FragmentIn {
@fragment @fragment
fn main(in: FragmentIn) -> @location(0) vec4<f32> { fn main(in: FragmentIn) -> @location(0) vec4<f32> {
if in.primitive_index == pc.index { if in.primitive_index == im.index {
return in.color; return in.color;
} else { } else {
return vec4<f32>(vec3<f32>(1.0) - in.color.rgb, in.color.a); return vec4<f32>(vec3<f32>(1.0) - in.color.rgb, in.color.a);

View File

@ -8,7 +8,7 @@ version = [1, 0]
[hlsl] [hlsl]
shader_model = "V6_2" shader_model = "V6_2"
special_constants_binding = { space = 1, register = 0 } special_constants_binding = { space = 1, register = 0 }
push_constants_target = { space = 0, register = 0 } immediates_target = { space = 0, register = 0 }
lang_version = [1, 0] lang_version = [1, 0]
per_entry_point_map = {} per_entry_point_map = {}

View File

@ -10,7 +10,7 @@ zero_initialize_workgroup_memory = true
[hlsl] [hlsl]
shader_model = "V6_0" shader_model = "V6_0"
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -3,7 +3,7 @@ targets = "GLSL | HLSL"
[hlsl] [hlsl]
fake_missing_bindings = true fake_missing_bindings = true
push_constants_target = { register = 0, space = 0 } immediates_target = { register = 0, space = 0 }
restrict_indexing = true restrict_indexing = true
special_constants_binding = { register = 0, space = 1 } special_constants_binding = { register = 0, space = 1 }
zero_initialize_workgroup_memory = true zero_initialize_workgroup_memory = true

View File

@ -1,7 +1,7 @@
struct PushConstants { struct ImmediateData {
multiplier: f32 multiplier: f32
} }
var<push_constant> pc: PushConstants; var<immediate> im: ImmediateData;
struct FragmentIn { struct FragmentIn {
@location(0) color: vec4<f32> @location(0) color: vec4<f32>
@ -13,10 +13,10 @@ fn vert_main(
@builtin(instance_index) ii: u32, @builtin(instance_index) ii: u32,
@builtin(vertex_index) vi: u32, @builtin(vertex_index) vi: u32,
) -> @builtin(position) vec4<f32> { ) -> @builtin(position) vec4<f32> {
return vec4<f32>(f32(ii) * f32(vi) * pc.multiplier * pos, 0.0, 1.0); return vec4<f32>(f32(ii) * f32(vi) * im.multiplier * pos, 0.0, 1.0);
} }
@fragment @fragment
fn main(in: FragmentIn) -> @location(0) vec4<f32> { fn main(in: FragmentIn) -> @location(0) vec4<f32> {
return in.color * pc.multiplier; return in.color * im.multiplier;
} }

View File

@ -1325,22 +1325,22 @@ fn float16_capability_and_enable() {
} }
#[test] #[test]
fn float16_in_push_constant() { fn float16_in_immediate() {
check_validation! { check_validation! {
"enable f16; var<push_constant> input: f16;", "enable f16; var<immediate> input: f16;",
"enable f16; var<push_constant> input: vec2<f16>;", "enable f16; var<immediate> input: vec2<f16>;",
"enable f16; var<push_constant> input: mat4x4<f16>;", "enable f16; var<immediate> input: mat4x4<f16>;",
"enable f16; struct S { a: f16 }; var<push_constant> input: S;", "enable f16; struct S { a: f16 }; var<immediate> input: S;",
"enable f16; struct S1 { a: f16 }; struct S2 { a : S1 } var<push_constant> input: S2;": "enable f16; struct S1 { a: f16 }; struct S2 { a : S1 } var<immediate> input: S2;":
Err(naga::valid::ValidationError::GlobalVariable { Err(naga::valid::ValidationError::GlobalVariable {
source: naga::valid::GlobalVariableError::InvalidPushConstantType( source: naga::valid::GlobalVariableError::InvalidImmediateType(
naga::valid::PushConstantError::InvalidScalar( naga::valid::ImmediateError::InvalidScalar(
naga::Scalar::F16 naga::Scalar::F16
) )
), ),
.. ..
}), }),
naga::valid::Capabilities::SHADER_FLOAT16 | naga::valid::Capabilities::PUSH_CONSTANT naga::valid::Capabilities::SHADER_FLOAT16 | naga::valid::Capabilities::IMMEDIATES
} }
} }

View File

@ -3,20 +3,20 @@
precision highp float; precision highp float;
precision highp int; precision highp int;
struct PushConstants { struct ImmediateData {
float multiplier; float multiplier;
}; };
struct FragmentIn { struct FragmentIn {
vec4 color; vec4 color;
}; };
uniform PushConstants _push_constant_binding_fs; uniform ImmediateData _immediates_binding_fs;
layout(location = 0) smooth in vec4 _vs2fs_location0; layout(location = 0) smooth in vec4 _vs2fs_location0;
layout(location = 0) out vec4 _fs2p_location0; layout(location = 0) out vec4 _fs2p_location0;
void main() { void main() {
FragmentIn in_ = FragmentIn(_vs2fs_location0); FragmentIn in_ = FragmentIn(_vs2fs_location0);
float _e4 = _push_constant_binding_fs.multiplier; float _e4 = _immediates_binding_fs.multiplier;
_fs2p_location0 = (in_.color * _e4); _fs2p_location0 = (in_.color * _e4);
return; return;
} }

View File

@ -5,13 +5,13 @@ precision highp int;
uniform uint naga_vs_first_instance; uniform uint naga_vs_first_instance;
struct PushConstants { struct ImmediateData {
float multiplier; float multiplier;
}; };
struct FragmentIn { struct FragmentIn {
vec4 color; vec4 color;
}; };
uniform PushConstants _push_constant_binding_vs; uniform ImmediateData _immediates_binding_vs;
layout(location = 0) in vec2 _p2vs_location0; layout(location = 0) in vec2 _p2vs_location0;
@ -19,7 +19,7 @@ void main() {
vec2 pos = _p2vs_location0; vec2 pos = _p2vs_location0;
uint ii = (uint(gl_InstanceID) + naga_vs_first_instance); uint ii = (uint(gl_InstanceID) + naga_vs_first_instance);
uint vi = uint(gl_VertexID); uint vi = uint(gl_VertexID);
float _e8 = _push_constant_binding_vs.multiplier; float _e8 = _immediates_binding_vs.multiplier;
gl_Position = vec4((((float(ii) * float(vi)) * _e8) * pos), 0.0, 1.0); gl_Position = vec4((((float(ii) * float(vi)) * _e8) * pos), 0.0, 1.0);
return; return;
} }

View File

@ -5,7 +5,7 @@ struct NagaConstants {
}; };
ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1); ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1);
struct PushConstants { struct ImmediateData {
float multiplier; float multiplier;
}; };
@ -13,7 +13,7 @@ struct FragmentIn {
float4 color : LOC0; float4 color : LOC0;
}; };
ConstantBuffer<PushConstants> pc: register(b0); ConstantBuffer<ImmediateData> im: register(b0);
struct FragmentInput_main { struct FragmentInput_main {
float4 color : LOC0; float4 color : LOC0;
@ -21,13 +21,13 @@ struct FragmentInput_main {
float4 vert_main(float2 pos : LOC0, uint ii : SV_InstanceID, uint vi : SV_VertexID) : SV_Position float4 vert_main(float2 pos : LOC0, uint ii : SV_InstanceID, uint vi : SV_VertexID) : SV_Position
{ {
float _e8 = pc.multiplier; float _e8 = im.multiplier;
return float4((((float((_NagaConstants.first_instance + ii)) * float((_NagaConstants.first_vertex + vi))) * _e8) * pos), 0.0, 1.0); return float4((((float((_NagaConstants.first_instance + ii)) * float((_NagaConstants.first_vertex + vi))) * _e8) * pos), 0.0, 1.0);
} }
float4 main(FragmentInput_main fragmentinput_main) : SV_Target0 float4 main(FragmentInput_main fragmentinput_main) : SV_Target0
{ {
FragmentIn in_ = { fragmentinput_main.color }; FragmentIn in_ = { fragmentinput_main.color };
float _e4 = pc.multiplier; float _e4 = im.multiplier;
return (in_.color * _e4); return (in_.color * _e4);
} }

View File

@ -4,7 +4,7 @@
using metal::uint; using metal::uint;
struct PushConstants { struct ImmediateData {
uint index; uint index;
char _pad1[4]; char _pad1[4];
metal::float2 double_; metal::float2 double_;
@ -24,10 +24,10 @@ struct main_Output {
fragment main_Output main_( fragment main_Output main_(
main_Input varyings [[stage_in]] main_Input varyings [[stage_in]]
, uint primitive_index [[primitive_id]] , uint primitive_index [[primitive_id]]
, constant PushConstants& pc [[buffer(1)]] , constant ImmediateData& im [[buffer(1)]]
) { ) {
const FragmentIn in = { varyings.color, primitive_index }; const FragmentIn in = { varyings.color, primitive_index };
uint _e4 = pc.index; uint _e4 = im.index;
if (in.primitive_index == _e4) { if (in.primitive_index == _e4) {
return main_Output { in.color }; return main_Output { in.color };
} else { } else {

View File

@ -13,7 +13,7 @@ struct VertexOutput {
@group(0) @binding(0) @group(0) @binding(0)
var<uniform> global: Globals; var<uniform> global: Globals;
var<push_constant> global_1: VertexPushConstants; var<immediate> global_1: VertexPushConstants;
var<private> position_1: vec2<f32>; var<private> position_1: vec2<f32>;
var<private> color_1: vec4<f32>; var<private> color_1: vec4<f32>;
var<private> frag_color: vec4<f32>; var<private> frag_color: vec4<f32>;

View File

@ -1,4 +1,4 @@
struct PushConstants { struct ImmediateData {
index: u32, index: u32,
double: vec2<f32>, double: vec2<f32>,
} }
@ -8,11 +8,11 @@ struct FragmentIn {
@builtin(primitive_index) primitive_index: u32, @builtin(primitive_index) primitive_index: u32,
} }
var<push_constant> pc: PushConstants; var<immediate> im: ImmediateData;
@fragment @fragment
fn main(in: FragmentIn) -> @location(0) vec4<f32> { fn main(in: FragmentIn) -> @location(0) vec4<f32> {
let _e4 = pc.index; let _e4 = im.index;
if (in.primitive_index == _e4) { if (in.primitive_index == _e4) {
return in.color; return in.color;
} else { } else {

View File

@ -202,7 +202,7 @@ impl Player {
let resolved_desc = wgc::binding_model::ResolvedPipelineLayoutDescriptor { let resolved_desc = wgc::binding_model::ResolvedPipelineLayoutDescriptor {
label: desc.label.clone(), label: desc.label.clone(),
bind_group_layouts: Cow::from(&bind_group_layouts), bind_group_layouts: Cow::from(&bind_group_layouts),
push_constant_ranges: Cow::Borrowed(&*desc.push_constant_ranges), immediates_ranges: Cow::Borrowed(&*desc.immediates_ranges),
}; };
let pipeline_layout = device let pipeline_layout = device
@ -913,7 +913,7 @@ impl Player {
error, error,
commands, commands,
dynamic_offsets, dynamic_offsets,
push_constant_data, immediates_data,
string_data, string_data,
} = pass; } = pass;
@ -925,7 +925,7 @@ impl Player {
.map(|cmd| self.resolve_compute_command(cmd)) .map(|cmd| self.resolve_compute_command(cmd))
.collect(), .collect(),
dynamic_offsets, dynamic_offsets,
push_constant_data, immediates_data,
string_data, string_data,
} }
} }
@ -939,7 +939,7 @@ impl Player {
error, error,
commands, commands,
dynamic_offsets, dynamic_offsets,
push_constant_data, immediates_data,
string_data, string_data,
} = pass; } = pass;
@ -951,7 +951,7 @@ impl Player {
.map(|cmd| self.resolve_render_command(cmd)) .map(|cmd| self.resolve_render_command(cmd))
.collect(), .collect(),
dynamic_offsets, dynamic_offsets,
push_constant_data, immediates_data,
string_data, string_data,
} }
} }
@ -972,11 +972,11 @@ impl Player {
bind_group: bind_group.map(|bg| self.resolve_bind_group_id(bg)), bind_group: bind_group.map(|bg| self.resolve_bind_group_id(bg)),
}, },
C::SetPipeline(id) => C::SetPipeline(self.resolve_compute_pipeline_id(id)), C::SetPipeline(id) => C::SetPipeline(self.resolve_compute_pipeline_id(id)),
C::SetPushConstant { C::SetImmediate {
offset, offset,
size_bytes, size_bytes,
values_offset, values_offset,
} => C::SetPushConstant { } => C::SetImmediate {
offset, offset,
size_bytes, size_bytes,
values_offset, values_offset,
@ -1057,12 +1057,12 @@ impl Player {
depth_max, depth_max,
}, },
C::SetScissor(rect) => C::SetScissor(rect), C::SetScissor(rect) => C::SetScissor(rect),
C::SetPushConstant { C::SetImmediate {
stages, stages,
offset, offset,
size_bytes, size_bytes,
values_offset, values_offset,
} => C::SetPushConstant { } => C::SetImmediate {
stages, stages,
offset, offset,
size_bytes, size_bytes,

View File

@ -39,7 +39,7 @@
bind_group_layouts: [ bind_group_layouts: [
PointerId(0x10), PointerId(0x10),
], ],
push_constant_ranges: [], immediates_ranges: [],
)), )),
CreateShaderModule( CreateShaderModule(
id: PointerId(0x10), id: PointerId(0x10),
@ -76,7 +76,7 @@
], ],
dynamic_offsets: [], dynamic_offsets: [],
string_data: [], string_data: [],
push_constant_data: [], immediates_data: [],
), ),
), ),
]), ]),

View File

@ -12,7 +12,7 @@
CreatePipelineLayout(PointerId(0x10), ( CreatePipelineLayout(PointerId(0x10), (
label: Some("empty"), label: Some("empty"),
bind_group_layouts: [], bind_group_layouts: [],
push_constant_ranges: [], immediates_ranges: [],
)), )),
CreateShaderModule( CreateShaderModule(
id: PointerId(0x10), id: PointerId(0x10),
@ -67,7 +67,7 @@
], ],
dynamic_offsets: [], dynamic_offsets: [],
string_data: [], string_data: [],
push_constant_data: [], immediates_data: [],
), ),
), ),
ResolveQuerySet( ResolveQuerySet(

View File

@ -47,7 +47,7 @@
CreatePipelineLayout(PointerId(0x10), ( CreatePipelineLayout(PointerId(0x10), (
label: None, label: None,
bind_group_layouts: [], bind_group_layouts: [],
push_constant_ranges: [], immediates_ranges: [],
)), )),
CreateGeneralRenderPipeline( CreateGeneralRenderPipeline(
id: PointerId(0x10), id: PointerId(0x10),
@ -96,7 +96,7 @@
], ],
dynamic_offsets: [], dynamic_offsets: [],
string_data: [], string_data: [],
push_constant_data: [], immediates_data: [],
), ),
color_attachments: [ color_attachments: [
Some(( Some((

View File

@ -124,7 +124,7 @@
bind_group_layouts: [ bind_group_layouts: [
PointerId(0x10), PointerId(0x10),
], ],
push_constant_ranges: [], immediates_ranges: [],
)), )),
CreateComputePipeline( CreateComputePipeline(
id: PointerId(0x10), id: PointerId(0x10),
@ -155,7 +155,7 @@
], ],
dynamic_offsets: [], dynamic_offsets: [],
string_data: [], string_data: [],
push_constant_data: [], immediates_data: [],
), ),
) )
]), ]),

View File

@ -117,7 +117,7 @@
bind_group_layouts: [ bind_group_layouts: [
PointerId(0x10), PointerId(0x10),
], ],
push_constant_ranges: [], immediates_ranges: [],
)), )),
CreateShaderModule( CreateShaderModule(
id: PointerId(0x10), id: PointerId(0x10),
@ -156,7 +156,7 @@
], ],
dynamic_offsets: [], dynamic_offsets: [],
string_data: [], string_data: [],
push_constant_data: [], immediates_data: [],
), ),
), ),
CopyTextureToBuffer( CopyTextureToBuffer(

View File

@ -44,7 +44,7 @@
commands: [], commands: [],
dynamic_offsets: [], dynamic_offsets: [],
string_data: [], string_data: [],
push_constant_data: [], immediates_data: [],
), ),
color_attachments: [ color_attachments: [
Some(( Some((

View File

@ -347,7 +347,7 @@ fn copy_via_compute(
let pll = device.create_pipeline_layout(&PipelineLayoutDescriptor { let pll = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let source = String::from(include_str!("copy_texture_to_buffer.wgsl")); let source = String::from(include_str!("copy_texture_to_buffer.wgsl"));

View File

@ -89,7 +89,7 @@ static BGRA8_UNORM_STORAGE: GpuTestConfiguration = GpuTestConfiguration::new()
let pl = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pl = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { let module = device.create_shader_module(wgpu::ShaderModuleDescriptor {

View File

@ -81,7 +81,7 @@ async fn bgl_dedupe(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl_1b], bind_group_layouts: &[&bgl_1b],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let module = ctx let module = ctx
@ -145,7 +145,7 @@ fn bgl_dedupe_with_dropped_user_handle(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl_1], bind_group_layouts: &[&bgl_1],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
// We drop bgl_1 here. As bgl_1 is still alive, referenced by the pipeline layout, // We drop bgl_1 here. As bgl_1 is still alive, referenced by the pipeline layout,

View File

@ -70,7 +70,7 @@ fn multiple_bindings_with_differing_sizes(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"), label: Some("pipeline_layout"),
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipelines = SHADER_SRC let pipelines = SHADER_SRC

View File

@ -224,7 +224,7 @@ async fn binding_array_buffers(
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"), label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -179,7 +179,7 @@ async fn binding_array_sampled_textures(ctx: TestingContext, partially_bound: bo
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"), label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -212,7 +212,7 @@ async fn binding_array_samplers(ctx: TestingContext, partially_bound: bool) {
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"), label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -172,7 +172,7 @@ async fn binding_array_storage_textures(ctx: TestingContext, partially_bound: bo
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"), label: Some("Pipeline Layout"),
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -233,7 +233,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_LAYOUT: GpuTestConfiguration = GpuTestConfigu
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
wgpu_test::fail( wgpu_test::fail(
@ -307,7 +307,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_DISPATCH: GpuTestConfiguration = GpuTestConfi
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -323,7 +323,7 @@ fn resource_setup(ctx: &TestingContext) -> ResourceSetup {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"), label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -138,7 +138,7 @@ async fn request_device_error_message() {
max_texture_dimension_2d: u32::MAX, max_texture_dimension_2d: u32::MAX,
max_texture_dimension_3d: u32::MAX, max_texture_dimension_3d: u32::MAX,
max_bind_groups: u32::MAX, max_bind_groups: u32::MAX,
max_push_constant_size: u32::MAX, max_immediate_size: u32::MAX,
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
@ -432,7 +432,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&invalid_bind_group_layout], bind_group_layouts: &[&invalid_bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let _ = ctx let _ = ctx

View File

@ -16,12 +16,12 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
static NUM_WORKGROUPS_BUILTIN: GpuTestConfiguration = GpuTestConfiguration::new() static NUM_WORKGROUPS_BUILTIN: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS) .features(wgpu::Features::IMMEDIATES)
.downlevel_flags( .downlevel_flags(
wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION, wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION,
) )
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_push_constant_size: 4, max_immediate_size: 4,
..wgpu::Limits::downlevel_defaults() ..wgpu::Limits::downlevel_defaults()
}), }),
) )
@ -36,13 +36,13 @@ static NUM_WORKGROUPS_BUILTIN: GpuTestConfiguration = GpuTestConfiguration::new(
static DISCARD_DISPATCH: GpuTestConfiguration = GpuTestConfiguration::new() static DISCARD_DISPATCH: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS) .features(wgpu::Features::IMMEDIATES)
.downlevel_flags( .downlevel_flags(
wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION, wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION,
) )
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_compute_workgroups_per_dimension: 10, max_compute_workgroups_per_dimension: 10,
max_push_constant_size: 4, max_immediate_size: 4,
..wgpu::Limits::downlevel_defaults() ..wgpu::Limits::downlevel_defaults()
}), }),
) )
@ -67,12 +67,12 @@ static DISCARD_DISPATCH: GpuTestConfiguration = GpuTestConfiguration::new()
static RESET_BIND_GROUPS: GpuTestConfiguration = GpuTestConfiguration::new() static RESET_BIND_GROUPS: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS) .features(wgpu::Features::IMMEDIATES)
.downlevel_flags( .downlevel_flags(
wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION, wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION,
) )
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_push_constant_size: 4, max_immediate_size: 4,
..wgpu::Limits::downlevel_defaults() ..wgpu::Limits::downlevel_defaults()
}).enable_noop(), }).enable_noop(),
) )
@ -92,7 +92,7 @@ static RESET_BIND_GROUPS: GpuTestConfiguration = GpuTestConfiguration::new()
{ {
let mut compute_pass = encoder.begin_compute_pass(&Default::default()); let mut compute_pass = encoder.begin_compute_pass(&Default::default());
compute_pass.set_pipeline(&test_resources.pipeline); compute_pass.set_pipeline(&test_resources.pipeline);
compute_pass.set_push_constants(0, &[0, 0, 0, 0]); compute_pass.set_immediates(0, &[0, 0, 0, 0]);
// compute_pass.set_bind_group(0, &test_resources.bind_group, &[]); // compute_pass.set_bind_group(0, &test_resources.bind_group, &[]);
compute_pass.dispatch_workgroups_indirect(&indirect_buffer, 0); compute_pass.dispatch_workgroups_indirect(&indirect_buffer, 0);
} }
@ -109,12 +109,12 @@ static RESET_BIND_GROUPS: GpuTestConfiguration = GpuTestConfiguration::new()
static ZERO_SIZED_BUFFER: GpuTestConfiguration = GpuTestConfiguration::new() static ZERO_SIZED_BUFFER: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS) .features(wgpu::Features::IMMEDIATES)
.downlevel_flags( .downlevel_flags(
wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION, wgpu::DownlevelFlags::COMPUTE_SHADERS | wgpu::DownlevelFlags::INDIRECT_EXECUTION,
) )
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_push_constant_size: 4, max_immediate_size: 4,
..wgpu::Limits::downlevel_defaults() ..wgpu::Limits::downlevel_defaults()
}) })
.enable_noop(), .enable_noop(),
@ -135,7 +135,7 @@ static ZERO_SIZED_BUFFER: GpuTestConfiguration = GpuTestConfiguration::new()
{ {
let mut compute_pass = encoder.begin_compute_pass(&Default::default()); let mut compute_pass = encoder.begin_compute_pass(&Default::default());
compute_pass.set_pipeline(&test_resources.pipeline); compute_pass.set_pipeline(&test_resources.pipeline);
compute_pass.set_push_constants(0, &[0, 0, 0, 0]); compute_pass.set_immediates(0, &[0, 0, 0, 0]);
compute_pass.set_bind_group(0, &test_resources.bind_group, &[]); compute_pass.set_bind_group(0, &test_resources.bind_group, &[]);
compute_pass.dispatch_workgroups_indirect(&indirect_buffer, 0); compute_pass.dispatch_workgroups_indirect(&indirect_buffer, 0);
} }
@ -163,8 +163,8 @@ impl TestResources {
inner: u32, inner: u32,
} }
// `test_offset.inner` should always be 0; we test that resetting the push constant set by the validation code works properly. // `test_offset.inner` should always be 0; we test that resetting the immediate data set by the validation code works properly.
var<push_constant> test_offset: TestOffsetPc; var<immediate> test_offset: TestOffsetPc;
@group(0) @binding(0) @group(0) @binding(0)
var<storage, read_write> out: array<u32, 3>; var<storage, read_write> out: array<u32, 3>;
@ -207,7 +207,7 @@ impl TestResources {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[wgpu::PushConstantRange { immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::COMPUTE, stages: wgpu::ShaderStages::COMPUTE,
range: 0..4, range: 0..4,
}], }],
@ -292,7 +292,7 @@ async fn run_test(ctx: &TestingContext, num_workgroups: &[u32; 3]) -> [u32; 3] {
{ {
let mut compute_pass = encoder.begin_compute_pass(&Default::default()); let mut compute_pass = encoder.begin_compute_pass(&Default::default());
compute_pass.set_pipeline(&test_resources.pipeline); compute_pass.set_pipeline(&test_resources.pipeline);
compute_pass.set_push_constants(0, &[0, 0, 0, 0]); compute_pass.set_immediates(0, &[0, 0, 0, 0]);
compute_pass.set_bind_group(0, &test_resources.bind_group, &[]); compute_pass.set_bind_group(0, &test_resources.bind_group, &[]);
compute_pass.dispatch_workgroups_indirect(&indirect_buffer, indirect_offset); compute_pass.dispatch_workgroups_indirect(&indirect_buffer, indirect_offset);
} }

View File

@ -101,7 +101,7 @@ async fn test_format(
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let shader = ctx.device.create_shader_module(desc); let shader = ctx.device.create_shader_module(desc);
let pipeline = ctx let pipeline = ctx

View File

@ -11,7 +11,7 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
vec.extend([PARTIAL_UPDATE, RENDER_PASS_TEST]); vec.extend([PARTIAL_UPDATE, RENDER_PASS_TEST]);
} }
/// We want to test that partial updates to push constants work as expected. /// We want to test that partial updates to immediates work as expected.
/// ///
/// As such, we dispatch two compute passes, one which writes the values /// As such, we dispatch two compute passes, one which writes the values
/// before a partial update, and one which writes the values after the partial update. /// before a partial update, and one which writes the values after the partial update.
@ -22,9 +22,9 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
static PARTIAL_UPDATE: GpuTestConfiguration = GpuTestConfiguration::new() static PARTIAL_UPDATE: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS) .features(wgpu::Features::IMMEDIATES)
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_push_constant_size: 32, max_immediate_size: 32,
..Default::default() ..Default::default()
}), }),
) )
@ -36,7 +36,7 @@ const SHADER: &str = r#"
vector: vec4f, vector: vec4f,
} }
var<push_constant> pc: Pc; var<immediate> pc: Pc;
@group(0) @binding(0) @group(0) @binding(0)
var<storage, read_write> output: array<vec4f>; var<storage, read_write> output: array<vec4f>;
@ -99,7 +99,7 @@ async fn partial_update_test(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"), label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[wgpu::PushConstantRange { immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::COMPUTE, stages: wgpu::ShaderStages::COMPUTE,
range: 0..32, range: 0..32,
}], }],
@ -133,17 +133,17 @@ async fn partial_update_test(ctx: TestingContext) {
// -- Dispatch 0 -- // -- Dispatch 0 --
// Dispatch number // Dispatch number
cpass.set_push_constants(0, bytemuck::bytes_of(&[0_u32])); cpass.set_immediates(0, bytemuck::bytes_of(&[0_u32]));
// Update the whole vector. // Update the whole vector.
cpass.set_push_constants(16, bytemuck::bytes_of(&[1.0_f32, 2.0, 3.0, 4.0])); cpass.set_immediates(16, bytemuck::bytes_of(&[1.0_f32, 2.0, 3.0, 4.0]));
cpass.dispatch_workgroups(1, 1, 1); cpass.dispatch_workgroups(1, 1, 1);
// -- Dispatch 1 -- // -- Dispatch 1 --
// Dispatch number // Dispatch number
cpass.set_push_constants(0, bytemuck::bytes_of(&[1_u32])); cpass.set_immediates(0, bytemuck::bytes_of(&[1_u32]));
// Update just the y component of the vector. // Update just the y component of the vector.
cpass.set_push_constants(20, bytemuck::bytes_of(&[5.0_f32])); cpass.set_immediates(20, bytemuck::bytes_of(&[5.0_f32]));
cpass.dispatch_workgroups(1, 1, 1); cpass.dispatch_workgroups(1, 1, 1);
} }
@ -166,9 +166,9 @@ async fn partial_update_test(ctx: TestingContext) {
static RENDER_PASS_TEST: GpuTestConfiguration = GpuTestConfiguration::new() static RENDER_PASS_TEST: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(Features::PUSH_CONSTANTS | Features::VERTEX_WRITABLE_STORAGE) .features(Features::IMMEDIATES | Features::VERTEX_WRITABLE_STORAGE)
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_push_constant_size: 64, max_immediate_size: 64,
..Default::default() ..Default::default()
}), }),
) )
@ -178,19 +178,19 @@ static RENDER_PASS_TEST: GpuTestConfiguration = GpuTestConfiguration::new()
} }
}); });
// This shader simply moves the values from vector_constants and push_constants into the // This shader simply moves the values from vector_constants and immediates into the
// result buffer. It expects to be called 4 times (with vector_index in 0..4) with its // result buffer. It expects to be called 4 times (with vector_index in 0..4) with its
// topology being PointList, so that each vertex shader call leads to exactly one fragment // topology being PointList, so that each vertex shader call leads to exactly one fragment
// call. // call.
const SHADER2: &str = " const SHADER2: &str = "
const POSITION: vec4f = vec4f(0, 0, 0, 1); const POSITION: vec4f = vec4f(0, 0, 0, 1);
struct PushConstants { struct ImmediateData {
vertex_constants: vec4i, vertex_constants: vec4i,
fragment_constants: vec4i, fragment_constants: vec4i,
} }
var<push_constant> push_constants: PushConstants; var<immediate> immediates: ImmediateData;
@group(0) @binding(0) var<storage, read_write> result: array<i32>; @group(0) @binding(0) var<storage, read_write> result: array<i32>;
@ -202,14 +202,14 @@ const SHADER2: &str = "
@vertex fn vertex( @vertex fn vertex(
@builtin(vertex_index) ix: u32, @builtin(vertex_index) ix: u32,
) -> VertexOutput { ) -> VertexOutput {
result[ix] = push_constants.vertex_constants[ix]; result[ix] = immediates.vertex_constants[ix];
return VertexOutput(POSITION, ix); return VertexOutput(POSITION, ix);
} }
@fragment fn fragment( @fragment fn fragment(
@location(0) ix: u32, @location(0) ix: u32,
) -> @location(0) vec4f { ) -> @location(0) vec4f {
result[ix + 4u] = push_constants.fragment_constants[ix]; result[ix + 4u] = immediates.fragment_constants[ix];
return vec4f(); return vec4f();
} }
"; ";
@ -271,7 +271,7 @@ async fn render_pass_test(ctx: &TestingContext, use_render_bundle: bool) {
.device .device
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
bind_group_layouts: &[&bind_group_layout], bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[PushConstantRange { immediates_ranges: &[ImmediateRange {
stages: ShaderStages::VERTEX_FRAGMENT, stages: ShaderStages::VERTEX_FRAGMENT,
range: 0..8 * size_of::<u32>() as u32, range: 0..8 * size_of::<u32>() as u32,
}], }],
@ -338,7 +338,7 @@ async fn render_pass_test(ctx: &TestingContext, use_render_bundle: bool) {
) { ) {
let data_as_u8: &[u8] = bytemuck::cast_slice(data.as_slice()); let data_as_u8: &[u8] = bytemuck::cast_slice(data.as_slice());
encoder.set_pipeline(pipeline); encoder.set_pipeline(pipeline);
encoder.set_push_constants(ShaderStages::VERTEX_FRAGMENT, 0, data_as_u8); encoder.set_immediates(ShaderStages::VERTEX_FRAGMENT, 0, data_as_u8);
encoder.set_bind_group(0, Some(bind_group), &[]); encoder.set_bind_group(0, Some(bind_group), &[]);
encoder.draw(0..4, 0..1); encoder.draw(0..4, 0..1);
} }

View File

@ -32,6 +32,7 @@ mod external_image_copy;
mod external_texture; mod external_texture;
mod float32_filterable; mod float32_filterable;
mod image_atomics; mod image_atomics;
mod immediates;
mod instance; mod instance;
mod life_cycle; mod life_cycle;
mod mem_leaks; mod mem_leaks;
@ -44,7 +45,6 @@ mod pipeline;
mod pipeline_cache; mod pipeline_cache;
mod planar_texture; mod planar_texture;
mod poll; mod poll;
mod push_constants;
mod query_set; mod query_set;
mod queue_transfer; mod queue_transfer;
mod ray_tracing; mod ray_tracing;
@ -108,7 +108,7 @@ fn all_tests() -> Vec<wgpu_test::GpuTestInitializer> {
pipeline::all_tests(&mut tests); pipeline::all_tests(&mut tests);
planar_texture::all_tests(&mut tests); planar_texture::all_tests(&mut tests);
poll::all_tests(&mut tests); poll::all_tests(&mut tests);
push_constants::all_tests(&mut tests); immediates::all_tests(&mut tests);
query_set::all_tests(&mut tests); query_set::all_tests(&mut tests);
queue_transfer::all_tests(&mut tests); queue_transfer::all_tests(&mut tests);
ray_tracing::all_tests(&mut tests); ray_tracing::all_tests(&mut tests);

View File

@ -92,7 +92,7 @@ async fn draw_test_with_reports(
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let global_report = ctx.instance.generate_report().unwrap(); let global_report = ctx.instance.generate_report().unwrap();

View File

@ -211,7 +211,7 @@ fn mesh_pipeline_build(ctx: &TestingContext, info: MeshPipelineTestInfo) {
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor { let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None, label: None,
@ -299,7 +299,7 @@ fn mesh_draw(ctx: &TestingContext, draw_type: DrawType) {
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor { let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None, label: None,

View File

@ -178,7 +178,7 @@ impl TestResources {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx
@ -342,7 +342,7 @@ async fn d3d12_restrict_dynamic_buffers(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let pipeline = ctx let pipeline = ctx

View File

@ -98,7 +98,7 @@ async fn pipeline_cache_test(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"), label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let first_cache_data; let first_cache_data;

View File

@ -8,7 +8,7 @@ struct ShaderData {
@group(0) @binding(0) @group(0) @binding(0)
var<uniform> data1: ShaderData; var<uniform> data1: ShaderData;
var<push_constant> data2: ShaderData; var<immediate> data2: ShaderData;
struct FsIn { struct FsIn {
@builtin(position) position: vec4f, @builtin(position) position: vec4f,
@ -27,7 +27,7 @@ fn fs_main(fs_in: FsIn) -> @location(0) vec4f {
case 0u: { case 0u: {
return fs_in.data1; return fs_in.data1;
} }
// (1, 0) - push constant from the vertex shader // (1, 0) - immediate data from the vertex shader
case 1u: { case 1u: {
return fs_in.data2; return fs_in.data2;
} }
@ -35,7 +35,7 @@ fn fs_main(fs_in: FsIn) -> @location(0) vec4f {
case 2u: { case 2u: {
return vec4f(data1.a, data1.b, data1.c, data1.d); return vec4f(data1.a, data1.b, data1.c, data1.d);
} }
// (1, 1) - push constant from the fragment shader // (1, 1) - immediate data from the fragment shader
case 3u: { case 3u: {
return vec4f(data2.a, data2.b, data2.c, data2.d); return vec4f(data2.a, data2.b, data2.c, data2.d);
} }

View File

@ -12,8 +12,8 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
/// we will not properly bind uniform buffers to both the vertex and fragment /// we will not properly bind uniform buffers to both the vertex and fragment
/// shaders. This turned out to not reproduce at all with this test case. /// shaders. This turned out to not reproduce at all with this test case.
/// ///
/// However, it also caught issues with the push constant implementation, /// However, it also caught issues with the immediate data implementation,
/// making sure that it works correctly with different definitions for the push constant /// making sure that it works correctly with different definitions for the immediate data
/// block in vertex and fragment shaders. /// block in vertex and fragment shaders.
/// ///
/// This test needs to be able to run on GLES 3.0 /// This test needs to be able to run on GLES 3.0
@ -22,18 +22,18 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
/// data source. /// data source.
/// ///
/// top left: Vertex Shader / Uniform Buffer /// top left: Vertex Shader / Uniform Buffer
/// top right: Vertex Shader / Push Constant /// top right: Vertex Shader / Immediate data
/// bottom left: Fragment Shader / Uniform Buffer /// bottom left: Fragment Shader / Uniform Buffer
/// bottom right: Fragment Shader / Push Constant /// bottom right: Fragment Shader / Immediate data
/// ///
/// We then validate the data is correct from every position. /// We then validate the data is correct from every position.
#[gpu_test] #[gpu_test]
static MULTI_STAGE_DATA_BINDING: GpuTestConfiguration = GpuTestConfiguration::new() static MULTI_STAGE_DATA_BINDING: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS) .features(wgpu::Features::IMMEDIATES)
.limits(wgpu::Limits { .limits(wgpu::Limits {
max_push_constant_size: 16, max_immediate_size: 16,
..Default::default() ..Default::default()
}), }),
) )
@ -41,7 +41,7 @@ static MULTI_STAGE_DATA_BINDING: GpuTestConfiguration = GpuTestConfiguration::ne
async fn multi_stage_data_binding_test(ctx: TestingContext) { async fn multi_stage_data_binding_test(ctx: TestingContext) {
// We use different shader modules to allow us to use different // We use different shader modules to allow us to use different
// types for the uniform and push constant blocks between stages. // types for the uniform and immediate data blocks between stages.
let vs_sm = ctx let vs_sm = ctx
.device .device
.create_shader_module(wgpu::include_wgsl!("issue_3349.vs.wgsl")); .create_shader_module(wgpu::include_wgsl!("issue_3349.vs.wgsl"));
@ -93,7 +93,7 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pll"), label: Some("pll"),
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[wgpu::PushConstantRange { immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::VERTEX_FRAGMENT, stages: wgpu::ShaderStages::VERTEX_FRAGMENT,
range: 0..16, range: 0..16,
}], }],
@ -171,7 +171,7 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) {
rpass.set_pipeline(&pipeline); rpass.set_pipeline(&pipeline);
rpass.set_bind_group(0, &bg, &[]); rpass.set_bind_group(0, &bg, &[]);
rpass.set_push_constants( rpass.set_immediates(
wgpu::ShaderStages::VERTEX_FRAGMENT, wgpu::ShaderStages::VERTEX_FRAGMENT,
0, 0,
bytemuck::cast_slice(&input), bytemuck::cast_slice(&input),

View File

@ -6,7 +6,7 @@ struct Pc {
inner: vec4f, inner: vec4f,
} }
var<push_constant> data2: Pc; var<immediate> data2: Pc;
struct VsOut { struct VsOut {
@builtin(position) position: vec4f, @builtin(position) position: vec4f,

View File

@ -46,7 +46,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration = GpuTestConfiguration::ne
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"), label: Some("Pipeline Layout"),
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let double_pipeline = ctx let double_pipeline = ctx

View File

@ -26,7 +26,7 @@ static ALLOW_INPUT_NOT_CONSUMED: GpuTestConfiguration = GpuTestConfiguration::ne
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("Pipeline Layout"), label: Some("Pipeline Layout"),
bind_group_layouts: &[], bind_group_layouts: &[],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let _ = ctx let _ = ctx

View File

@ -464,7 +464,7 @@ fn resource_setup(ctx: &TestingContext) -> ResourceSetup {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"), label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let target_size = wgpu::Extent3d { let target_size = wgpu::Extent3d {

View File

@ -335,7 +335,7 @@ fn sampler_bind_group(ctx: TestingContext, group_type: GroupType) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"), label: Some("pipeline_layout"),
bind_group_layouts: &bgl_references, bind_group_layouts: &bgl_references,
push_constant_ranges: &[], immediates_ranges: &[],
}); });
let input_image = ctx.device.create_texture(&wgpu::TextureDescriptor { let input_image = ctx.device.create_texture(&wgpu::TextureDescriptor {

View File

@ -9,7 +9,7 @@ use std::{borrow::Cow, fmt::Debug};
use wgpu::{ use wgpu::{
Backends, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, Backends, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry,
BindingType, BufferDescriptor, BufferUsages, CommandEncoderDescriptor, ComputePassDescriptor, BindingType, BufferDescriptor, BufferUsages, CommandEncoderDescriptor, ComputePassDescriptor,
ComputePipelineDescriptor, MapMode, PipelineLayoutDescriptor, PollType, PushConstantRange, ComputePipelineDescriptor, ImmediateRange, MapMode, PipelineLayoutDescriptor, PollType,
ShaderModuleDescriptor, ShaderSource, ShaderStages, ShaderModuleDescriptor, ShaderSource, ShaderStages,
}; };
@ -37,7 +37,7 @@ pub fn all_tests(tests: &mut Vec<GpuTestInitializer>) {
enum InputStorageType { enum InputStorageType {
Uniform, Uniform,
Storage, Storage,
PushConstant, Immediate,
} }
impl InputStorageType { impl InputStorageType {
@ -45,7 +45,7 @@ impl InputStorageType {
match self { match self {
InputStorageType::Uniform => "uniform", InputStorageType::Uniform => "uniform",
InputStorageType::Storage => "storage", InputStorageType::Storage => "storage",
InputStorageType::PushConstant => "push_constant", InputStorageType::Immediate => "immediate",
} }
} }
} }
@ -213,11 +213,11 @@ async fn shader_input_output_test(
binding: 0, binding: 0,
visibility: ShaderStages::COMPUTE, visibility: ShaderStages::COMPUTE,
ty: BindingType::Buffer { ty: BindingType::Buffer {
// We don't use this buffer for push constants, but for simplicity // We don't use this buffer for immediates, but for simplicity
// we just use the storage buffer binding. // we just use the storage buffer binding.
ty: match storage_type { ty: match storage_type {
InputStorageType::Uniform => wgpu::BufferBindingType::Uniform, InputStorageType::Uniform => wgpu::BufferBindingType::Uniform,
InputStorageType::Storage | InputStorageType::PushConstant => { InputStorageType::Storage | InputStorageType::Immediate => {
wgpu::BufferBindingType::Storage { read_only: true } wgpu::BufferBindingType::Storage { read_only: true }
} }
}, },
@ -280,8 +280,8 @@ async fn shader_input_output_test(
.create_pipeline_layout(&PipelineLayoutDescriptor { .create_pipeline_layout(&PipelineLayoutDescriptor {
label: None, label: None,
bind_group_layouts: &[&bgl], bind_group_layouts: &[&bgl],
push_constant_ranges: match storage_type { immediates_ranges: match storage_type {
InputStorageType::PushConstant => &[PushConstantRange { InputStorageType::Immediate => &[ImmediateRange {
stages: ShaderStages::COMPUTE, stages: ShaderStages::COMPUTE,
range: 0..MAX_BUFFER_SIZE as u32, range: 0..MAX_BUFFER_SIZE as u32,
}], }],
@ -308,8 +308,8 @@ async fn shader_input_output_test(
.replace("{{input_members}}", &test.custom_struct_members) .replace("{{input_members}}", &test.custom_struct_members)
.replace("{{body}}", &test.body); .replace("{{body}}", &test.body);
// Add the bindings for all inputs besides push constants. // Add the bindings for all inputs besides immediates.
processed = if matches!(storage_type, InputStorageType::PushConstant) { processed = if matches!(storage_type, InputStorageType::Immediate) {
processed.replace("{{input_bindings}}", "") processed.replace("{{input_bindings}}", "")
} else { } else {
processed.replace("{{input_bindings}}", "@group(0) @binding(0)") processed.replace("{{input_bindings}}", "@group(0) @binding(0)")
@ -363,8 +363,8 @@ async fn shader_input_output_test(
cpass.set_pipeline(&pipeline); cpass.set_pipeline(&pipeline);
cpass.set_bind_group(0, &bg, &[]); cpass.set_bind_group(0, &bg, &[]);
if let InputStorageType::PushConstant = storage_type { if let InputStorageType::Immediate = storage_type {
cpass.set_push_constants(0, bytemuck::cast_slice(&test.input_values)) cpass.set_immediates(0, bytemuck::cast_slice(&test.input_values))
} }
cpass.dispatch_workgroups(1, 1, 1); cpass.dispatch_workgroups(1, 1, 1);

View File

@ -9,10 +9,10 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
vec.extend([ vec.extend([
UNIFORM_INPUT, UNIFORM_INPUT,
STORAGE_INPUT, STORAGE_INPUT,
PUSH_CONSTANT_INPUT, IMMEDIATES_INPUT,
UNIFORM_INPUT_INT64, UNIFORM_INPUT_INT64,
STORAGE_INPUT_INT64, STORAGE_INPUT_INT64,
PUSH_CONSTANT_INPUT_INT64, IMMEDIATES_INPUT_INT64,
UNIFORM_INPUT_F16, UNIFORM_INPUT_F16,
STORAGE_INPUT_F16, STORAGE_INPUT_F16,
]); ]);
@ -54,21 +54,21 @@ static STORAGE_INPUT: GpuTestConfiguration = GpuTestConfiguration::new()
}); });
#[gpu_test] #[gpu_test]
static PUSH_CONSTANT_INPUT: GpuTestConfiguration = GpuTestConfiguration::new() static IMMEDIATES_INPUT: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(Features::PUSH_CONSTANTS) .features(Features::IMMEDIATES)
.downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) .downlevel_flags(DownlevelFlags::COMPUTE_SHADERS)
.limits(Limits { .limits(Limits {
max_push_constant_size: MAX_BUFFER_SIZE as u32, max_immediate_size: MAX_BUFFER_SIZE as u32,
..Limits::downlevel_defaults() ..Limits::downlevel_defaults()
}), }),
) )
.run_async(|ctx| { .run_async(|ctx| {
shader_input_output_test( shader_input_output_test(
ctx, ctx,
InputStorageType::PushConstant, InputStorageType::Immediate,
create_struct_layout_tests(InputStorageType::PushConstant), create_struct_layout_tests(InputStorageType::Immediate),
) )
}); });
@ -352,20 +352,20 @@ static STORAGE_INPUT_INT64: GpuTestConfiguration = GpuTestConfiguration::new()
}); });
#[gpu_test] #[gpu_test]
static PUSH_CONSTANT_INPUT_INT64: GpuTestConfiguration = GpuTestConfiguration::new() static IMMEDIATES_INPUT_INT64: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters( .parameters(
TestParameters::default() TestParameters::default()
.features(Features::SHADER_INT64 | Features::PUSH_CONSTANTS) .features(Features::SHADER_INT64 | Features::IMMEDIATES)
.downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) .downlevel_flags(DownlevelFlags::COMPUTE_SHADERS)
.limits(Limits { .limits(Limits {
max_push_constant_size: MAX_BUFFER_SIZE as u32, max_immediate_size: MAX_BUFFER_SIZE as u32,
..Limits::downlevel_defaults() ..Limits::downlevel_defaults()
}), }),
) )
.run_async(|ctx| { .run_async(|ctx| {
shader_input_output_test( shader_input_output_test(
ctx, ctx,
InputStorageType::PushConstant, InputStorageType::Immediate,
create_64bit_struct_layout_tests(), create_64bit_struct_layout_tests(),
) )
}); });

Some files were not shown because too many files have changed in this diff Show More