Skip to content

Commit

Permalink
[naga] Move array-by-value snapshot tests to index-by-value.wgsl.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Oct 11, 2024
1 parent 0395695 commit 5689cb4
Show file tree
Hide file tree
Showing 17 changed files with 499 additions and 814 deletions.
12 changes: 0 additions & 12 deletions naga/tests/in/access.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,6 @@ fn assign_through_ptr() {
assign_array_through_ptr_fn(&arr);
}

@vertex
fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4<f32> {
let arr = array<i32, 5>(1, 2, 3, 4, 5);
let value = arr[vi];
return vec4<f32>(vec4<i32>(value));
}

fn array_by_value(a: array<i32, 5>, i: i32) -> i32 {
return a[i];
}


struct AssignToMember {
x: u32,
}
Expand Down
7 changes: 7 additions & 0 deletions naga/tests/in/index-by-value.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ fn index_let_matrix(i: i32, j: i32) -> f32 {
let a = mat2x2<f32>(1, 2, 3, 4);
return a[i][j];
}

@vertex
fn index_let_array_1d(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4<f32> {
let arr = array<i32, 5>(1, 2, 3, 4, 5);
let value = arr[vi];
return vec4<f32>(vec4<i32>(value));
}
186 changes: 0 additions & 186 deletions naga/tests/out/analysis/access.info.ron
Original file line number Diff line number Diff line change
Expand Up @@ -2739,54 +2739,6 @@
sampling: [],
dual_source_blending: false,
),
(
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
available_stages: ("VERTEX | FRAGMENT | COMPUTE"),
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
may_kill: false,
sampling_set: [],
global_uses: [
(""),
(""),
(""),
(""),
(""),
],
expressions: [
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(25),
),
(
uniformity: (
non_uniform_result: Some(1),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(2),
),
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(2),
),
],
sampling: [],
dual_source_blending: false,
),
(
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
available_stages: ("VERTEX | FRAGMENT | COMPUTE"),
Expand Down Expand Up @@ -4243,144 +4195,6 @@
sampling: [],
dual_source_blending: false,
),
(
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
available_stages: ("VERTEX | FRAGMENT | COMPUTE"),
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
may_kill: false,
sampling_set: [],
global_uses: [
(""),
(""),
(""),
(""),
(""),
],
expressions: [
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(0),
),
(
uniformity: (
non_uniform_result: None,
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Scalar((
kind: Sint,
width: 4,
))),
),
(
uniformity: (
non_uniform_result: None,
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Scalar((
kind: Sint,
width: 4,
))),
),
(
uniformity: (
non_uniform_result: None,
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Scalar((
kind: Sint,
width: 4,
))),
),
(
uniformity: (
non_uniform_result: None,
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Scalar((
kind: Sint,
width: 4,
))),
),
(
uniformity: (
non_uniform_result: None,
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Scalar((
kind: Sint,
width: 4,
))),
),
(
uniformity: (
non_uniform_result: None,
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(25),
),
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(2),
),
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Vector(
size: Quad,
scalar: (
kind: Sint,
width: 4,
),
)),
),
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Vector(
size: Quad,
scalar: (
kind: Float,
width: 4,
),
)),
),
],
sampling: [],
dual_source_blending: false,
),
(
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
available_stages: ("VERTEX | FRAGMENT | COMPUTE"),
Expand Down
12 changes: 4 additions & 8 deletions naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct AssignToMember {
uint x;
};

float read_from_private(inout float foo_2) {
float _e1 = foo_2;
float read_from_private(inout float foo_1) {
float _e1 = foo_1;
return _e1;
}

Expand All @@ -37,15 +37,11 @@ void assign_through_ptr_fn(inout uint p) {
return;
}

void assign_array_through_ptr_fn(inout vec4 foo_3[2]) {
foo_3 = vec4[2](vec4(1.0), vec4(2.0));
void assign_array_through_ptr_fn(inout vec4 foo_2[2]) {
foo_2 = vec4[2](vec4(1.0), vec4(2.0));
return;
}

int array_by_value(int a_1[5], int i) {
return a_1[i];
}

uint fetch_arg_ptr_member(inout AssignToMember p_1) {
uint _e2 = p_1.x;
return _e2;
Expand Down
12 changes: 4 additions & 8 deletions naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct AssignToMember {
uint x;
};

float read_from_private(inout float foo_2) {
float _e1 = foo_2;
float read_from_private(inout float foo_1) {
float _e1 = foo_1;
return _e1;
}

Expand All @@ -37,15 +37,11 @@ void assign_through_ptr_fn(inout uint p) {
return;
}

void assign_array_through_ptr_fn(inout vec4 foo_3[2]) {
foo_3 = vec4[2](vec4(1.0), vec4(2.0));
void assign_array_through_ptr_fn(inout vec4 foo_2[2]) {
foo_2 = vec4[2](vec4(1.0), vec4(2.0));
return;
}

int array_by_value(int a_1[5], int i) {
return a_1[i];
}

uint fetch_arg_ptr_member(inout AssignToMember p_1) {
uint _e2 = p_1.x;
return _e2;
Expand Down
12 changes: 4 additions & 8 deletions naga/tests/out/glsl/access.foo_frag.Fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ layout(std430) buffer type_13_block_1Fragment { ivec2 _group_0_binding_2_fs; };

layout(location = 0) out vec4 _fs2p_location0;

float read_from_private(inout float foo_2) {
float _e1 = foo_2;
float read_from_private(inout float foo_1) {
float _e1 = foo_1;
return _e1;
}

Expand All @@ -47,15 +47,11 @@ void assign_through_ptr_fn(inout uint p) {
return;
}

void assign_array_through_ptr_fn(inout vec4 foo_3[2]) {
foo_3 = vec4[2](vec4(1.0), vec4(2.0));
void assign_array_through_ptr_fn(inout vec4 foo_2[2]) {
foo_2 = vec4[2](vec4(1.0), vec4(2.0));
return;
}

int array_by_value(int a_1[5], int i) {
return a_1[i];
}

uint fetch_arg_ptr_member(inout AssignToMember p_1) {
uint _e2 = p_1.x;
return _e2;
Expand Down
16 changes: 6 additions & 10 deletions naga/tests/out/glsl/access.foo_vert.Vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ void test_matrix_within_array_within_struct_accesses() {
return;
}

float read_from_private(inout float foo_2) {
float _e1 = foo_2;
float read_from_private(inout float foo_1) {
float _e1 = foo_1;
return _e1;
}

Expand All @@ -120,15 +120,11 @@ void assign_through_ptr_fn(inout uint p) {
return;
}

void assign_array_through_ptr_fn(inout vec4 foo_3[2]) {
foo_3 = vec4[2](vec4(1.0), vec4(2.0));
void assign_array_through_ptr_fn(inout vec4 foo_2[2]) {
foo_2 = vec4[2](vec4(1.0), vec4(2.0));
return;
}

int array_by_value(int a_1[5], int i) {
return a_1[i];
}

uint fetch_arg_ptr_member(inout AssignToMember p_1) {
uint _e2 = p_1.x;
return _e2;
Expand Down Expand Up @@ -160,10 +156,10 @@ void main() {
mat4x3 _matrix = _group_0_binding_0_vs._matrix;
uvec2 arr_1[2] = _group_0_binding_0_vs.arr;
float b = _group_0_binding_0_vs._matrix[3u][0];
int a_2 = _group_0_binding_0_vs.data[(uint(_group_0_binding_0_vs.data.length()) - 2u)].value;
int a_1 = _group_0_binding_0_vs.data[(uint(_group_0_binding_0_vs.data.length()) - 2u)].value;
ivec2 c = _group_0_binding_2_vs;
float _e33 = read_from_private(foo);
c2_ = int[5](a_2, int(b), 3, 4, 5);
c2_ = int[5](a_1, int(b), 3, 4, 5);
c2_[(vi + 1u)] = 42;
int value = c2_[vi];
float _e47 = test_arr_as_arg(float[5][10](float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)));
Expand Down
Loading

0 comments on commit 5689cb4

Please sign in to comment.