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

View File

@ -151,7 +151,7 @@ impl RenderpassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let mut vertex_buffers = Vec::with_capacity(vertex_buffer_count as usize);
@ -287,7 +287,7 @@ impl RenderpassState {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bindless_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: crate::transform_label(descriptor.label.clone()),
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(

View File

@ -430,8 +430,8 @@ pub enum GPUFeatureName {
PartiallyBoundBindingArray,
#[webidl(rename = "multi-draw-indirect-count")]
MultiDrawIndirectCount,
#[webidl(rename = "push-constants")]
PushConstants,
#[webidl(rename = "immediate-data")]
ImmediateData,
#[webidl(rename = "address-mode-clamp-to-zero")]
AddressModeClampToZero,
#[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::PartiallyBoundBindingArray => Features::PARTIALLY_BOUND_BINDING_ARRAY,
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::AddressModeClampToBorder => Features::ADDRESS_MODE_CLAMP_TO_BORDER,
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) {
return_features.insert(MultiDrawIndirectCount);
}
if features.contains(wgpu_types::Features::PUSH_CONSTANTS) {
return_features.insert(PushConstants);
if features.contains(wgpu_types::Features::IMMEDIATES) {
return_features.insert(ImmediateData);
}
if features.contains(wgpu_types::Features::ADDRESS_MODE_CLAMP_TO_ZERO) {
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.
- `ray_cube_fragment` - Demonstrates using ray queries with a fragment shader.
- `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).
#### Compute

View File

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

View File

@ -107,7 +107,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("compute"),
bind_group_layouts: &[&compute_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
// create render pipeline with empty bind group layout
@ -116,7 +116,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("render"),
bind_group_layouts: &[],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[&global_bind_group_layout, &local_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let shader_triangle_and_lines =
@ -195,7 +195,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
// Create the texture

View File

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

View File

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

View File

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

View File

@ -112,7 +112,7 @@ impl MultiTargetRenderer {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&texture_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
@ -232,7 +232,7 @@ impl TargetRenderer {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&texture_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
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 {
@ -116,7 +116,7 @@ impl crate::framework::Example for Example {
fn required_limits() -> wgpu::Limits {
wgpu::Limits {
max_push_constant_size: 12,
max_immediate_size: 12,
..wgpu::Limits::default()
}
.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 {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[wgpu::PushConstantRange {
immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::FRAGMENT,
range: 0..12,
}],
@ -353,9 +353,9 @@ impl crate::framework::Example for Example {
rpass.set_pipeline(&self.pipeline);
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_push_constants(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, 0, &0.0_f32.to_ne_bytes());
rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 4, &cos.to_ne_bytes());
rpass.set_immediates(wgpu::ShaderStages::FRAGMENT, 8, &sin.to_ne_bytes());
rpass.set_vertex_buffer(0, self.vertex_buf.slice(..));
rpass.set_index_buffer(self.index_buf.slice(..), IndexFormat::Uint16);
rpass.draw_indexed(0..12, 0, 0..1);

View File

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

View File

@ -269,7 +269,7 @@ impl crate::framework::Example for Example {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline layout for shader.wgsl"),
bind_group_layouts: &[&bgl],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: Some("pipeline layout for blit.wgsl"),
bind_group_layouts: &[&blit_bgl],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,

View File

@ -466,7 +466,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("shadow"),
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: Some("main"),
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);

View File

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

View File

@ -48,7 +48,7 @@ impl crate::framework::Example for Example {
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,

View File

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

View File

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

View File

@ -162,7 +162,7 @@ impl WgpuContext {
label: None,
// (4)
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: Some("water"),
bind_group_layouts: &[&water_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let terrain_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("terrain"),
bind_group_layouts: &[&terrain_bind_group_layout],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
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,

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() {
if ep_info[handle].is_empty() {
@ -448,11 +448,11 @@ impl<W> Writer<'_, W> {
match global.space {
AddressSpace::WorkGroup => self.features.request(Features::COMPUTE_SHADER),
AddressSpace::Storage { .. } => self.features.request(Features::BUFFER_STORAGE),
AddressSpace::PushConstant => {
if push_constant_used {
return Err(Error::MultiplePushConstants);
AddressSpace::Immediate => {
if immediates_used {
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::Storage { .. }
| crate::AddressSpace::Handle
| crate::AddressSpace::PushConstant
| crate::AddressSpace::Immediate
| crate::AddressSpace::TaskPayload => false,
}
}
@ -376,8 +376,8 @@ pub struct ReflectionInfo {
pub uniforms: crate::FastHashMap<Handle<crate::GlobalVariable>, String>,
/// Mapping between names and attribute locations.
pub varying: crate::FastHashMap<String, VaryingLocation>,
/// List of push constant items in the shader.
pub push_constant_items: Vec<PushConstantItem>,
/// List of immediate data items in the shader.
pub immediates_items: Vec<ImmediateItem>,
/// Number of user-defined clip planes. Only applicable to vertex shaders.
pub clip_distance_count: u32,
}
@ -401,14 +401,14 @@ pub struct TextureMapping {
/// 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
/// 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
/// push constant block.
/// immediate data block.
#[derive(Debug, Clone)]
pub struct PushConstantItem {
pub struct ImmediateItem {
/// GL uniform name for the item. This name is the same as if you were
/// to access it directly from a GLSL shader.
///
@ -420,24 +420,24 @@ pub struct PushConstantItem {
/// value: f32,
/// }
///
/// struct PushConstant {
/// struct ImmediateData {
/// InnerStruct inner;
/// vec4 array[2];
/// }
///
/// uniform PushConstants _push_constant_binding_cs;
/// uniform ImmediateData _immediates_binding_cs;
/// ```
///
/// ```text
/// - _push_constant_binding_cs.inner.value
/// - _push_constant_binding_cs.array[0]
/// - _push_constant_binding_cs.array[1]
/// - _immediates_binding_cs.inner.value
/// - _immediates_binding_cs.array[0]
/// - _immediates_binding_cs.array[1]
/// ```
///
pub access_path: String,
/// Type of the uniform. This will only ever be a scalar, vector, or matrix.
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.
pub offset: u32,
@ -540,10 +540,10 @@ pub enum Error {
/// Contains the missing [`Features`].
#[error("The selected version doesn't support {0:?}")]
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.
#[error("Multiple push constants aren't supported")]
MultiplePushConstants,
#[error("Multiple immediates aren't supported")]
MultipleImmediateData,
/// The specified [`Version`] isn't supported.
#[error("The specified version isn't supported")]
VersionNotSupported,
@ -666,9 +666,9 @@ impl<'a, W: Write> Writer<'a, W> {
&keywords::RESERVED_KEYWORD_SET,
proc::CaseInsensitiveKeywordSet::empty(),
&[
"gl_", // all GL built-in variables
"_group", // all normal bindings
"_push_constant_binding_", // all push constant bindings
"gl_", // all GL built-in variables
"_group", // all normal bindings
"_immediates_binding_", // all immediate data bindings
],
&mut names,
);
@ -1292,7 +1292,7 @@ impl<'a, W: Write> Writer<'a, W> {
crate::AddressSpace::WorkGroup => {
self.write_simple_global(handle, global)?;
}
crate::AddressSpace::PushConstant => {
crate::AddressSpace::Immediate => {
self.write_simple_global(handle, global)?;
}
crate::AddressSpace::Uniform => {
@ -1338,7 +1338,7 @@ impl<'a, W: Write> Writer<'a, W> {
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);
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()
)
}
(&None, crate::AddressSpace::PushConstant) => {
format!("_push_constant_binding_{}", self.entry_point.stage.to_str())
(&None, crate::AddressSpace::Immediate) => {
format!("_immediates_binding_{}", self.entry_point.stage.to_str())
}
(&None, _) => self.names[&NameKey::GlobalVariable(handle)].clone(),
}
@ -1549,9 +1549,9 @@ impl<'a, W: Write> Writer<'a, W> {
br.binding,
self.entry_point.stage.to_str()
)?,
(&None, crate::AddressSpace::PushConstant) => write!(
(&None, crate::AddressSpace::Immediate) => write!(
self.out,
"_push_constant_binding_{}",
"_immediates_binding_{}",
self.entry_point.stage.to_str()
)?,
(&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() {
if info[handle].is_empty() {
continue;
@ -5047,19 +5047,19 @@ impl<'a, W: Write> Writer<'a, W> {
let name = self.reflection_names_globals[&handle].clone();
uniforms.insert(handle, name);
}
crate::AddressSpace::PushConstant => {
crate::AddressSpace::Immediate => {
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 push_constant_items = vec![];
let mut immediates_segments = Vec::new();
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.
//
// 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();
// 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.
self.collect_push_constant_items(
// We then recursively collect all the uniform fields of the immediate data.
self.collect_immediates_items(
ty,
&mut push_constant_segments,
&mut immediates_segments,
&layouter,
&mut 0,
&mut push_constant_items,
&mut immediates_items,
);
}
@ -5084,18 +5084,18 @@ impl<'a, W: Write> Writer<'a, W> {
texture_mapping,
uniforms,
varying: mem::take(&mut self.varying),
push_constant_items,
immediates_items,
clip_distance_count: self.clip_distance_count,
})
}
fn collect_push_constant_items(
fn collect_immediates_items(
&mut self,
ty: Handle<crate::Type>,
segments: &mut Vec<String>,
layouter: &proc::Layouter,
offset: &mut u32,
items: &mut Vec<PushConstantItem>,
items: &mut Vec<ImmediateItem>,
) {
// At this point in the recursion, `segments` contains the path
// needed to access `ty` from the root.
@ -5107,7 +5107,7 @@ impl<'a, W: Write> Writer<'a, W> {
TypeInner::Scalar { .. } | TypeInner::Vector { .. } | TypeInner::Matrix { .. } => {
// Build the full name, by combining all current segments.
let name: String = segments.iter().map(String::as_str).collect();
items.push(PushConstantItem {
items.push(ImmediateItem {
access_path: name,
offset: *offset,
ty,
@ -5117,13 +5117,13 @@ impl<'a, W: Write> Writer<'a, W> {
// Arrays are recursed into.
TypeInner::Array { base, size, .. } => {
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() {
// Add the array accessor and recurse.
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();
}
@ -5137,7 +5137,7 @@ impl<'a, W: Write> Writer<'a, W> {
".{}",
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();
}
@ -5286,7 +5286,7 @@ const fn glsl_storage_qualifier(space: crate::AddressSpace) -> Option<&'static s
As::Uniform => Some("uniform"),
As::Handle => Some("uniform"),
As::WorkGroup => Some("shared"),
As::PushConstant => Some("uniform"),
As::Immediate => Some("uniform"),
As::TaskPayload => unreachable!(),
}
}

View File

@ -177,15 +177,15 @@ use crate::{back, ir, proc};
///
/// The [`back::hlsl::Options`] structure provides `BindTarget`s for various
/// situations in which Naga may need to generate an HLSL global variable, like
/// [`binding_map`] for Naga global variables, or [`push_constants_target`] for
/// a module's sole [`PushConstant`] variable. See those fields' documentation
/// [`binding_map`] for Naga global variables, or [`immediates_target`] for
/// a module's sole [`Immediate`] variable. See those fields' documentation
/// for details.
///
/// [`Storage`]: crate::ir::AddressSpace::Storage
/// [`back::hlsl::Options`]: Options
/// [`binding_map`]: Options::binding_map
/// [`push_constants_target`]: Options::push_constants_target
/// [`PushConstant`]: crate::ir::AddressSpace::PushConstant
/// [`immediates_target`]: Options::immediates_target
/// [`Immediate`]: crate::ir::AddressSpace::Immediate
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[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.
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
/// series of [`D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS`], whose binding
/// 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
pub push_constants_target: Option<BindTarget>,
pub immediates_target: Option<BindTarget>,
/// HLSL binding information for the sampler heap and comparison sampler heap.
pub sampler_heap_target: SamplerHeapBindTargets,
@ -554,7 +554,7 @@ impl Default for Options {
special_constants_binding: None,
sampler_heap_target: SamplerHeapBindTargets::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(),
external_texture_binding_map: ExternalTextureBindingMap::default(),
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)?;
register
}
crate::AddressSpace::PushConstant => {
// The type of the push constants will be wrapped in `ConstantBuffer`
crate::AddressSpace::Immediate => {
// The type of the immediates will be wrapped in `ConstantBuffer`
write!(self.out, "ConstantBuffer<")?;
"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`
if global.space == crate::AddressSpace::PushConstant {
if global.space == crate::AddressSpace::Immediate {
self.write_global_type(module, global.ty)?;
// 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)];
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
if global.space == crate::AddressSpace::PushConstant {
if global.space == crate::AddressSpace::Immediate {
match module.types[global.ty].inner {
TypeInner::Struct { .. } => {}
_ => {
@ -1041,9 +1041,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
let target = self
.options
.push_constants_target
.immediates_target
.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)?;
if target.space != 0 {
write!(self.out, ", space{}", target.space)?;
@ -3085,7 +3085,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
crate::AddressSpace::Function
| crate::AddressSpace::Private
| crate::AddressSpace::WorkGroup
| crate::AddressSpace::PushConstant
| crate::AddressSpace::Immediate
| crate::AddressSpace::TaskPayload,
)
| None => true,

View File

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

View File

@ -594,7 +594,7 @@ impl crate::AddressSpace {
| Self::Storage { .. }
| Self::Private
| Self::WorkGroup
| Self::PushConstant
| Self::Immediate
| Self::Handle
| Self::TaskPayload => true,
Self::Function => false,
@ -613,7 +613,7 @@ impl crate::AddressSpace {
// These should always be read-write.
Self::Private | Self::WorkGroup => false,
// These translate to `constant` address space, no need for qualifiers.
Self::Uniform | Self::PushConstant => false,
Self::Uniform | Self::Immediate => false,
// Not applicable.
Self::Handle | Self::Function => false,
}
@ -622,7 +622,7 @@ impl crate::AddressSpace {
const fn to_msl_name(self) -> Option<&'static str> {
match self {
Self::Handle => None,
Self::Uniform | Self::PushConstant => Some("constant"),
Self::Uniform | Self::Immediate => Some("constant"),
Self::Storage { .. } => Some("device"),
Self::Private | Self::Function => Some("thread"),
Self::WorkGroup => Some("threadgroup"),
@ -6732,8 +6732,8 @@ template <typename A>
break;
}
}
crate::AddressSpace::PushConstant => {
if let Err(e) = options.resolve_push_constants(ep) {
crate::AddressSpace::Immediate => {
if let Err(e) = options.resolve_immediates(ep) {
ep_error = Some(e);
break;
}
@ -7164,7 +7164,7 @@ template <typename A>
// the resolves have already been checked for `!fake_missing_bindings` case
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,
_ => options
.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::Uniform => spirv::StorageClass::Uniform,
crate::AddressSpace::WorkGroup => spirv::StorageClass::Workgroup,
crate::AddressSpace::PushConstant => spirv::StorageClass::PushConstant,
crate::AddressSpace::Immediate => spirv::StorageClass::PushConstant,
crate::AddressSpace::TaskPayload => unreachable!(),
}
}
@ -98,7 +98,7 @@ pub fn global_needs_wrapper(ir_module: &crate::Module, var: &crate::GlobalVariab
match var.space {
crate::AddressSpace::Uniform
| crate::AddressSpace::Storage { .. }
| crate::AddressSpace::PushConstant => {}
| crate::AddressSpace::Immediate => {}
_ => return false,
};
match ir_module.types[var.ty].inner {

View File

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

View File

@ -555,7 +555,7 @@ impl Frontend {
TypeInner::Sampler { .. } => space = AddressSpace::Handle,
_ => {
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.
Some(Sc::Uniform) => Ec::Global(crate::AddressSpace::Uniform),
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)),
})
}

View File

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

View File

@ -356,21 +356,21 @@ pub enum AddressSpace {
/// Opaque handles, such as samplers and images.
Handle,
/// Push constants.
/// Immediate data.
///
/// A [`Module`] may contain at most one [`GlobalVariable`] in
/// 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.
///
/// `PushConstant` variables may not contain `f16` values, even if
/// `Immediate` variables may not contain `f16` values, even if
/// the [`SHADER_FLOAT16`] capability is enabled.
///
/// Backends generally place tight limits on the size of
/// `PushConstant` variables.
/// `Immediate` variables.
///
/// [`SHADER_FLOAT16`]: crate::valid::Capabilities::SHADER_FLOAT16
PushConstant,
Immediate,
/// Task shader to mesh shader payload
TaskPayload,
}

View File

@ -182,7 +182,7 @@ impl super::AddressSpace {
crate::AddressSpace::Uniform => Sa::LOAD,
crate::AddressSpace::Storage { access } => access,
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,
// when not using multiple payloads and matching the entry payload is checked.
crate::AddressSpace::TaskPayload => Sa::LOAD | Sa::STORE,

View File

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

View File

@ -4,7 +4,7 @@ use bit_set::BitSet;
use super::{
analyzer::{FunctionInfo, GlobalUse},
Capabilities, Disalignment, FunctionError, ModuleInfo, PushConstantError,
Capabilities, Disalignment, FunctionError, ImmediateError, ModuleInfo,
};
use crate::arena::{Handle, UniqueArena};
use crate::span::{AddSpan as _, MapErrWithSpan as _, SpanProvider as _, WithSpan};
@ -41,8 +41,8 @@ pub enum GlobalVariableError {
InitializerNotAllowed(crate::AddressSpace),
#[error("Storage address space doesn't support write-only access")]
StorageAddressSpaceWriteOnlyNotSupported,
#[error("Type is not valid for use as a push constant")]
InvalidPushConstantType(#[source] PushConstantError),
#[error("Type is not valid for use as a immediate data")]
InvalidImmediateType(#[source] ImmediateError),
#[error("Task payload must not be zero-sized")]
ZeroSizedTaskPayload,
}
@ -117,8 +117,8 @@ pub enum EntryPointError {
ForbiddenStageOperations,
#[error("Global variable {0:?} is used incorrectly as {1:?}")]
InvalidGlobalUsage(Handle<crate::GlobalVariable>, GlobalUse),
#[error("More than 1 push constant variable is used")]
MoreThanOnePushConstantUsed,
#[error("More than 1 immediate data variable is used")]
MoreThanOneImmediateUsed,
#[error("Bindings for {0:?} conflict with other resource")]
BindingCollision(Handle<crate::GlobalVariable>),
#[error("Argument {0} varying error")]
@ -740,14 +740,14 @@ impl super::Validator {
}
(TypeFlags::DATA | TypeFlags::SIZED, false)
}
crate::AddressSpace::PushConstant => {
if !self.capabilities.contains(Capabilities::PUSH_CONSTANT) {
crate::AddressSpace::Immediate => {
if !self.capabilities.contains(Capabilities::IMMEDIATES) {
return Err(GlobalVariableError::UnsupportedCapability(
Capabilities::PUSH_CONSTANT,
Capabilities::IMMEDIATES,
));
}
if let Err(ref err) = type_info.push_constant_compatibility {
return Err(GlobalVariableError::InvalidPushConstantType(err.clone()));
if let Err(ref err) = type_info.immediates_compatibility {
return Err(GlobalVariableError::InvalidImmediateType(err.clone()));
}
(
TypeFlags::DATA
@ -1031,16 +1031,16 @@ impl super::Validator {
}
{
let mut used_push_constants = module
let mut used_immediates = module
.global_variables
.iter()
.filter(|&(_, var)| var.space == crate::AddressSpace::PushConstant)
.filter(|&(_, var)| var.space == crate::AddressSpace::Immediate)
.map(|(handle, _)| handle)
.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.
if let Some(handle) = used_push_constants.nth(1) {
return Err(EntryPointError::MoreThanOnePushConstantUsed
if let Some(handle) = used_immediates.nth(1) {
return Err(EntryPointError::MoreThanOneImmediateUsed
.with_span_handle(handle, &module.global_variables));
}
}
@ -1094,7 +1094,7 @@ impl super::Validator {
GlobalUse::empty()
}
}
crate::AddressSpace::PushConstant => GlobalUse::READ,
crate::AddressSpace::Immediate => GlobalUse::READ,
};
if !allowed_usage.contains(usage) {
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 function::{CallError, FunctionError, LocalVariableError, SubgroupError};
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;
@ -84,10 +84,10 @@ bitflags::bitflags! {
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Capabilities: u32 {
/// Support for [`AddressSpace::PushConstant`][1].
/// Support for [`AddressSpace::Immediate`][1].
///
/// [1]: crate::AddressSpace::PushConstant
const PUSH_CONSTANT = 1 << 0;
/// [1]: crate::AddressSpace::Immediate
const IMMEDIATES = 1 << 0;
/// Float values with width = 8.
const FLOAT64 = 1 << 1;
/// Support for [`BuiltIn::PrimitiveIndex`][1].

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
struct PushConstants {
struct ImmediateData {
multiplier: f32
}
var<push_constant> pc: PushConstants;
var<immediate> im: ImmediateData;
struct FragmentIn {
@location(0) color: vec4<f32>
@ -13,10 +13,10 @@ fn vert_main(
@builtin(instance_index) ii: u32,
@builtin(vertex_index) vi: u32,
) -> @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
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]
fn float16_in_push_constant() {
fn float16_in_immediate() {
check_validation! {
"enable f16; var<push_constant> input: f16;",
"enable f16; var<push_constant> input: vec2<f16>;",
"enable f16; var<push_constant> input: mat4x4<f16>;",
"enable f16; struct S { a: f16 }; var<push_constant> input: S;",
"enable f16; struct S1 { a: f16 }; struct S2 { a : S1 } var<push_constant> input: S2;":
"enable f16; var<immediate> input: f16;",
"enable f16; var<immediate> input: vec2<f16>;",
"enable f16; var<immediate> input: mat4x4<f16>;",
"enable f16; struct S { a: f16 }; var<immediate> input: S;",
"enable f16; struct S1 { a: f16 }; struct S2 { a : S1 } var<immediate> input: S2;":
Err(naga::valid::ValidationError::GlobalVariable {
source: naga::valid::GlobalVariableError::InvalidPushConstantType(
naga::valid::PushConstantError::InvalidScalar(
source: naga::valid::GlobalVariableError::InvalidImmediateType(
naga::valid::ImmediateError::InvalidScalar(
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 int;
struct PushConstants {
struct ImmediateData {
float multiplier;
};
struct FragmentIn {
vec4 color;
};
uniform PushConstants _push_constant_binding_fs;
uniform ImmediateData _immediates_binding_fs;
layout(location = 0) smooth in vec4 _vs2fs_location0;
layout(location = 0) out vec4 _fs2p_location0;
void main() {
FragmentIn in_ = FragmentIn(_vs2fs_location0);
float _e4 = _push_constant_binding_fs.multiplier;
float _e4 = _immediates_binding_fs.multiplier;
_fs2p_location0 = (in_.color * _e4);
return;
}

View File

@ -5,13 +5,13 @@ precision highp int;
uniform uint naga_vs_first_instance;
struct PushConstants {
struct ImmediateData {
float multiplier;
};
struct FragmentIn {
vec4 color;
};
uniform PushConstants _push_constant_binding_vs;
uniform ImmediateData _immediates_binding_vs;
layout(location = 0) in vec2 _p2vs_location0;
@ -19,7 +19,7 @@ void main() {
vec2 pos = _p2vs_location0;
uint ii = (uint(gl_InstanceID) + naga_vs_first_instance);
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);
return;
}

View File

@ -5,7 +5,7 @@ struct NagaConstants {
};
ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1);
struct PushConstants {
struct ImmediateData {
float multiplier;
};
@ -13,7 +13,7 @@ struct FragmentIn {
float4 color : LOC0;
};
ConstantBuffer<PushConstants> pc: register(b0);
ConstantBuffer<ImmediateData> im: register(b0);
struct FragmentInput_main {
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
{
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);
}
float4 main(FragmentInput_main fragmentinput_main) : SV_Target0
{
FragmentIn in_ = { fragmentinput_main.color };
float _e4 = pc.multiplier;
float _e4 = im.multiplier;
return (in_.color * _e4);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -347,7 +347,7 @@ fn copy_via_compute(
let pll = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&bgl],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[&bgl],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[&bgl_1b],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let module = ctx
@ -145,7 +145,7 @@ fn bgl_dedupe_with_dropped_user_handle(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
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,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
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
/// 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()
.parameters(
TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS)
.features(wgpu::Features::IMMEDIATES)
.limits(wgpu::Limits {
max_push_constant_size: 32,
max_immediate_size: 32,
..Default::default()
}),
)
@ -36,7 +36,7 @@ const SHADER: &str = r#"
vector: vec4f,
}
var<push_constant> pc: Pc;
var<immediate> pc: Pc;
@group(0) @binding(0)
var<storage, read_write> output: array<vec4f>;
@ -99,7 +99,7 @@ async fn partial_update_test(ctx: TestingContext) {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl],
push_constant_ranges: &[wgpu::PushConstantRange {
immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::COMPUTE,
range: 0..32,
}],
@ -133,17 +133,17 @@ async fn partial_update_test(ctx: TestingContext) {
// -- Dispatch 0 --
// 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.
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);
// -- Dispatch 1 --
// 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.
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);
}
@ -166,9 +166,9 @@ async fn partial_update_test(ctx: TestingContext) {
static RENDER_PASS_TEST: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.features(Features::PUSH_CONSTANTS | Features::VERTEX_WRITABLE_STORAGE)
.features(Features::IMMEDIATES | Features::VERTEX_WRITABLE_STORAGE)
.limits(wgpu::Limits {
max_push_constant_size: 64,
max_immediate_size: 64,
..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
// topology being PointList, so that each vertex shader call leads to exactly one fragment
// call.
const SHADER2: &str = "
const POSITION: vec4f = vec4f(0, 0, 0, 1);
struct PushConstants {
struct ImmediateData {
vertex_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>;
@ -202,14 +202,14 @@ const SHADER2: &str = "
@vertex fn vertex(
@builtin(vertex_index) ix: u32,
) -> VertexOutput {
result[ix] = push_constants.vertex_constants[ix];
result[ix] = immediates.vertex_constants[ix];
return VertexOutput(POSITION, ix);
}
@fragment fn fragment(
@location(0) ix: u32,
) -> @location(0) vec4f {
result[ix + 4u] = push_constants.fragment_constants[ix];
result[ix + 4u] = immediates.fragment_constants[ix];
return vec4f();
}
";
@ -271,7 +271,7 @@ async fn render_pass_test(ctx: &TestingContext, use_render_bundle: bool) {
.device
.create_pipeline_layout(&PipelineLayoutDescriptor {
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[PushConstantRange {
immediates_ranges: &[ImmediateRange {
stages: ShaderStages::VERTEX_FRAGMENT,
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());
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.draw(0..4, 0..1);
}

View File

@ -32,6 +32,7 @@ mod external_image_copy;
mod external_texture;
mod float32_filterable;
mod image_atomics;
mod immediates;
mod instance;
mod life_cycle;
mod mem_leaks;
@ -44,7 +45,6 @@ mod pipeline;
mod pipeline_cache;
mod planar_texture;
mod poll;
mod push_constants;
mod query_set;
mod queue_transfer;
mod ray_tracing;
@ -108,7 +108,7 @@ fn all_tests() -> Vec<wgpu_test::GpuTestInitializer> {
pipeline::all_tests(&mut tests);
planar_texture::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);
queue_transfer::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 {
label: None,
bind_group_layouts: &[&bgl],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: None,
bind_group_layouts: &[],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None,
@ -299,7 +299,7 @@ fn mesh_draw(ctx: &TestingContext, draw_type: DrawType) {
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[],
push_constant_ranges: &[],
immediates_ranges: &[],
});
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None,

View File

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

View File

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

View File

@ -8,7 +8,7 @@ struct ShaderData {
@group(0) @binding(0)
var<uniform> data1: ShaderData;
var<push_constant> data2: ShaderData;
var<immediate> data2: ShaderData;
struct FsIn {
@builtin(position) position: vec4f,
@ -27,7 +27,7 @@ fn fs_main(fs_in: FsIn) -> @location(0) vec4f {
case 0u: {
return fs_in.data1;
}
// (1, 0) - push constant from the vertex shader
// (1, 0) - immediate data from the vertex shader
case 1u: {
return fs_in.data2;
}
@ -35,7 +35,7 @@ fn fs_main(fs_in: FsIn) -> @location(0) vec4f {
case 2u: {
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: {
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
/// shaders. This turned out to not reproduce at all with this test case.
///
/// However, it also caught issues with the push constant implementation,
/// making sure that it works correctly with different definitions for the push constant
/// However, it also caught issues with the immediate data implementation,
/// making sure that it works correctly with different definitions for the immediate data
/// block in vertex and fragment shaders.
///
/// 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.
///
/// 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 right: Fragment Shader / Push Constant
/// bottom right: Fragment Shader / Immediate data
///
/// We then validate the data is correct from every position.
#[gpu_test]
static MULTI_STAGE_DATA_BINDING: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.features(wgpu::Features::PUSH_CONSTANTS)
.features(wgpu::Features::IMMEDIATES)
.limits(wgpu::Limits {
max_push_constant_size: 16,
max_immediate_size: 16,
..Default::default()
}),
)
@ -41,7 +41,7 @@ static MULTI_STAGE_DATA_BINDING: GpuTestConfiguration = GpuTestConfiguration::ne
async fn multi_stage_data_binding_test(ctx: TestingContext) {
// 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
.device
.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 {
label: Some("pll"),
bind_group_layouts: &[&bgl],
push_constant_ranges: &[wgpu::PushConstantRange {
immediates_ranges: &[wgpu::ImmediateRange {
stages: wgpu::ShaderStages::VERTEX_FRAGMENT,
range: 0..16,
}],
@ -171,7 +171,7 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) {
rpass.set_pipeline(&pipeline);
rpass.set_bind_group(0, &bg, &[]);
rpass.set_push_constants(
rpass.set_immediates(
wgpu::ShaderStages::VERTEX_FRAGMENT,
0,
bytemuck::cast_slice(&input),

View File

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

View File

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

View File

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

View File

@ -464,7 +464,7 @@ fn resource_setup(ctx: &TestingContext) -> ResourceSetup {
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pipeline_layout"),
bind_group_layouts: &[&bgl],
push_constant_ranges: &[],
immediates_ranges: &[],
});
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 {
label: Some("pipeline_layout"),
bind_group_layouts: &bgl_references,
push_constant_ranges: &[],
immediates_ranges: &[],
});
let input_image = ctx.device.create_texture(&wgpu::TextureDescriptor {

View File

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

View File

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

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