diff --git a/naga/tests/in/abstract-types-function-calls.wgsl b/naga/tests/in/abstract-types-function-calls.wgsl index 9c3c28ef066..599a073f89b 100644 --- a/naga/tests/in/abstract-types-function-calls.wgsl +++ b/naga/tests/in/abstract-types-function-calls.wgsl @@ -14,25 +14,53 @@ fn func_au(a: array) {} fn func_f_i(a: f32, b: i32) {} +const const_af = 0; +const const_ai = 0; +const const_vec_af = vec2(0.0); +const const_vec_ai = vec2(0); +const const_mat_af = mat2x2(vec2(0.0), vec2(0.0)); +const const_arr_af = array(0.0, 0.0); +const const_arr_ai = array(0, 0); + fn main() { func_f(0.0); func_f(0); func_i(0); func_u(0); + func_f(const_af); + func_f(const_ai); + func_i(const_ai); + func_u(const_ai); + func_vf(vec2(0.0)); func_vf(vec2(0)); func_vi(vec2(0)); func_vu(vec2(0)); + func_vf(const_vec_af); + func_vf(const_vec_ai); + func_vi(const_vec_ai); + func_vu(const_vec_ai); + func_mf(mat2x2(vec2(0.0), vec2(0.0))); func_mf(mat2x2(vec2(0), vec2(0))); + func_mf(const_mat_af); + func_af(array(0.0, 0.0)); func_af(array(0, 0)); func_ai(array(0, 0)); func_au(array(0, 0)); + func_af(const_arr_af); + func_af(const_arr_ai); + func_ai(const_arr_ai); + func_au(const_arr_ai); + func_f_i(0.0, 0); func_f_i(0, 0); + + func_f_i(const_af, const_ai); + func_f_i(const_ai, const_ai); } diff --git a/naga/tests/in/abstract-types-return.wgsl b/naga/tests/in/abstract-types-return.wgsl index da77c129a06..d1c879f8a74 100644 --- a/naga/tests/in/abstract-types-return.wgsl +++ b/naga/tests/in/abstract-types-return.wgsl @@ -24,3 +24,8 @@ fn return_vec2f32_ai() -> vec2 { fn return_arrf32_ai() -> array { return array(1, 1, 1, 1); } + +const one = 1; +fn return_const_f32_const_ai() -> f32 { + return one; +} diff --git a/naga/tests/in/const_assert.wgsl b/naga/tests/in/const_assert.wgsl index 23f57fbb1a3..667676900f3 100644 --- a/naga/tests/in/const_assert.wgsl +++ b/naga/tests/in/const_assert.wgsl @@ -4,8 +4,13 @@ const y = 2; const_assert x < y; // valid at module-scope. const_assert(y != 0); // parentheses are optional. +// Ensure abstract-typed consts can be compared to different concrete types +const_assert x == 1i; +const_assert x > 0u; +const_assert x < 2.0f; + fn foo() { const z = x + y - 2; const_assert z > 0; // valid in functions. const_assert(z > 0); -} \ No newline at end of file +} diff --git a/naga/tests/out/glsl/abstract-types-return.main.Compute.glsl b/naga/tests/out/glsl/abstract-types-return.main.Compute.glsl index 07c75d7c518..45064258764 100644 --- a/naga/tests/out/glsl/abstract-types-return.main.Compute.glsl +++ b/naga/tests/out/glsl/abstract-types-return.main.Compute.glsl @@ -30,6 +30,10 @@ float[4] return_arrf32_ai() { return float[4](1.0, 1.0, 1.0, 1.0); } +float return_const_f32_const_ai() { + return 1.0; +} + void main() { return; } diff --git a/naga/tests/out/hlsl/abstract-types-return.hlsl b/naga/tests/out/hlsl/abstract-types-return.hlsl index fe2de29aee8..64ba1e51738 100644 --- a/naga/tests/out/hlsl/abstract-types-return.hlsl +++ b/naga/tests/out/hlsl/abstract-types-return.hlsl @@ -35,6 +35,11 @@ ret_return_arrf32_ai return_arrf32_ai() return Constructarray4_float_(1.0, 1.0, 1.0, 1.0); } +float return_const_f32_const_ai() +{ + return 1.0; +} + [numthreads(1, 1, 1)] void main() { diff --git a/naga/tests/out/msl/abstract-types-function-calls.msl b/naga/tests/out/msl/abstract-types-function-calls.msl index bf62d87a543..88ac95bea98 100644 --- a/naga/tests/out/msl/abstract-types-function-calls.msl +++ b/naga/tests/out/msl/abstract-types-function-calls.msl @@ -87,16 +87,31 @@ void main_( func_f(0.0); func_i(0); func_u(0u); + func_f(0.0); + func_f(0.0); + func_i(0); + func_u(0u); + func_vf(metal::float2(0.0)); + func_vf(metal::float2(0.0)); + func_vi(metal::int2(0)); + func_vu(metal::uint2(0u)); func_vf(metal::float2(0.0)); func_vf(metal::float2(0.0)); func_vi(metal::int2(0)); func_vu(metal::uint2(0u)); func_mf(metal::float2x2(metal::float2(0.0), metal::float2(0.0))); func_mf(metal::float2x2(metal::float2(0.0), metal::float2(0.0))); + func_mf(metal::float2x2(metal::float2(0.0), metal::float2(0.0))); func_af(type_7 {0.0, 0.0}); func_af(type_7 {0.0, 0.0}); func_ai(type_8 {0, 0}); func_au(type_9 {0u, 0u}); + func_af(type_7 {0.0, 0.0}); + func_af(type_7 {0.0, 0.0}); + func_ai(type_8 {0, 0}); + func_au(type_9 {0u, 0u}); + func_f_i(0.0, 0); + func_f_i(0.0, 0); func_f_i(0.0, 0); func_f_i(0.0, 0); return; diff --git a/naga/tests/out/msl/abstract-types-return.msl b/naga/tests/out/msl/abstract-types-return.msl index 99072e7473b..3d2ee03a67d 100644 --- a/naga/tests/out/msl/abstract-types-return.msl +++ b/naga/tests/out/msl/abstract-types-return.msl @@ -38,6 +38,11 @@ type_4 return_arrf32_ai( return type_4 {1.0, 1.0, 1.0, 1.0}; } +float return_const_f32_const_ai( +) { + return 1.0; +} + kernel void main_( ) { return; diff --git a/naga/tests/out/spv/abstract-types-function-calls.spvasm b/naga/tests/out/spv/abstract-types-function-calls.spvasm index 58e064bb4e4..29bdf1548a1 100644 --- a/naga/tests/out/spv/abstract-types-function-calls.spvasm +++ b/naga/tests/out/spv/abstract-types-function-calls.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 100 +; Bound: 115 OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" @@ -129,17 +129,32 @@ OpBranch %83 %85 = OpFunctionCall %2 %16 %73 %86 = OpFunctionCall %2 %21 %74 %87 = OpFunctionCall %2 %26 %75 -%88 = OpFunctionCall %2 %31 %76 -%89 = OpFunctionCall %2 %31 %76 -%90 = OpFunctionCall %2 %36 %77 -%91 = OpFunctionCall %2 %41 %78 -%92 = OpFunctionCall %2 %46 %79 -%93 = OpFunctionCall %2 %46 %79 -%94 = OpFunctionCall %2 %51 %80 -%95 = OpFunctionCall %2 %51 %80 -%96 = OpFunctionCall %2 %56 %81 -%97 = OpFunctionCall %2 %61 %82 -%98 = OpFunctionCall %2 %67 %73 %74 -%99 = OpFunctionCall %2 %67 %73 %74 +%88 = OpFunctionCall %2 %16 %73 +%89 = OpFunctionCall %2 %16 %73 +%90 = OpFunctionCall %2 %21 %74 +%91 = OpFunctionCall %2 %26 %75 +%92 = OpFunctionCall %2 %31 %76 +%93 = OpFunctionCall %2 %31 %76 +%94 = OpFunctionCall %2 %36 %77 +%95 = OpFunctionCall %2 %41 %78 +%96 = OpFunctionCall %2 %31 %76 +%97 = OpFunctionCall %2 %31 %76 +%98 = OpFunctionCall %2 %36 %77 +%99 = OpFunctionCall %2 %41 %78 +%100 = OpFunctionCall %2 %46 %79 +%101 = OpFunctionCall %2 %46 %79 +%102 = OpFunctionCall %2 %46 %79 +%103 = OpFunctionCall %2 %51 %80 +%104 = OpFunctionCall %2 %51 %80 +%105 = OpFunctionCall %2 %56 %81 +%106 = OpFunctionCall %2 %61 %82 +%107 = OpFunctionCall %2 %51 %80 +%108 = OpFunctionCall %2 %51 %80 +%109 = OpFunctionCall %2 %56 %81 +%110 = OpFunctionCall %2 %61 %82 +%111 = OpFunctionCall %2 %67 %73 %74 +%112 = OpFunctionCall %2 %67 %73 %74 +%113 = OpFunctionCall %2 %67 %73 %74 +%114 = OpFunctionCall %2 %67 %73 %74 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/abstract-types-return.spvasm b/naga/tests/out/spv/abstract-types-return.spvasm index 8ce671adfc0..4341b27b2fc 100644 --- a/naga/tests/out/spv/abstract-types-return.spvasm +++ b/naga/tests/out/spv/abstract-types-return.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 41 +; Bound: 44 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %38 "main" -OpExecutionMode %38 LocalSize 1 1 1 +OpEntryPoint GLCompute %41 "main" +OpExecutionMode %41 LocalSize 1 1 1 OpDecorate %7 ArrayStride 4 %2 = OpTypeVoid %3 = OpTypeInt 32 1 @@ -25,7 +25,7 @@ OpDecorate %7 ArrayStride 4 %30 = OpConstantComposite %6 %22 %22 %34 = OpTypeFunction %7 %35 = OpConstantComposite %7 %22 %22 %22 %22 -%39 = OpTypeFunction %2 +%42 = OpTypeFunction %2 %10 = OpFunction %3 None %11 %9 = OpLabel OpBranch %13 @@ -62,9 +62,15 @@ OpBranch %36 %36 = OpLabel OpReturnValue %35 OpFunctionEnd -%38 = OpFunction %2 None %39 +%38 = OpFunction %5 None %21 %37 = OpLabel -OpBranch %40 +OpBranch %39 +%39 = OpLabel +OpReturnValue %22 +OpFunctionEnd +%41 = OpFunction %2 None %42 %40 = OpLabel +OpBranch %43 +%43 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/abstract-types-function-calls.wgsl b/naga/tests/out/wgsl/abstract-types-function-calls.wgsl index 419125bc6b6..1bc290cd39e 100644 --- a/naga/tests/out/wgsl/abstract-types-function-calls.wgsl +++ b/naga/tests/out/wgsl/abstract-types-function-calls.wgsl @@ -47,16 +47,31 @@ fn main() { func_f(0f); func_i(0i); func_u(0u); + func_f(0f); + func_f(0f); + func_i(0i); + func_u(0u); + func_vf(vec2(0f)); + func_vf(vec2(0f)); + func_vi(vec2(0i)); + func_vu(vec2(0u)); func_vf(vec2(0f)); func_vf(vec2(0f)); func_vi(vec2(0i)); func_vu(vec2(0u)); func_mf(mat2x2(vec2(0f), vec2(0f))); func_mf(mat2x2(vec2(0f), vec2(0f))); + func_mf(mat2x2(vec2(0f), vec2(0f))); func_af(array(0f, 0f)); func_af(array(0f, 0f)); func_ai(array(0i, 0i)); func_au(array(0u, 0u)); + func_af(array(0f, 0f)); + func_af(array(0f, 0f)); + func_ai(array(0i, 0i)); + func_au(array(0u, 0u)); + func_f_i(0f, 0i); + func_f_i(0f, 0i); func_f_i(0f, 0i); func_f_i(0f, 0i); return; diff --git a/naga/tests/out/wgsl/abstract-types-return.wgsl b/naga/tests/out/wgsl/abstract-types-return.wgsl index c25a217dacc..6c5b60224b3 100644 --- a/naga/tests/out/wgsl/abstract-types-return.wgsl +++ b/naga/tests/out/wgsl/abstract-types-return.wgsl @@ -22,6 +22,10 @@ fn return_arrf32_ai() -> array { return array(1f, 1f, 1f, 1f); } +fn return_const_f32_const_ai() -> f32 { + return 1f; +} + @compute @workgroup_size(1, 1, 1) fn main() { return;