Skip to content

Commit

Permalink
Update tests for pointer_composite_access
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev committed Jan 15, 2025
1 parent 59dbb16 commit 00a89cb
Show file tree
Hide file tree
Showing 13 changed files with 1,041 additions and 459 deletions.
14 changes: 14 additions & 0 deletions naga/tests/in/access.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,17 @@ fn assign_to_ptr_components() {
assign_to_arg_ptr_array_element(&a1);
fetch_arg_ptr_array_element(&a1);
}

fn index_ptr(value: bool) -> bool {
var a = array<bool, 1>(value);
let p = &a;
return p[0];
}

struct S { m: i32 };

fn member_ptr() -> i32 {
var s: S = S(42);
let p = &s;
return p.m;
}
152 changes: 152 additions & 0 deletions naga/tests/out/analysis/access.info.ron
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
("SIZED | COPY | CREATION_RESOLVED | ARGUMENT"),
("DATA | SIZED | COPY | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"),
("SIZED | COPY | CREATION_RESOLVED | ARGUMENT"),
("DATA | SIZED | COPY | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"),
("DATA | SIZED | COPY | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"),
("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | CREATION_RESOLVED | ARGUMENT | CONSTRUCTIBLE"),
],
functions: [
(
Expand Down Expand Up @@ -2959,6 +2962,155 @@
dual_source_blending: false,
diagnostic_filter_leaf: None,
),
(
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
available_stages: ("VERTEX | FRAGMENT | COMPUTE"),
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
may_kill: false,
sampling_set: [],
global_uses: [
(""),
(""),
(""),
(""),
(""),
],
expressions: [
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(33),
),
(
uniformity: (
non_uniform_result: Some(0),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(34),
),
(
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
ref_count: 2,
assignable_global: None,
ty: Value(Pointer(
base: 34,
space: Function,
)),
),
(
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Pointer(
base: 33,
space: Function,
)),
),
(
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(33),
),
],
sampling: [],
dual_source_blending: false,
diagnostic_filter_leaf: None,
),
(
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
available_stages: ("VERTEX | FRAGMENT | COMPUTE"),
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
may_kill: false,
sampling_set: [],
global_uses: [
(""),
(""),
(""),
(""),
(""),
],
expressions: [
(
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(35),
),
(
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Pointer(
base: 35,
space: Function,
)),
),
(
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Value(Pointer(
base: 2,
space: Function,
)),
),
(
uniformity: (
non_uniform_result: Some(2),
requirements: (""),
),
ref_count: 1,
assignable_global: None,
ty: Handle(2),
),
],
sampling: [],
dual_source_blending: false,
diagnostic_filter_leaf: None,
),
],
entry_points: [
(
Expand Down
16 changes: 16 additions & 0 deletions naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct MatCx2InArray {
struct AssignToMember {
uint x;
};
struct S {
int m;
};

float read_from_private(inout float foo_1) {
float _e1 = foo_1;
Expand Down Expand Up @@ -62,6 +65,19 @@ void assign_to_arg_ptr_array_element(inout uint p_4[4]) {
return;
}

bool index_ptr(bool value) {
bool a_1[1] = bool[1](false);
a_1 = bool[1](value);
bool _e4 = a_1[0];
return _e4;
}

int member_ptr() {
S s = S(42);
int _e4 = s.m;
return _e4;
}

void main() {
uint val = 33u;
vec4 arr[2] = vec4[2](vec4(6.0), vec4(7.0));
Expand Down
16 changes: 16 additions & 0 deletions naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct MatCx2InArray {
struct AssignToMember {
uint x;
};
struct S {
int m;
};

float read_from_private(inout float foo_1) {
float _e1 = foo_1;
Expand Down Expand Up @@ -62,6 +65,19 @@ void assign_to_arg_ptr_array_element(inout uint p_4[4]) {
return;
}

bool index_ptr(bool value) {
bool a_1[1] = bool[1](false);
a_1 = bool[1](value);
bool _e4 = a_1[0];
return _e4;
}

int member_ptr() {
S s = S(42);
int _e4 = s.m;
return _e4;
}

void main() {
AssignToMember s1_ = AssignToMember(0u);
uint a1_[4] = uint[4](0u, 0u, 0u, 0u);
Expand Down
16 changes: 16 additions & 0 deletions naga/tests/out/glsl/access.foo_frag.Fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ struct MatCx2InArray {
struct AssignToMember {
uint x;
};
struct S {
int m;
};
layout(std430) buffer Bar_block_0Fragment {
mat4x3 _matrix;
mat2x2 matrix_array[2];
Expand Down Expand Up @@ -72,6 +75,19 @@ void assign_to_arg_ptr_array_element(inout uint p_4[4]) {
return;
}

bool index_ptr(bool value) {
bool a_1[1] = bool[1](false);
a_1 = bool[1](value);
bool _e4 = a_1[0];
return _e4;
}

int member_ptr() {
S s = S(42);
int _e4 = s.m;
return _e4;
}

void main() {
_group_0_binding_0_fs._matrix[1][2] = 1.0;
_group_0_binding_0_fs._matrix = mat4x3(vec3(0.0), vec3(1.0), vec3(2.0), vec3(3.0));
Expand Down
24 changes: 20 additions & 4 deletions naga/tests/out/glsl/access.foo_vert.Vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ struct MatCx2InArray {
struct AssignToMember {
uint x;
};
struct S {
int m;
};
layout(std430) buffer Bar_block_0Vertex {
mat4x3 _matrix;
mat2x2 matrix_array[2];
Expand Down Expand Up @@ -145,6 +148,19 @@ void assign_to_arg_ptr_array_element(inout uint p_4[4]) {
return;
}

bool index_ptr(bool value) {
bool a_1[1] = bool[1](false);
a_1 = bool[1](value);
bool _e4 = a_1[0];
return _e4;
}

int member_ptr() {
S s = S(42);
int _e4 = s.m;
return _e4;
}

void main() {
uint vi = uint(gl_VertexID);
float foo = 0.0;
Expand All @@ -156,14 +172,14 @@ 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_1 = _group_0_binding_0_vs.data[(uint(_group_0_binding_0_vs.data.length()) - 2u)].value;
int a_2 = _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_1, int(b), 3, 4, 5);
c2_ = int[5](a_2, int(b), 3, 4, 5);
c2_[(vi + 1u)] = 42;
int value = c2_[vi];
int value_1 = 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)));
gl_Position = vec4((_matrix * vec4(ivec4(value))), 2.0);
gl_Position = vec4((_matrix * vec4(ivec4(value_1))), 2.0);
gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);
return;
}
Expand Down
41 changes: 37 additions & 4 deletions naga/tests/out/hlsl/access.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ struct AssignToMember {
uint x;
};

struct S {
int m;
};

GlobalConst ConstructGlobalConst(uint arg0, uint3 arg1, int arg2) {
GlobalConst ret = (GlobalConst)0;
ret.a = arg0;
Expand Down Expand Up @@ -258,6 +262,35 @@ void assign_to_arg_ptr_array_element(inout uint p_4[4])
return;
}

typedef bool ret_Constructarray1_bool_[1];
ret_Constructarray1_bool_ Constructarray1_bool_(bool arg0) {
bool ret[1] = { arg0 };
return ret;
}

bool index_ptr(bool value)
{
bool a_1[1] = (bool[1])0;

a_1 = Constructarray1_bool_(value);
bool _e4 = a_1[0];
return _e4;
}

S ConstructS(int arg0) {
S ret = (S)0;
ret.m = arg0;
return ret;
}

int member_ptr()
{
S s = ConstructS(42);

int _e4 = s.m;
return _e4;
}

typedef int ret_Constructarray5_int_[5];
ret_Constructarray5_int_ Constructarray5_int_(int arg0, int arg1, int arg2, int arg3, int arg4) {
int ret[5] = { arg0, arg1, arg2, arg3, arg4 };
Expand Down Expand Up @@ -294,14 +327,14 @@ float4 foo_vert(uint vi : SV_VertexID) : SV_Position
float4x3 _matrix = float4x3(asfloat(bar.Load3(0+0)), asfloat(bar.Load3(0+16)), asfloat(bar.Load3(0+32)), asfloat(bar.Load3(0+48)));
uint2 arr_1[2] = Constructarray2_uint2_(asuint(bar.Load2(144+0)), asuint(bar.Load2(144+8)));
float b = asfloat(bar.Load(0+3u*16+0));
int a_1 = asint(bar.Load(0+(((NagaBufferLengthRW(bar) - 160) / 8) - 2u)*8+160));
int a_2 = asint(bar.Load(0+(((NagaBufferLengthRW(bar) - 160) / 8) - 2u)*8+160));
int2 c = asint(qux.Load2(0));
const float _e33 = read_from_private(foo);
c2_ = Constructarray5_int_(a_1, int(b), 3, 4, 5);
c2_ = Constructarray5_int_(a_2, int(b), 3, 4, 5);
c2_[min(uint((vi + 1u)), 4u)] = 42;
int value = c2_[min(uint(vi), 4u)];
int value_1 = c2_[min(uint(vi), 4u)];
const float _e47 = test_arr_as_arg(ZeroValuearray5_array10_float__());
return float4(mul(float4((value).xxxx), _matrix), 2.0);
return float4(mul(float4((value_1).xxxx), _matrix), 2.0);
}

int2 ZeroValueint2() {
Expand Down
Loading

0 comments on commit 00a89cb

Please sign in to comment.