Skip to content

Commit 6948a01

Browse files
fix(core): remove max_inter_stage_shader_components validation
1 parent a26de12 commit 6948a01

9 files changed

Lines changed: 36 additions & 97 deletions

File tree

wgpu-core/src/validation.rs

Lines changed: 36 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ impl fmt::Display for NumericDimension {
102102
}
103103
}
104104

105-
impl NumericDimension {
106-
fn num_components(&self) -> u32 {
107-
match *self {
108-
Self::Scalar => 1,
109-
Self::Vector(size) => size as u32,
110-
Self::Matrix(w, h) => w as u32 * h as u32,
111-
}
112-
}
113-
}
114-
115105
#[derive(Clone, Copy, Debug)]
116106
pub struct NumericType {
117107
dim: NumericDimension,
@@ -302,8 +292,6 @@ pub enum StageError {
302292
per_dimension_limit: &'static str,
303293
total_limit: &'static str,
304294
},
305-
#[error("Shader uses {used} inter-stage components above the limit of {limit}")]
306-
TooManyVaryings { used: u32, limit: u32 },
307295
#[error("Unable to find entry point '{0}'")]
308296
MissingEntryPoint(String),
309297
#[error("Shader global {0:?} is not available in the pipeline layout")]
@@ -426,7 +414,6 @@ impl WebGpuError for StageError {
426414
error,
427415
} => error,
428416
Self::InvalidWorkgroupSize { .. }
429-
| Self::TooManyVaryings { .. }
430417
| Self::MissingEntryPoint(..)
431418
| Self::NoEntryPointFound
432419
| Self::MultipleEntryPointsFound
@@ -1424,7 +1411,6 @@ impl Interface {
14241411
}
14251412
}
14261413

1427-
let mut inter_stage_components = 0;
14281414
let mut this_stage_primitive_index = false;
14291415
let mut has_draw_id = false;
14301416

