Skip to content

Commit 4514fb2

Browse files
committed
fix(naga): Increase MAX_TYPE_SIZE to i32::MAX
1 parent 528f31d commit 4514fb2

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

cts_runner/fail.lst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ webgpu:shader,validation,shader_io,interpolate:*
133133
webgpu:shader,validation,shader_io,layout_constraints:* // 99%, struct alignment not inferred from @align on members
134134
webgpu:shader,validation,shader_io,locations:stage_inout:* // 66%, invalid usage @location in compute shaders
135135
webgpu:shader,validation,shader_io,pipeline_stage:* // 92%, stage attributes incorrectly accepted on var<private> and var<storage>
136-
webgpu:shader,validation,shader_io,size:* // 94%, large size validation, runtime-sized array
137136
webgpu:shader,validation,shader_io,workgroup_size:* // 88%, type mixing, attribute placement
138137
webgpu:shader,validation,statement,continue:* // 90%, continue bypassing declaration used in continuing block, https://github.com/gfx-rs/wgpu/issues/7650
139138
webgpu:shader,validation,statement,for:* // 93%, phony/increment in for-loop init/cont, empty loop behavior

cts_runner/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ webgpu:shader,validation,shader_io,locations:nesting:*
466466
webgpu:shader,validation,shader_io,locations:out_of_order:*
467467
webgpu:shader,validation,shader_io,locations:type:*
468468
webgpu:shader,validation,shader_io,locations:validation:*
469+
webgpu:shader,validation,shader_io,size:*
469470
webgpu:shader,validation,statement,break_if:*
470471
webgpu:shader,validation,statement,break:*
471472
webgpu:shader,validation,statement,compound:*

naga/src/valid/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use r#type::{Disalignment, ImmediateError, TypeError, TypeFlags, WidthError}
3636
use self::handles::InvalidHandleError;
3737

3838
/// Maximum size of a type, in bytes.
39-
pub const MAX_TYPE_SIZE: u32 = 0x4000_0000; // 1GB
39+
pub const MAX_TYPE_SIZE: u32 = i32::MAX as u32;
4040

4141
bitflags::bitflags! {
4242
/// Validation flags.

naga/tests/naga/wgsl_errors.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,13 @@ fn struct_member_size_too_low() {
590590
check(
591591
r#"
592592
struct Bar {
593-
@size(0) data: array<f32>
593+
@size(0) data: array<f32, 1>
594594
}
595595
"#,
596596
r#"error: struct member size must be at least 4
597597
┌─ wgsl:3:23
598598
599-
3 │ @size(0) data: array<f32>
599+
3 │ @size(0) data: array<f32, 1>
600600
│ ^ must be at least 4
601601
602602
"#,
@@ -4396,7 +4396,7 @@ fn max_type_size_large_array() {
43964396
// The total size of an array is not resolved until validation. Type aliases
43974397
// don't get spans so the error isn't very helpful.
43984398
check_validation! {
4399-
"alias LargeArray = array<u32, (1 << 28) + 1>;":
4399+
"alias LargeArray = array<u32, 1 << 29>;":
44004400
Err(naga::valid::ValidationError::Layouter(
44014401
naga::proc::LayoutError {
44024402
inner: naga::proc::LayoutErrorInner::TooLarge,
@@ -4412,9 +4412,9 @@ fn max_type_size_array_of_arrays() {
44124412
// during lowering. Anonymous types don't get spans so this error isn't very
44134413
// helpful.
44144414
check(
4415-
"alias ArrayOfArrays = array<array<u32, (1 << 28) + 1>, 22>;",
4415+
"alias ArrayOfArrays = array<array<u32, 1 << 29>, 22>;",
44164416
r#"error: type is too large
4417-
= note: the maximum size is 1073741824 bytes
4417+
= note: the maximum size is 2147483647 bytes
44184418
44194419
"#,
44204420
);
@@ -4441,7 +4441,7 @@ fn max_type_size_override_array() {
44414441
.validate(&module)
44424442
.expect("module should validate");
44434443

4444-
let overrides = hashbrown::HashMap::from([(String::from("SIZE"), f64::from((1 << 28) + 1))]);
4444+
let overrides = hashbrown::HashMap::from([(String::from("SIZE"), f64::from(1 << 29))]);
44454445
let err = naga::back::pipeline_constants::process_overrides(&module, &info, None, &overrides)
44464446
.unwrap_err();
44474447
let naga::back::pipeline_constants::PipelineConstantError::ValidationError(err) = err else {
@@ -4463,16 +4463,16 @@ fn max_type_size_array_in_struct() {
44634463
check(
44644464
r#"
44654465
struct ContainsLargeArray {
4466-
arr: array<u32, (1 << 28) + 1>,
4466+
arr: array<u32, 1 << 29>,
44674467
}
44684468
"#,
44694469
r#"error: struct member is too large
44704470
┌─ wgsl:3:17
44714471
4472-
3 │ arr: array<u32, (1 << 28) + 1>,
4472+
3 │ arr: array<u32, 1 << 29>,
44734473
│ ^^^ this member exceeds the maximum size
44744474
4475-
= note: the maximum size is 1073741824 bytes
4475+
= note: the maximum size is 2147483647 bytes
44764476
44774477
"#,
44784478
);
@@ -4485,20 +4485,20 @@ fn max_type_size_two_arrays_in_struct() {
44854485
check(
44864486
r#"
44874487
struct TwoArrays {
4488-
arr1: array<u32, 1 << 27>,
4489-
arr2: array<u32, (1 << 27) + 1>,
4488+
arr1: array<u32, 1 << 28>,
4489+
arr2: array<u32, 1 << 28>,
44904490
}
44914491
"#,
44924492
"error: type is too large
44934493
┌─ wgsl:2:13
44944494
\x20\x20
44954495
2 │ ╭ struct TwoArrays {
4496-
3 │ │ arr1: array<u32, 1 << 27>,
4497-
4 │ │ arr2: array<u32, (1 << 27) + 1>,
4496+
3 │ │ arr1: array<u32, 1 << 28>,
4497+
4 │ │ arr2: array<u32, 1 << 28>,
44984498
5 │ │ }
44994499
│ ╰─────────────^ this type exceeds the maximum size
45004500
\x20\x20
4501-
= note: the maximum size is 1073741824 bytes
4501+
= note: the maximum size is 2147483647 bytes
45024502
45034503
",
45044504
);
@@ -4513,7 +4513,7 @@ fn max_type_size_array_of_structs() {
45134513
struct NotVeryBigStruct {
45144514
data: u32,
45154515
}
4516-
alias BigArrayOfStructs = array<NotVeryBigStruct, (1 << 28) + 1>;
4516+
alias BigArrayOfStructs = array<NotVeryBigStruct, 1 << 29>;
45174517
"#:
45184518
Err(naga::valid::ValidationError::Layouter(
45194519
naga::proc::LayoutError {

0 commit comments

Comments
 (0)