Skip to content

Commit

Permalink
Add test for using local const in types
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
  • Loading branch information
sagudev committed Feb 18, 2025
1 parent 68b0fd5 commit 64a0038
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 142 deletions.
6 changes: 6 additions & 0 deletions naga/tests/in/const-exprs.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fn main() {
splat_of_constant();
compose_of_constant();
compose_of_splat();
test_local_const();
}

// Swizzle the value of nested Compose expressions.
Expand Down Expand Up @@ -109,3 +110,8 @@ fn relational() {
var vec_all_false = all(vec4(vec3(vec2<bool>(), TRUE), false));
var vec_all_true = all(vec4(true));
}

fn test_local_const() {
const local_const = 2;
var arr: array<f32, local_const>;
}
6 changes: 6 additions & 0 deletions naga/tests/out/glsl/const-exprs.main.Compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void compose_of_splat() {
return;
}

void test_local_const() {
float arr[2] = float[2](0.0, 0.0);
return;
}

uint map_texture_kind(int texture_kind) {
switch(texture_kind) {
case 0: {
Expand Down Expand Up @@ -115,6 +120,7 @@ void main() {
splat_of_constant();
compose_of_constant();
compose_of_splat();
test_local_const();
return;
}

8 changes: 8 additions & 0 deletions naga/tests/out/hlsl/const-exprs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ void compose_of_splat()
return;
}

void test_local_const()
{
float arr[2] = (float[2])0;

return;
}

uint map_texture_kind(int texture_kind)
{
switch(texture_kind) {
Expand Down Expand Up @@ -128,5 +135,6 @@ void main()
splat_of_constant();
compose_of_constant();
compose_of_splat();
test_local_const();
return;
}
10 changes: 10 additions & 0 deletions naga/tests/out/msl/const-exprs.msl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

using metal::uint;

struct type_6 {
float inner[2];
};
constant uint TWO = 2u;
constant int THREE = 3;
constant bool TRUE = true;
Expand Down Expand Up @@ -76,6 +79,12 @@ void compose_of_splat(
return;
}

void test_local_const(
) {
type_6 arr = {};
return;
}

uint map_texture_kind(
int texture_kind
) {
Expand Down Expand Up @@ -125,5 +134,6 @@ kernel void main_(
splat_of_constant();
compose_of_constant();
compose_of_splat();
test_local_const();
return;
}
Loading

0 comments on commit 64a0038

Please sign in to comment.