@@ -1437,38 +1423,36 @@ impl Interface {
14371423
.get(&location)
14381424
.ok_or(InputError::Missing)
14391425
.and_then(|provided| {
1440-
let (compatible, num_components, per_primitive_correct) =
1441-
match shader_stage.to_naga() {
1442-
// For vertex attributes, there are defaults filled out
1443-
// by the driver if data is not provided.
1444-
naga::ShaderStage::Vertex => {
1445-
let is_compatible =
1446-
iv.ty.scalar.kind == provided.ty.scalar.kind;
1447-
// vertex inputs don't count towards inter-stage
1448-
(is_compatible, 0, !iv.per_primitive)
1426+
let (compatible, per_primitive_correct) = match shader_stage.to_naga() {
1427+
// For vertex attributes, there are defaults filled out
1428+
// by the driver if data is not provided.
1429+
naga::ShaderStage::Vertex => {
1430+
let is_compatible =
1431+
iv.ty.scalar.kind == provided.ty.scalar.kind;
1432+
// vertex inputs don't count towards inter-stage
1433+
(is_compatible, !iv.per_primitive)
1434+
}
1435+
naga::ShaderStage::Fragment => {
1436+
if iv.interpolation != provided.interpolation {
1437+
return Err(InputError::InterpolationMismatch(
1438+
provided.interpolation,
1439+
));
14491440
}
1450-
naga::ShaderStage::Fragment => {
1451-
if iv.interpolation != provided.interpolation {
1452-
return Err(InputError::InterpolationMismatch(
1453-
provided.interpolation,
1454-
));
1455-
}
1456-
if iv.sampling != provided.sampling {
1457-
return Err(InputError::SamplingMismatch(
1458-
provided.sampling,
1459-
));
1460-
}
1461-
(
1462-
iv.ty.is_subtype_of(&provided.ty),
1463-
iv.ty.dim.num_components(),
1464-
iv.per_primitive == provided.per_primitive,
1465-
)
1441+
if iv.sampling != provided.sampling {
1442+
return Err(InputError::SamplingMismatch(
1443+
provided.sampling,
1444+
));
14661445
}
1467-
// These can't have varying inputs
1468-
naga::ShaderStage::Compute
1469-
| naga::ShaderStage::Task
1470-
| naga::ShaderStage::Mesh => (false, 0, false),
1471-
};
1446+
(
1447+
iv.ty.is_subtype_of(&provided.ty),
1448+
iv.per_primitive == provided.per_primitive,
1449+
)
1450+
}
1451+
// These can't have varying inputs
1452+
naga::ShaderStage::Compute
1453+
| naga::ShaderStage::Task
1454+
| naga::ShaderStage::Mesh => (false, false),
1455+
};
14721456
if !compatible {
14731457
return Err(InputError::WrongType(provided.ty));
14741458
} else if !per_primitive_correct {
@@ -1477,19 +1461,15 @@ impl Interface {
14771461
shader: iv.per_primitive,
14781462
});
14791463
}
1480-
Ok(num_components)
1464+
Ok(())
1465+
});
1466+
1467+
if let Err(error) = result {
1468+
return Err(StageError::Input {
1469+
location,
1470+
var: iv.clone(),
1471+
error,
14811472
});
1482-
match result {
1483-
Ok(num_components) => {
1484-
inter_stage_components += num_components;
1485-
}
1486-
Err(error) => {
1487-
return Err(StageError::Input {
1488-
location,
1489-
var: iv.clone(),
1490-
error,
1491-
})
1492-
}
14931473
}
14941474
}
14951475
Varying::BuiltIn(naga::BuiltIn::PrimitiveIndex) => {
@@ -1544,7 +1524,6 @@ impl Interface {
15441524
});
15451525
}
15461526
num_user_defined_outputs += 1;
1547-
inter_stage_components += iv.ty.dim.num_components()
15481527
}
15491528
Varying::BuiltIn(_) => {}
15501529
};
@@ -1625,7 +1604,6 @@ impl Interface {
16251604
});
16261605
}
16271606
num_user_defined_inputs += 1;
1628-
inter_stage_components += iv.ty.dim.num_components()
16291607
}
16301608
Varying::BuiltIn(_) => {}
16311609
};
@@ -1655,13 +1633,6 @@ impl Interface {
16551633
_ => (),
16561634
}
16571635

1658-
if inter_stage_components > self.limits.max_inter_stage_shader_components {
1659-
return Err(StageError::TooManyVaryings {
1660-
used: inter_stage_components,
1661-
limit: self.limits.max_inter_stage_shader_components,
1662-
});
1663-
}
1664-
16651636
if let Some(ref mesh_info) = entry_point.mesh_info {
16661637
if mesh_info.max_vertices > self.limits.max_mesh_output_vertices {
16671638
return Err(StageError::TooManyMeshVertices {

wgpu-hal/src/dx12/adapter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ impl super::Adapter {
809809
min_uniform_buffer_offset_alignment:
810810
Direct3D12::D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT,
811811
min_storage_buffer_offset_alignment: 4,
812-
max_inter_stage_shader_components: base.max_inter_stage_shader_components,
813812
max_inter_stage_shader_variables: base.max_inter_stage_shader_variables,
814813
max_color_attachments,
815814
max_color_attachment_bytes_per_sample,

wgpu-hal/src/gles/adapter.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -755,19 +755,6 @@ impl super::Adapter {
755755
max_immediate_size: super::MAX_IMMEDIATES as u32 * 4,
756756
min_uniform_buffer_offset_alignment,
757757
min_storage_buffer_offset_alignment,
758-
max_inter_stage_shader_components: {
759-
// MAX_VARYING_COMPONENTS may return 0, because it is deprecated since OpenGL 3.2 core,
760-
// and an OpenGL Context with the core profile and with forward-compatibility=true,
761-
// will make deprecated constants unavailable.
762-
let max_varying_components =
763-
unsafe { gl.get_parameter_i32(glow::MAX_VARYING_COMPONENTS) } as u32;
764-
if max_varying_components == 0 {
765-
// default value for max_inter_stage_shader_components
766-
60
767-
} else {
768-
max_varying_components
769-
}
770-
},
771758
max_inter_stage_shader_variables: {
772759
// MAX_VARYING_COMPONENTS may return 0, because it is deprecated since OpenGL 3.2 core,
773760
// and an OpenGL Context with the core profile and with forward-compatibility=true,

wgpu-hal/src/metal/adapter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,6 @@ impl super::PrivateCapabilities {
11941194
max_inter_stage_shader_variables: self.max_varying_components / 4,
11951195
min_uniform_buffer_offset_alignment: self.buffer_alignment as u32,
11961196
min_storage_buffer_offset_alignment: self.buffer_alignment as u32,
1197-
max_inter_stage_shader_components: self.max_varying_components,
11981197
max_color_attachments: self.max_color_render_targets as u32,
11991198
max_color_attachment_bytes_per_sample: self.max_color_attachment_bytes_per_sample
12001199
as u32,

wgpu-hal/src/noop/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ pub const CAPABILITIES: crate::Capabilities = {
185185
max_inter_stage_shader_variables: ALLOC_MAX_U32,
186186
min_uniform_buffer_offset_alignment: 1,
187187
min_storage_buffer_offset_alignment: 1,
188-
max_inter_stage_shader_components: ALLOC_MAX_U32,
189188
max_color_attachments: ALLOC_MAX_U32,
190189
max_color_attachment_bytes_per_sample: ALLOC_MAX_U32,
191190
max_compute_workgroup_storage_size: ALLOC_MAX_U32,

wgpu-hal/src/vulkan/adapter.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,6 @@ impl PhysicalDeviceProperties {
14371437
/ 4,
14381438
min_uniform_buffer_offset_alignment: limits.min_uniform_buffer_offset_alignment as u32,
14391439
min_storage_buffer_offset_alignment: limits.min_storage_buffer_offset_alignment as u32,
1440-
max_inter_stage_shader_components: limits
1441-
.max_vertex_output_components
1442-
.min(limits.max_fragment_input_components),
14431440
max_color_attachments: limits.max_color_attachments,
14441441
max_color_attachment_bytes_per_sample,
14451442
max_compute_workgroup_storage_size: limits.max_compute_shared_memory_size,

wgpu-info/src/human.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
167167
max_inter_stage_shader_variables,
168168
min_uniform_buffer_offset_alignment,
169169
min_storage_buffer_offset_alignment,
170-
max_inter_stage_shader_components,
171170
max_color_attachments,
172171
max_color_attachment_bytes_per_sample,
173172
max_compute_workgroup_storage_size,
@@ -223,7 +222,6 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
223222
writeln!(output, "\t\t Max Inter-stage Shader Variables: {max_inter_stage_shader_variables}")?;
224223
writeln!(output, "\t\t Min Uniform Buffer Offset Alignment: {min_uniform_buffer_offset_alignment}")?;
225224
writeln!(output, "\t\t Min Storage Buffer Offset Alignment: {min_storage_buffer_offset_alignment}")?;
226-
writeln!(output, "\t\t Max Inter-Stage Shader Component: {max_inter_stage_shader_components}")?;
227225
writeln!(output, "\t\t Max Color Attachments: {max_color_attachments}")?;
228226
writeln!(output, "\t\t Max Color Attachment Bytes per sample: {max_color_attachment_bytes_per_sample}")?;
229227
writeln!(output, "\t\t Max Compute Workgroup Storage Size: {max_compute_workgroup_storage_size}")?;

wgpu-types/src/limits.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ macro_rules! with_limits {
4646
$macro_name!(max_vertex_buffer_array_stride, Ordering::Less);
4747
$macro_name!(min_uniform_buffer_offset_alignment, Ordering::Greater);
4848
$macro_name!(min_storage_buffer_offset_alignment, Ordering::Greater);
49-
$macro_name!(max_inter_stage_shader_components, Ordering::Less);
5049
$macro_name!(max_color_attachments, Ordering::Less);
5150
$macro_name!(max_color_attachment_bytes_per_sample, Ordering::Less);
5251
$macro_name!(max_compute_workgroup_storage_size, Ordering::Less);
@@ -193,10 +192,6 @@ pub struct Limits {
193192
/// when creating a `BindGroup`, or for `set_bind_group` `dynamicOffsets`.
194193
/// Defaults to 256. Lower is "better".
195194
pub min_storage_buffer_offset_alignment: u32,
196-
/// Maximum allowed number of components (scalars) of input or output locations for
197-
/// inter-stage communication (vertex outputs to fragment inputs). Defaults to 60.
198-
/// Higher is "better".
199-
pub max_inter_stage_shader_components: u32,
200195
/// The maximum allowed number of color attachments.
201196
pub max_color_attachments: u32,
202197
/// The maximum number of bytes necessary to hold one sample (pixel or subpixel) of render
@@ -333,7 +328,6 @@ impl Limits {
333328
/// max_inter_stage_shader_variables: 16,
334329
/// min_uniform_buffer_offset_alignment: 256,
335330
/// min_storage_buffer_offset_alignment: 256,
336-
/// max_inter_stage_shader_components: 60,
337331
/// max_color_attachments: 8,
338332
/// max_color_attachment_bytes_per_sample: 32,
339333
/// max_compute_workgroup_storage_size: 16384,
@@ -392,7 +386,6 @@ impl Limits {
392386
max_inter_stage_shader_variables: 16,
393387
min_uniform_buffer_offset_alignment: 256,
394388
min_storage_buffer_offset_alignment: 256,
395-
max_inter_stage_shader_components: 60,
396389
max_color_attachments: 8,
397390
max_color_attachment_bytes_per_sample: 32,
398391
max_compute_workgroup_storage_size: 16384,
@@ -455,7 +448,6 @@ impl Limits {
455448
/// min_uniform_buffer_offset_alignment: 256,
456449
/// min_storage_buffer_offset_alignment: 256,
457450
/// max_inter_stage_shader_variables: 15,
458-
/// max_inter_stage_shader_components: 60,
459451
/// max_color_attachments: 4,
460452
/// max_color_attachment_bytes_per_sample: 32,
461453
/// max_compute_workgroup_storage_size: 16352, // *
@@ -534,7 +526,6 @@ impl Limits {
534526
/// min_uniform_buffer_offset_alignment: 256,
535527
/// min_storage_buffer_offset_alignment: 256,
536528
/// max_inter_stage_shader_variables: 15,
537-
/// max_inter_stage_shader_components: 31,
538529
/// max_color_attachments: 4,
539530
/// max_color_attachment_bytes_per_sample: 32,
540531
/// max_compute_workgroup_storage_size: 0, // +
@@ -584,7 +575,6 @@ impl Limits {
584575

585576
// Value supported by Intel Celeron B830 on Windows (OpenGL 3.1)
586577
max_inter_stage_shader_variables: 15,
587-
max_inter_stage_shader_components: 31,
588578

589579
// Most of the values should be the same as the downlevel defaults
590580
..Self::downlevel_defaults()

wgpu/src/backend/webgpu.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,6 @@ fn map_wgt_limits(limits: webgpu_sys::GpuSupportedLimits) -> wgt::Limits {
821821
max_compute_workgroups_per_dimension: limits.max_compute_workgroups_per_dimension(),
822822
max_immediate_size: wgt::Limits::default().max_immediate_size,
823823
max_non_sampler_bindings: wgt::Limits::default().max_non_sampler_bindings,
824-
max_inter_stage_shader_components: wgt::Limits::default().max_inter_stage_shader_components,
825824

826825
max_task_mesh_workgroup_total_count: wgt::Limits::default()
827826
.max_task_mesh_workgroup_total_count,

0 commit comments

Comments
 (0)