summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-24 10:01:47 -0800
committerGitHub <noreply@github.com>2023-02-24 10:01:47 -0800
commitbd6306cdaa4a49344658bd026721b6532e103d09 (patch)
treebb7f666d426e6cfc7777a3ccac0a1d628588eb39 /tests
parente8c08e7ecb1124f115a1d1042277776193122b57 (diff)
More control flow simplifications. (#2673)
* More control flow and Phi param simplifications. * Fix. * Fix gcc error. * Fix. * More IR cleanup. * Fix bug in phi param dce + ifelse simplify. * Propagate and DCE side-effect-free functions. * Enhance CFG simplifcation to remove loops with no side effects. * Fix. * Fixes. * Fix tests. Add [__AlwaysFoldIntoUseSite] for rayPayloadLocation. * More cleanup. * Fixes. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/sample-grad-clamp-lod.slang.glsl6
-rw-r--r--tests/bugs/vk-structured-buffer-load.hlsl.glsl27
-rw-r--r--tests/cross-compile/array-of-buffers.slang.glsl20
-rw-r--r--tests/cross-compile/array-of-buffers.slang.hlsl20
-rw-r--r--tests/cross-compile/glsl-generic-in.slang.glsl12
-rw-r--r--tests/cross-compile/half-conversion.slang.glsl29
-rw-r--r--tests/cross-compile/sign.slang.glsl9
-rw-r--r--tests/diagnostics/interfaces/anyvalue-size-validation.slang4
-rw-r--r--tests/experimental/liveness/liveness-2.slang.expected5
-rw-r--r--tests/experimental/liveness/liveness-3.slang.expected81
-rw-r--r--tests/experimental/liveness/liveness-4.slang.expected19
-rw-r--r--tests/experimental/liveness/liveness-5.slang.expected23
-rw-r--r--tests/experimental/liveness/liveness-6.slang.expected31
-rw-r--r--tests/experimental/liveness/liveness.slang.expected77
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected20
-rw-r--r--tests/hlsl-intrinsic/vector-float.slang50
-rw-r--r--tests/ir/loop-dce.slang40
-rw-r--r--tests/ir/loop-dce.slang.expected.txt4
-rw-r--r--tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl84
-rw-r--r--tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl14
-rw-r--r--tests/pipeline/rasterization/mesh/passing-outputs.slang.glsl6
-rw-r--r--tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl3
-rw-r--r--tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl36
-rw-r--r--tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl157
-rw-r--r--tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl15
-rw-r--r--tests/vkray/anyhit.slang.glsl21
-rw-r--r--tests/vkray/callable-caller.slang.glsl23
-rw-r--r--tests/vkray/raygen.slang.glsl42
28 files changed, 360 insertions, 518 deletions
diff --git a/tests/bugs/sample-grad-clamp-lod.slang.glsl b/tests/bugs/sample-grad-clamp-lod.slang.glsl
index b91fb8668..a49983599 100644
--- a/tests/bugs/sample-grad-clamp-lod.slang.glsl
+++ b/tests/bugs/sample-grad-clamp-lod.slang.glsl
@@ -20,10 +20,10 @@ rayPayloadInEXT ShadowRay_0 _S1;
void main()
{
- vec4 val_0 = (textureGradOffsetClampARB(sampler2DArray(t2D_0,samplerState_0), (vec3(_S1.hitDistance_0 * 0.20000000000000001110, _S1.hitDistance_0 * 0.29999999999999998890, 0.20000000000000001110)), (vec2(float(0), float(0))), (vec2(float(0), float(0))), (ivec2(0)), (0.50000000000000000000)));
+ const vec2 _S2 = vec2(0.0, 0.0);
- float _S2 = dot(val_0, val_0);
+ vec4 val_0 = (textureGradOffsetClampARB(sampler2DArray(t2D_0,samplerState_0), (vec3(_S1.hitDistance_0 * 0.20000000298023223877, _S1.hitDistance_0 * 0.30000001192092895508, 0.20000000298023223877)), (_S2), (_S2), (ivec2(0)), (0.5)));
- _S1.hitDistance_0 = _S2;
+ _S1.hitDistance_0 = dot(val_0, val_0);
return;
}
diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl
index 7f3ec40a2..1d056944a 100644
--- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl
+++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl
@@ -1,15 +1,10 @@
-// vk-structured-buffer-load.hlsl.glsl
-//TEST_IGNORE_FILE:
-
#version 460
#extension GL_NV_ray_tracing : require
layout(row_major) uniform;
layout(row_major) buffer;
-
layout(std430, binding = 1) readonly buffer _S1 {
float _data[];
} gParamBlock_sbuf_0;
-
float rcp_0(float x_0)
{
float _S2 = 1.0 / x_0;
@@ -36,37 +31,21 @@ void main()
_S3.PackedHitInfoA_0.x = HitT_0;
float offsfloat_0 = ((gParamBlock_sbuf_0)._data[(0)]);
-
uint use_rcp_0 = 0U | uint(HitT_0 > 0.0);
-
if(use_rcp_0 != 0U)
{
-
- float _S5 = rcp_0(offsfloat_0);
-
- _S3.PackedHitInfoA_0.y = _S5;
-
+ _S3.PackedHitInfoA_0.y = rcp_0(offsfloat_0);
}
else
{
-
if(use_rcp_0 > 0U&&offsfloat_0 == 0.0)
{
-
- float _S6 = (inversesqrt((offsfloat_0 + 1.0)));
-
- _S3.PackedHitInfoA_0.y = _S6;
-
+ _S3.PackedHitInfoA_0.y = (inversesqrt((offsfloat_0 + 1.0)));
}
else
{
- float _S7 = (inversesqrt((offsfloat_0)));
-
- _S3.PackedHitInfoA_0.y = _S7;
-
+ _S3.PackedHitInfoA_0.y = (inversesqrt((offsfloat_0)));
}
-
}
-
return;
}
diff --git a/tests/cross-compile/array-of-buffers.slang.glsl b/tests/cross-compile/array-of-buffers.slang.glsl
index 1f436fad0..21961afd1 100644
--- a/tests/cross-compile/array-of-buffers.slang.glsl
+++ b/tests/cross-compile/array-of-buffers.slang.glsl
@@ -1,8 +1,6 @@
-//TEST_IGNORE_FILE:
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
-
struct SLANG_ParameterGroup_C_0
{
uint index_0;
@@ -13,7 +11,6 @@ layout(std140) uniform _S1
{
SLANG_ParameterGroup_C_0 _data;
} C_0;
-
struct S_0
{
vec4 f_0;
@@ -24,31 +21,26 @@ layout(std140) uniform _S2
{
S_0 _data;
} cb_0[3];
-
layout(std430, binding = 2) readonly buffer _S3 {
S_0 _data[];
} sb1_0[4];
-
layout(std430, binding = 3) buffer _S4 {
vec4 _data[];
} sb2_0[5];
-
layout(std430, binding = 4) readonly buffer _S5
{
uint _data[];
} bb_0[6];
-
layout(location = 0)
out vec4 _S6;
void main()
{
- S_0 _S7 = ((sb1_0[C_0._data.index_0])._data[(C_0._data.index_0)]);
- vec4 _S8 = cb_0[C_0._data.index_0]._data.f_0 + _S7.f_0;
- vec4 _S9 = _S8 + ((sb2_0[C_0._data.index_0])._data[(C_0._data.index_0)]);
- uint _S10 = ((bb_0[C_0._data.index_0])._data[(int(C_0._data.index_0 * 4U))/4]);
-
- _S6 = _S9 + vec4(float(_S10));
-
+ vec4 _S7 = cb_0[C_0._data.index_0]._data.f_0;
+ S_0 _S8 = ((sb1_0[C_0._data.index_0])._data[(C_0._data.index_0)]);
+ vec4 _S9 = _S7 + _S8.f_0;
+ vec4 _S10 = _S9 + ((sb2_0[C_0._data.index_0])._data[(C_0._data.index_0)]);
+ uint _S11 = ((bb_0[C_0._data.index_0])._data[(int(C_0._data.index_0 * 4U))/4]);
+ _S6 = _S10 + vec4(float(_S11));
return;
}
diff --git a/tests/cross-compile/array-of-buffers.slang.hlsl b/tests/cross-compile/array-of-buffers.slang.hlsl
index 501b9c6db..960957789 100644
--- a/tests/cross-compile/array-of-buffers.slang.hlsl
+++ b/tests/cross-compile/array-of-buffers.slang.hlsl
@@ -1,5 +1,3 @@
-//TEST_IGNORE_FILE:
-
#pragma pack_matrix(column_major)
#ifdef SLANG_HLSL_ENABLE_NVAPI
#include "nvHLSLExtns.h"
@@ -15,24 +13,24 @@ cbuffer C_0 : register(b0)
{
SLANG_ParameterGroup_C_0 C_0;
}
-
struct S_0
{
float4 f_0;
};
ConstantBuffer<S_0 > cb_0[int(3)] : register(b1);
+
StructuredBuffer<S_0 > sb1_0[int(4)] : register(t0);
+
RWStructuredBuffer<float4 > sb2_0[int(5)] : register(u0);
-ByteAddressBuffer bb_0[int(6)] : register(t4);
+ByteAddressBuffer bb_0[int(6)] : register(t4);
float4 main() : SV_TARGET
{
- S_0 _S1 = sb1_0[C_0.index_0][C_0.index_0];
-
- float4 _S2 = cb_0[C_0.index_0].f_0 + _S1.f_0;
- float4 _S3 = _S2 + sb2_0[C_0.index_0][C_0.index_0];
- uint _S4 = bb_0[C_0.index_0].Load(int(C_0.index_0 * 4U));
-
- return _S3 + (float4)float(_S4);
+ float4 _S1 = cb_0[C_0.index_0].f_0;
+ S_0 _S2 = sb1_0[C_0.index_0][C_0.index_0];
+ float4 _S3 = _S1 + _S2.f_0;
+ float4 _S4 = _S3 + sb2_0[C_0.index_0][C_0.index_0];
+ uint _S5 = bb_0[C_0.index_0].Load(int(C_0.index_0 * 4U));
+ return _S4 + (float4)float(_S5);
}
diff --git a/tests/cross-compile/glsl-generic-in.slang.glsl b/tests/cross-compile/glsl-generic-in.slang.glsl
index c8d9b1bd1..4bf0598d0 100644
--- a/tests/cross-compile/glsl-generic-in.slang.glsl
+++ b/tests/cross-compile/glsl-generic-in.slang.glsl
@@ -1,8 +1,6 @@
-//TEST_IGNORE_FILE:
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
-
struct F_0
{
vec4 v0_0;
@@ -14,10 +12,9 @@ float F_get_0(F_0 this_0)
return this_0.v0_0.x + this_0.v1_0.x;
}
-
float E_get_0()
{
- return 1.00000000000000000000;
+ return 1.0;
}
layout(location = 0)
@@ -33,14 +30,11 @@ struct VOut_0
{
vec4 projPos_0;
};
-
void main()
{
F_0 _S4 = { _S2, _S3 };
VOut_0 vout_0;
- float _S5 = F_get_0(_S4);
- float _S6 = E_get_0();
- vout_0.projPos_0 = vec4(_S1, _S5 + _S6);
+ vout_0.projPos_0 = vec4(_S1, F_get_0(_S4) + E_get_0());
gl_Position = vout_0.projPos_0;
return;
-} \ No newline at end of file
+}
diff --git a/tests/cross-compile/half-conversion.slang.glsl b/tests/cross-compile/half-conversion.slang.glsl
index 58d20b4fc..fb51809b4 100644
--- a/tests/cross-compile/half-conversion.slang.glsl
+++ b/tests/cross-compile/half-conversion.slang.glsl
@@ -1,8 +1,6 @@
-//half-conversion.slang.glsl
-//TEST_IGNORE_FILE:
-
#version 450
-
+layout(row_major) uniform;
+layout(row_major) buffer;
struct SLANG_ParameterGroup_C_0
{
uvec4 u_0;
@@ -13,29 +11,30 @@ layout(std140) uniform _S1
{
SLANG_ParameterGroup_C_0 _data;
} C_0;
-
vec4 f16tof32_0(uvec4 value_0)
{
vec4 result_0;
- int i_0;
- i_0 = 0;
+ int i_0 = 0;
for(;;)
{
- if(i_0 < 4) {} else break;
-
- float _S2 = (unpackHalf2x16((value_0[i_0])).x);
- result_0[i_0] = _S2;
- i_0 = i_0 + int(1);
+ if(i_0 < 4)
+ {
+ }
+ else
+ {
+ break;
+ }
+ result_0[i_0] = (unpackHalf2x16((value_0[i_0])).x);
+ i_0 = i_0 + 1;
}
return result_0;
}
layout(location = 0)
-out vec4 _S3;
+out vec4 _S2;
void main()
{
- vec4 _S4 = f16tof32_0(C_0._data.u_0);
- _S3 = _S4;
+ _S2 = f16tof32_0(C_0._data.u_0);
return;
}
diff --git a/tests/cross-compile/sign.slang.glsl b/tests/cross-compile/sign.slang.glsl
index 7a3a37c51..44c015967 100644
--- a/tests/cross-compile/sign.slang.glsl
+++ b/tests/cross-compile/sign.slang.glsl
@@ -1,17 +1,12 @@
-//TEST_IGNORE_FILE:
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
-#line 8 0
layout(location = 0)
out vec4 _S1;
-
-#line 8
void main()
{
- ivec4 _S2 = ivec4(sign(vec4(1.50000000000000000000, 1.00000000000000000000, -1.50000000000000000000, -1.00000000000000000000)));
- _S1 = vec4(_S2);
+ _S1 = vec4((ivec4(sign((vec4(1.5, 1.0, -1.5, -1.0))))));
return;
-} \ No newline at end of file
+}
diff --git a/tests/diagnostics/interfaces/anyvalue-size-validation.slang b/tests/diagnostics/interfaces/anyvalue-size-validation.slang
index 6c33b72a9..1ebf7f4c3 100644
--- a/tests/diagnostics/interfaces/anyvalue-size-validation.slang
+++ b/tests/diagnostics/interfaces/anyvalue-size-validation.slang
@@ -21,9 +21,11 @@ T test<T:IInterface>(T s)
return s;
}
+RWStructuredBuffer<uint> output;
+
[numthreads(4, 1, 1)]
void main()
{
S s;
- test(s);
+ output[0] = test(s).a;
} \ No newline at end of file
diff --git a/tests/experimental/liveness/liveness-2.slang.expected b/tests/experimental/liveness/liveness-2.slang.expected
index c742fa1fc..16883c1fd 100644
--- a/tests/experimental/liveness/liveness-2.slang.expected
+++ b/tests/experimental/liveness/liveness-2.slang.expected
@@ -51,9 +51,8 @@ layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
void main()
{
int index_0 = int(gl_GlobalInvocationID.x);
- uint _S4 = uint(index_0);
- int _S5 = calcThing_0(index_0);
- ((outputBuffer_0)._data[(_S4)]) = _S5;
+ int _S4 = calcThing_0(index_0);
+ ((outputBuffer_0)._data[(uint(index_0))]) = _S4;
return;
}
diff --git a/tests/experimental/liveness/liveness-3.slang.expected b/tests/experimental/liveness/liveness-3.slang.expected
index 4dff6b37a..cb093a640 100644
--- a/tests/experimental/liveness/liveness-3.slang.expected
+++ b/tests/experimental/liveness/liveness-3.slang.expected
@@ -53,12 +53,15 @@ int calcThing_0(int offset_0)
idx_0[0] = 0;
idx_0[1] = 0;
idx_0[2] = 0;
+ int _S2 = (k_0 + 7) % 5;
+ bool _S3 = _S2 == 4;
+ int k_1 = k_0 + 1;
int i_0;
livenessStart_1(i_0, 0);
i_0 = 0;
- int _S2;
- livenessStart_1(_S2, 0);
- _S2 = _S1;
+ int _S4;
+ livenessStart_1(_S4, 0);
+ _S4 = _S1;
for(;;)
{
if(i_0 < 17)
@@ -70,74 +73,74 @@ int calcThing_0(int offset_0)
}
int modRange_0 = i_0 % 3;
another_0[i_0 & 1] = another_0[i_0 & 1] + modRange_0;
- int _S3 = i_0 % 3;
- int _S4;
- if(_S3 != 0)
+ int _S5 = i_0 % 3;
+ int _S6;
+ if(modRange_0 != 0)
{
- int _S5 = _S2;
- livenessEnd_0(_S2, 0);
- int _S6 = _S5 + 1;
- livenessStart_1(_S4, 0);
- _S4 = _S6;
+ int _S7 = _S4;
+ livenessEnd_0(_S4, 0);
+ int _S8 = _S7 + 1;
+ livenessStart_1(_S6, 0);
+ _S6 = _S8;
}
else
{
- int _S7 = _S2;
- livenessEnd_0(_S2, 0);
- livenessStart_1(_S4, 0);
- _S4 = _S7;
+ int _S9 = _S4;
+ livenessEnd_0(_S4, 0);
+ livenessStart_1(_S6, 0);
+ _S6 = _S9;
}
- idx_0[modRange_0] = idx_0[modRange_0] + (_S4 + i_0);
+ idx_0[modRange_0] = idx_0[modRange_0] + (_S6 + i_0);
i_0 = i_0 + 1;
- livenessStart_1(_S2, 0);
- int _S8 = _S4;
- livenessEnd_0(_S4, 0);
- _S2 = _S8;
+ livenessStart_1(_S4, 0);
+ int _S10 = _S6;
+ livenessEnd_0(_S6, 0);
+ _S4 = _S10;
}
livenessEnd_0(i_0, 0);
livenessEnd_0(_S1, 0);
- int _S9 = (k_0 + 7) % 5;
- if(_S9 == 4)
+ livenessEnd_0(k_0, 0);
+ if(_S3)
{
- livenessEnd_0(_S2, 0);
+ livenessEnd_0(_S4, 0);
livenessEnd_1(idx_0, 0);
- livenessEnd_0(k_0, 0);
livenessEnd_2(another_0, 0);
return total_0;
}
- int _S10 = idx_0[0] + idx_0[1];
- int _S11 = idx_0[2];
+ int _S11 = idx_0[0] + idx_0[1];
+ int _S12 = idx_0[2];
livenessEnd_1(idx_0, 0);
- int _S12 = _S10 + _S11;
- int _S13 = total_0;
+ int _S13 = _S11 + _S12;
+ int _S14 = total_0;
livenessEnd_0(total_0, 0);
- int total_1 = _S13 + _S12;
- k_0 = k_0 + 1;
+ int total_1 = _S14 + _S13;
+ livenessStart_1(k_0, 0);
+ k_0 = k_1;
livenessStart_1(_S1, 0);
- int _S14 = _S2;
- livenessEnd_0(_S2, 0);
- _S1 = _S14;
+ int _S15 = _S4;
+ livenessEnd_0(_S4, 0);
+ _S1 = _S15;
livenessStart_1(total_0, 0);
total_0 = total_1;
}
livenessEnd_0(_S1, 0);
livenessEnd_0(k_0, 0);
livenessEnd_2(another_0, 0);
- int _S15 = total_0;
+ int _S16 = total_0;
livenessEnd_0(total_0, 0);
- return - _S15;
+ return - _S16;
}
-layout(std430, binding = 0) buffer _S16 {
+layout(std430, binding = 0) buffer _S17 {
int _data[];
} outputBuffer_0;
layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
void main()
{
int index_0 = int(gl_GlobalInvocationID.x);
- uint _S17 = uint(index_0);
- int _S18 = calcThing_0(index_0);
- ((outputBuffer_0)._data[(_S17)]) = _S18;
+ uint _S18 = uint(index_0);
+ int _S19 = calcThing_0(index_0);
+ ((outputBuffer_0)._data[(_S18)]) = _S19;
return;
}
diff --git a/tests/experimental/liveness/liveness-4.slang.expected b/tests/experimental/liveness/liveness-4.slang.expected
index cd97f8057..efc2e3846 100644
--- a/tests/experimental/liveness/liveness-4.slang.expected
+++ b/tests/experimental/liveness/liveness-4.slang.expected
@@ -36,6 +36,9 @@ int calcThing_0(int offset_0)
{
break;
}
+ int _S1 = (k_0 + 7) % 5;
+ bool _S2 = _S1 == 4;
+ int k_1 = k_0 + 1;
int i_0;
livenessStart_1(i_0, 0);
i_0 = 0;
@@ -52,30 +55,30 @@ int calcThing_0(int offset_0)
i_0 = i_0 + 1;
}
livenessEnd_0(i_0, 0);
- int _S1 = (k_0 + 7) % 5;
- if(_S1 == 4)
+ livenessEnd_0(k_0, 0);
+ if(_S2)
{
- livenessEnd_0(k_0, 0);
livenessEnd_1(another_0, 0);
return 1;
}
- k_0 = k_0 + 1;
+ livenessStart_1(k_0, 0);
+ k_0 = k_1;
}
livenessEnd_0(k_0, 0);
livenessEnd_1(another_0, 0);
return -2;
}
-layout(std430, binding = 0) buffer _S2 {
+layout(std430, binding = 0) buffer _S3 {
int _data[];
} outputBuffer_0;
layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
void main()
{
int index_0 = int(gl_GlobalInvocationID.x);
- uint _S3 = uint(index_0);
- int _S4 = calcThing_0(index_0);
- ((outputBuffer_0)._data[(_S3)]) = _S4;
+ uint _S4 = uint(index_0);
+ int _S5 = calcThing_0(index_0);
+ ((outputBuffer_0)._data[(_S4)]) = _S5;
return;
}
diff --git a/tests/experimental/liveness/liveness-5.slang.expected b/tests/experimental/liveness/liveness-5.slang.expected
index 3693d3fde..e9fe9d652 100644
--- a/tests/experimental/liveness/liveness-5.slang.expected
+++ b/tests/experimental/liveness/liveness-5.slang.expected
@@ -39,6 +39,9 @@ int calcThing_0(int offset_0)
{
break;
}
+ int _S1 = (k_0 + 7) % 5;
+ bool _S2 = _S1 == 4;
+ int k_1 = k_0 + 1;
int i_0;
livenessStart_1(i_0, 0);
i_0 = 0;
@@ -55,17 +58,17 @@ int calcThing_0(int offset_0)
i_0 = i_0 + 1;
}
livenessEnd_0(i_0, 0);
- int _S1 = total_0;
+ livenessEnd_0(k_0, 0);
+ int _S3 = total_0;
livenessEnd_0(total_0, 0);
- int total_1 = _S1 + another_0[k_0 & 1];
- int _S2 = (k_0 + 7) % 5;
- if(_S2 == 4)
+ int total_1 = _S3 + another_0[k_0 & 1];
+ if(_S2)
{
- livenessEnd_0(k_0, 0);
livenessEnd_1(another_0, 0);
return 1;
}
- k_0 = k_0 + 1;
+ livenessStart_1(k_0, 0);
+ k_0 = k_1;
livenessStart_1(total_0, 0);
total_0 = total_1;
}
@@ -81,16 +84,16 @@ int calcThing_0(int offset_0)
return total_0;
}
-layout(std430, binding = 0) buffer _S3 {
+layout(std430, binding = 0) buffer _S4 {
int _data[];
} outputBuffer_0;
layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
void main()
{
int index_0 = int(gl_GlobalInvocationID.x);
- uint _S4 = uint(index_0);
- int _S5 = calcThing_0(index_0);
- ((outputBuffer_0)._data[(_S4)]) = _S5;
+ uint _S5 = uint(index_0);
+ int _S6 = calcThing_0(index_0);
+ ((outputBuffer_0)._data[(_S5)]) = _S6;
return;
}
diff --git a/tests/experimental/liveness/liveness-6.slang.expected b/tests/experimental/liveness/liveness-6.slang.expected
index 9c3bae815..b661c09bf 100644
--- a/tests/experimental/liveness/liveness-6.slang.expected
+++ b/tests/experimental/liveness/liveness-6.slang.expected
@@ -43,6 +43,10 @@ int calcThing_0(int offset_0)
livenessStart_0(arr_0, 0);
arr_0[0] = 2;
arr_0[1] = 3;
+ int _S1 = k_0 & 1;
+ int _S2 = (k_0 + 7) % 5;
+ bool _S3 = _S2 == 4;
+ int k_1 = k_0 + 1;
int i_0;
livenessStart_1(i_0, 0);
i_0 = 0;
@@ -56,25 +60,24 @@ int calcThing_0(int offset_0)
break;
}
another_0[i_0 & 1] = another_0[i_0 & 1] + (k_0 + i_0);
- arr_0[k_0 & 1] = arr_0[k_0 & 1] + i_0;
+ arr_0[_S1] = arr_0[_S1] + i_0;
i_0 = i_0 + 1;
}
livenessEnd_0(i_0, 0);
- int _S1 = k_0 & 1;
- int _S2 = total_0;
+ livenessEnd_0(k_0, 0);
+ int _S4 = total_0;
livenessEnd_0(total_0, 0);
- int total_1 = _S2 + another_0[_S1];
- int _S3 = arr_0[_S1];
+ int total_1 = _S4 + another_0[_S1];
+ int _S5 = arr_0[_S1];
livenessEnd_1(arr_0, 0);
- int total_2 = total_1 + _S3;
- int _S4 = (k_0 + 7) % 5;
- if(_S4 == 4)
+ int total_2 = total_1 + _S5;
+ if(_S3)
{
- livenessEnd_0(k_0, 0);
livenessEnd_1(another_0, 0);
return 1;
}
- k_0 = k_0 + 1;
+ livenessStart_1(k_0, 0);
+ k_0 = k_1;
livenessStart_1(total_0, 0);
total_0 = total_2;
}
@@ -90,16 +93,16 @@ int calcThing_0(int offset_0)
return total_0;
}
-layout(std430, binding = 0) buffer _S5 {
+layout(std430, binding = 0) buffer _S6 {
int _data[];
} outputBuffer_0;
layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
void main()
{
int index_0 = int(gl_GlobalInvocationID.x);
- uint _S6 = uint(index_0);
- int _S7 = calcThing_0(index_0);
- ((outputBuffer_0)._data[(_S6)]) = _S7;
+ uint _S7 = uint(index_0);
+ int _S8 = calcThing_0(index_0);
+ ((outputBuffer_0)._data[(_S7)]) = _S8;
return;
}
diff --git a/tests/experimental/liveness/liveness.slang.expected b/tests/experimental/liveness/liveness.slang.expected
index 4a81b8855..06809ffc3 100644
--- a/tests/experimental/liveness/liveness.slang.expected
+++ b/tests/experimental/liveness/liveness.slang.expected
@@ -21,6 +21,7 @@ void livenessEnd_1(spirv_by_reference int _0, spirv_literal int _1);
int someSlowFunc_0(int a_0)
{
uint _S1 = uint(a_0);
+ int _S2 = a_0 * 20;
uint v_0;
livenessStart_0(v_0, 0);
v_0 = _S1;
@@ -29,20 +30,20 @@ int someSlowFunc_0(int a_0)
i_0 = 0;
for(;;)
{
- if(i_0 < a_0 * 20)
+ if(i_0 < _S2)
{
}
else
{
break;
}
- uint _S2 = v_0 >> 1;
- uint _S3 = v_0;
+ uint _S3 = v_0 >> 1;
+ uint _S4 = v_0;
livenessEnd_0(v_0, 0);
- uint _S4 = (_S2 | _S3 << 31) * uint(i_0);
+ uint _S5 = (_S3 | _S4 << 31) * uint(i_0);
int i_1 = i_0 + 1;
livenessStart_0(v_0, 0);
- v_0 = _S4;
+ v_0 = _S5;
i_0 = i_1;
}
livenessEnd_1(i_0, 0);
@@ -58,12 +59,12 @@ struct SomeStruct_0
SomeStruct_0 makeSomeStruct_0()
{
- const int _S5[100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- SomeStruct_0 s_0 = { 0, 0, _S5 };
+ const int _S6[100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ SomeStruct_0 s_0 = { 0, 0, _S6 };
return s_0;
}
-layout(std430, binding = 1) buffer _S6 {
+layout(std430, binding = 1) buffer _S7 {
int _data[];
} anotherBuffer_0;
int doThing_0(SomeStruct_0 s_1)
@@ -73,11 +74,12 @@ int doThing_0(SomeStruct_0 s_1)
int somethingElse_0(inout SomeStruct_0 s_2)
{
- s_2.x_0 = s_2.x_0 + 1;
- return s_2.x_0;
+ int _S8 = s_2.x_0 + 1;
+ s_2.x_0 = _S8;
+ return _S8;
}
-layout(std430, binding = 0) buffer _S7 {
+layout(std430, binding = 0) buffer _S9 {
int _data[];
} outputBuffer_0;
spirv_instruction(id = 256)
@@ -90,6 +92,12 @@ layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
void main()
{
int index_0 = int(gl_GlobalInvocationID.x);
+ const int _S10[100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ int _S11 = index_0 & 7;
+ SomeStruct_0 _S12 = makeSomeStruct_0();
+ int v_1 = someSlowFunc_0(index_0);
+ bool _S13 = (v_1 & 256) != 0;
+ int _S14 = v_1 & 3;
int i_2;
livenessStart_1(i_2, 0);
i_2 = 0;
@@ -105,23 +113,20 @@ void main()
{
break;
}
- int v_1 = someSlowFunc_0(index_0);
SomeStruct_0 s_3;
livenessStart_2(s_3, 0);
SomeStruct_0 t_0;
livenessStart_2(t_0, 0);
- SomeStruct_0 _S8 = makeSomeStruct_0();
- t_0 = _S8;
- const int _S9[100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ t_0 = _S12;
SomeStruct_0 u_0;
- if((v_1 & 256) != 0)
+ if(_S13)
{
- s_3.x_0 = ((anotherBuffer_0)._data[(uint(v_1 & 3))]);
- t_0.x_0 = ((anotherBuffer_0)._data[(uint(v_1 & 3))]);
+ s_3.x_0 = ((anotherBuffer_0)._data[(uint(_S14))]);
+ t_0.x_0 = ((anotherBuffer_0)._data[(uint(_S14))]);
livenessStart_2(u_0, 0);
u_0.a_1 = 0;
u_0.x_0 = 0;
- u_0.c_0 = _S9;
+ u_0.c_0 = _S10;
}
else
{
@@ -129,37 +134,35 @@ void main()
livenessStart_2(x_1, 0);
x_1.a_1 = 0;
x_1.x_0 = 0;
- x_1.c_0 = _S9;
- x_1.x_0 = ((anotherBuffer_0)._data[(uint(v_1 & 3))]) + 1;
- SomeStruct_0 _S10 = x_1;
+ x_1.c_0 = _S10;
+ x_1.x_0 = ((anotherBuffer_0)._data[(uint(_S14))]) + 1;
+ SomeStruct_0 _S15 = x_1;
livenessEnd_2(x_1, 0);
livenessStart_2(u_0, 0);
- u_0 = _S10;
+ u_0 = _S15;
}
- s_3.c_0[index_0 & 7] = s_3.c_0[index_0 & 7] + 1;
- int _S11 = s_3.x_0 + t_0.x_0;
- SomeStruct_0 _S12 = u_0;
+ s_3.c_0[_S11] = s_3.c_0[_S11] + 1;
+ int _S16 = s_3.x_0 + t_0.x_0;
+ SomeStruct_0 _S17 = u_0;
livenessEnd_2(u_0, 0);
- int _S13 = _S11 + _S12.x_0;
- int _S14 = doThing_0(t_0);
- int _S15 = _S13 + _S14;
- int _S16 = somethingElse_0(t_0);
+ int _S18 = _S16 + _S17.x_0 + doThing_0(t_0);
+ int _S19 = somethingElse_0(t_0);
livenessEnd_2(t_0, 0);
- int _S17 = _S15 + _S16;
- int _S18 = s_3.c_0[2];
+ int _S20 = _S18 + _S19;
+ int _S21 = s_3.c_0[2];
livenessEnd_2(s_3, 0);
- int _S19 = _S17 + _S18;
- int _S20 = res_0;
+ int _S22 = _S20 + _S21;
+ int _S23 = res_0;
livenessEnd_1(res_0, 0);
- int res_1 = _S20 + _S19;
+ int res_1 = _S23 + _S22;
i_2 = i_2 + 1;
livenessStart_1(res_0, 0);
res_0 = res_1;
}
livenessEnd_1(i_2, 0);
- int _S21 = res_0;
+ int _S24 = res_0;
livenessEnd_1(res_0, 0);
- ((outputBuffer_0)._data[(uint(index_0))]) = _S21;
+ ((outputBuffer_0)._data[(uint(index_0))]) = _S24;
return;
}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected
index 09e389c32..09c026980 100644
--- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected
@@ -90,15 +90,23 @@ void main()
ray_2.TMin_0 = 0.00999999977648258209;
ray_2.Direction_0 = vec3(0.0, 1.0, 0.0);
ray_2.TMax_0 = 10000.0;
- RayDesc_0 _S10 = ray_2;
+ int _S10 = idx_0 * 2;
+ int _S11 = idx_0 * 3;
+ RayDesc_0 _S12 = ray_2;
hitObjectNV hitObj_0;
- hitObjectRecordHitWithIndexNV(hitObj_0, scene_0, int(uint(idx_0)), int(uint(idx_0 * 2)), int(uint(idx_0 * 3)), 0U, 0U, _S10.Origin_0, _S10.TMin_0, _S10.Direction_0, _S10.TMax_0, (0));
+ int _S13 = int(uint(idx_0));
+ int _S14 = int(uint(_S10));
+ int _S15 = int(uint(_S11));
+ hitObjectRecordHitWithIndexNV(hitObj_0, scene_0, _S13, _S14, _S15, 0U, 0U, _S12.Origin_0, _S12.TMin_0, _S12.Direction_0, _S12.TMax_0, (0));
uint r_3 = calcValue_0(hitObj_0);
- RayDesc_0 _S11 = ray_2;
+ RayDesc_0 _S16 = ray_2;
hitObjectNV hitObj_1;
- hitObjectRecordHitNV(hitObj_1, scene_0, int(uint(idx_0)), int(uint(idx_0 * 3)), int(uint(idx_0 * 2)), 0U, 0U, 4U, _S11.Origin_0, _S11.TMin_0, _S11.Direction_0, _S11.TMax_0, (0));
- uint _S12 = calcValue_0(hitObj_1);
- uint r_4 = r_3 + _S12;
+ int _S17 = int(uint(idx_0));
+ int _S18 = int(uint(_S11));
+ int _S19 = int(uint(_S10));
+ hitObjectRecordHitNV(hitObj_1, scene_0, _S17, _S18, _S19, 0U, 0U, 4U, _S16.Origin_0, _S16.TMin_0, _S16.Direction_0, _S16.TMax_0, (0));
+ uint _S20 = calcValue_0(hitObj_1);
+ uint r_4 = r_3 + _S20;
((outputBuffer_0)._data[(uint(idx_0))]) = r_4;
return;
}
diff --git a/tests/hlsl-intrinsic/vector-float.slang b/tests/hlsl-intrinsic/vector-float.slang
index b9cc6b9c8..de49bae73 100644
--- a/tests/hlsl-intrinsic/vector-float.slang
+++ b/tests/hlsl-intrinsic/vector-float.slang
@@ -13,6 +13,32 @@ typedef vector<Float, 3> FloatVector;
typedef vector<int, 3> IntVector;
typedef vector<uint, 3> UIntVector;
+void subf(inout FloatVector ft, FloatVector f, int idx, Float vf)
+{
+
+ ft += log(f + 10.0);
+ ft += log2(f * 3 + 2);
+
+ {
+ float v[] = { 1, 10, 100, 1000 };
+ ft += IntVector(log10(FloatVector(v[idx] + vf) + 0.5f));
+ }
+
+ ft += abs(f * 4 - 2.0f);
+
+ ft += min(0.5, f);
+ ft += max(f, 0.75);
+
+ ft += pow(0.5, f);
+
+ ft += smoothstep(0.2, 0.7, f);
+ ft += lerp(-100, 100, f);
+
+ ft += clamp(f, 0.1, 0.3);
+
+ ft += step(f, 0.5);
+}
+
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
@@ -84,30 +110,8 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
ft += floor(f * 10 - 7.01);
ft += trunc(f * 7);
-
- ft += log(f + 10.0);
- ft += log2(f * 3 + 2);
-
-
- {
- float v[] = { 1, 10, 100, 1000 };
- ft += IntVector(log10(FloatVector(v[idx] + vf) + 0.5f));
- }
-
-
- ft += abs(f * 4 - 2.0f);
-
- ft += min(0.5, f);
- ft += max(f, 0.75);
- ft += pow(0.5, f);
-
- ft += smoothstep(0.2, 0.7, f);
- ft += lerp(-100, 100, f);
-
- ft += clamp(f, 0.1, 0.3);
-
- ft += step(f, 0.5);
+ subf(ft, f, idx, vf);
{
IntVector vi = asint(f - f) + idx;
diff --git a/tests/ir/loop-dce.slang b/tests/ir/loop-dce.slang
new file mode 100644
index 000000000..f89c1aa38
--- /dev/null
+++ b/tests/ir/loop-dce.slang
@@ -0,0 +1,40 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+__target_intrinsic(hlsl, "@")
+__target_intrinsic(glsl, "@")
+__target_intrinsic(cpp, "@")
+__target_intrinsic(cuda, "@")
+[__readNone]
+int produceSyntaxError() { return 0; }
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ int sum = 0;
+ int array[100];
+ // Next, this loop will be removed because there is no use of `array`.
+ for (int i = 0; i < 100; i++)
+ {
+ // This loop must be removed, or we will fail downstream compilation.
+ array[i] = i + produceSyntaxError();
+ }
+
+ // First, this loop will be removed because there is no use of `sum`.
+ for (int i = 0; i < 100; i++)
+ {
+ // This loop must be removed, or we will fail downstream compilation.
+ if (i < 50)
+ {
+ sum += array[i] + produceSyntaxError();
+ }
+ else
+ {
+ sum += i * 2 + produceSyntaxError();
+ }
+ }
+ outputBuffer[0] = 1;
+}
diff --git a/tests/ir/loop-dce.slang.expected.txt b/tests/ir/loop-dce.slang.expected.txt
new file mode 100644
index 000000000..968ac3ef0
--- /dev/null
+++ b/tests/ir/loop-dce.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+0
+0
+0
diff --git a/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl b/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl
index 724a0a241..bae5f361d 100644
--- a/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl
+++ b/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl
@@ -3,47 +3,38 @@
#extension GL_NV_ray_tracing_motion_blur : require
layout(row_major) uniform;
layout(row_major) buffer;
-
struct ReflectionRay_0
{
float color_0;
};
-
layout(location = 0)
rayPayloadEXT
ReflectionRay_0 p_0;
-
struct ShadowRay_0
{
float hitDistance_0;
};
-
layout(location = 1)
rayPayloadEXT
ShadowRay_0 p_1;
-
layout(binding = 0)
uniform texture2D samplerPosition_0;
-
layout(binding = 2)
uniform sampler sampler_0;
-
layout(binding = 1)
uniform texture2D samplerNormal_0;
-
struct Light_0
{
vec4 position_0;
vec4 color_1;
};
-
struct Uniforms_0
{
Light_0 light_0;
@@ -52,13 +43,11 @@ struct Uniforms_0
mat4x4 model_0;
};
-
layout(binding = 3)
layout(std140) uniform _S1
{
Uniforms_0 _data;
} ubo_0;
-
struct RayDesc_0
{
vec3 Origin_0;
@@ -67,115 +56,76 @@ struct RayDesc_0
float TMax_0;
};
-
void TraceMotionRay_0(accelerationStructureEXT AccelerationStructure_0, uint RayFlags_0, uint InstanceInclusionMask_0, uint RayContributionToHitGroupIndex_0, uint MultiplierForGeometryContributionToHitGroupIndex_0, uint MissShaderIndex_0, RayDesc_0 Ray_0, float CurrentTime_0, inout ShadowRay_0 Payload_0)
{
-
p_1 = Payload_0;
traceRayMotionNV(AccelerationStructure_0, RayFlags_0, InstanceInclusionMask_0, RayContributionToHitGroupIndex_0, MultiplierForGeometryContributionToHitGroupIndex_0, MissShaderIndex_0, Ray_0.Origin_0, Ray_0.TMin_0, Ray_0.Direction_0, Ray_0.TMax_0, CurrentTime_0, (1));
-
Payload_0 = p_1;
return;
}
-
layout(binding = 5)
uniform accelerationStructureEXT as_0;
-
float saturate_0(float x_0)
{
- float _S2 = clamp(x_0, 0.0, 1.0);
-
- return _S2;
+ return clamp(x_0, 0.0, 1.0);
}
-
void TraceRay_0(accelerationStructureEXT AccelerationStructure_1, uint RayFlags_1, uint InstanceInclusionMask_1, uint RayContributionToHitGroupIndex_1, uint MultiplierForGeometryContributionToHitGroupIndex_1, uint MissShaderIndex_1, RayDesc_0 Ray_1, inout ReflectionRay_0 Payload_1)
{
-
p_0 = Payload_1;
traceRayEXT(AccelerationStructure_1, RayFlags_1, InstanceInclusionMask_1, RayContributionToHitGroupIndex_1, MultiplierForGeometryContributionToHitGroupIndex_1, MissShaderIndex_1, Ray_1.Origin_0, Ray_1.TMin_0, Ray_1.Direction_0, Ray_1.TMax_0, (0));
-
Payload_1 = p_0;
return;
}
-
layout(rgba32f)
layout(binding = 4)
uniform image2D outputImage_0;
-
void main()
{
- uvec3 _S3 = ((gl_LaunchIDEXT));
-
- ivec2 launchID_0 = ivec2(_S3.xy);
- uvec3 _S4 = ((gl_LaunchSizeEXT));
-
- ivec2 launchSize_0 = ivec2(_S4.xy);
-
-
- float _S5 = (float(launchID_0.x) + 0.5) / float(launchSize_0.x);
- float _S6 = (float(launchID_0.y) + 0.5) / float(launchSize_0.y);
-
- vec2 inUV_0 = vec2(_S5, _S6);
-
- vec4 _S7 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0)));
-
- vec3 P_0 = _S7.xyz;
- vec4 _S8 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0)));
-
- vec3 N_0 = _S8.xyz * 2.0 - 1.0;
-
+ uvec3 _S2 = ((gl_LaunchIDEXT));
+ ivec2 launchID_0 = ivec2(_S2.xy);
+ uvec3 _S3 = ((gl_LaunchSizeEXT));
+ ivec2 launchSize_0 = ivec2(_S3.xy);
+
+ float _S4 = (float(launchID_0.x) + 0.5) / float(launchSize_0.x);
+ float _S5 = (float(launchID_0.y) + 0.5) / float(launchSize_0.y);
+ vec2 inUV_0 = vec2(_S4, _S5);
+ vec4 _S6 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0)));
+ vec3 P_0 = _S6.xyz;
+ vec4 _S7 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0)));
+ vec3 N_0 = _S7.xyz * 2.0 - 1.0;
vec3 lightDelta_0 = ubo_0._data.light_0.position_0.xyz - P_0;
float lightDist_0 = length(lightDelta_0);
vec3 L_0 = normalize(lightDelta_0);
- float _S9 = 1.0 / (lightDist_0 * lightDist_0);
-
+ float _S8 = 1.0 / (lightDist_0 * lightDist_0);
RayDesc_0 ray_0;
ray_0.Origin_0 = P_0;
ray_0.TMin_0 = 0.00000099999999747524;
ray_0.Direction_0 = lightDelta_0;
ray_0.TMax_0 = lightDist_0;
-
ShadowRay_0 shadowRay_0;
shadowRay_0.hitDistance_0 = 0.0;
-
-
TraceMotionRay_0(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, 1.0, shadowRay_0);
-
float atten_0;
-
if(shadowRay_0.hitDistance_0 < lightDist_0)
{
-
atten_0 = 0.0;
-
}
else
{
-
- atten_0 = _S9;
-
+ atten_0 = _S8;
}
-
- vec3 _S10 = ubo_0._data.light_0.color_1.xyz;
-
- float _S11 = dot(N_0, L_0);
-
- float _S12 = saturate_0(_S11);
-
- vec3 color_2 = _S10 * _S12 * atten_0;
-
+ vec3 color_2 = ubo_0._data.light_0.color_1.xyz * saturate_0(dot(N_0, L_0)) * atten_0;
ReflectionRay_0 reflectionRay_0;
TraceRay_0(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, reflectionRay_0);
-
imageStore((outputImage_0), ivec2((uvec2(launchID_0))), vec4(color_2 + reflectionRay_0.color_0, 1.0));
return;
-} \ No newline at end of file
+}
diff --git a/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl b/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl
index 84eba46f0..7f53576e9 100644
--- a/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl
+++ b/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl
@@ -1,10 +1,7 @@
-//TEST_IGNORE_FILE:
-
#version 450
#extension GL_ARB_fragment_shader_interlock : require
layout(row_major) uniform;
layout(row_major) buffer;
-
layout(rgba32f)
layout(binding = 0)
uniform image2D entryPointParams_texture_0;
@@ -17,15 +14,12 @@ out vec4 _S2;
void main()
{
- beginInvocationInterlockARB();
-
- vec2 _S3 = _S1.xy;
-
- vec4 _S4 = (imageLoad((entryPointParams_texture_0), ivec2((uvec2(_S3)))));
- imageStore((entryPointParams_texture_0), ivec2((uvec2(_S3))), _S4 + _S1);
+ beginInvocationInterlockARB();
+ uvec2 _S3 = uvec2(_S1.xy);
+ vec4 _S4 = (imageLoad((entryPointParams_texture_0), ivec2((_S3))));
+ imageStore((entryPointParams_texture_0), ivec2((_S3)), _S4 + _S1);
endInvocationInterlockARB();
-
_S2 = _S4;
return;
}
diff --git a/tests/pipeline/rasterization/mesh/passing-outputs.slang.glsl b/tests/pipeline/rasterization/mesh/passing-outputs.slang.glsl
index 31c2f0db2..1102a838e 100644
--- a/tests/pipeline/rasterization/mesh/passing-outputs.slang.glsl
+++ b/tests/pipeline/rasterization/mesh/passing-outputs.slang.glsl
@@ -160,16 +160,10 @@ void main()
d_0(gl_LocalInvocationIndex);
e_0(gl_LocalInvocationIndex);
}
- else
- {
- }
if(gl_LocalInvocationIndex < 1U)
{
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0U, 1U, 2U);
}
- else
- {
- }
return;
}
diff --git a/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl b/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl
index f95321039..83797d2d5 100644
--- a/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl
+++ b/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl
@@ -1,6 +1,7 @@
#version 460
#extension GL_EXT_ray_tracing : require
-
+layout(row_major) uniform;
+layout(row_major) buffer;
int helper_0(accelerationStructureEXT a_0, int b_0)
{
return b_0;
diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl b/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl
index 0364d2513..1c2bc8090 100644
--- a/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl
+++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl
@@ -3,7 +3,6 @@
#extension GL_EXT_ray_query : require
layout(row_major) uniform;
layout(row_major) buffer;
-
struct SLANG_ParameterGroup_C_0
{
vec3 origin_0;
@@ -20,7 +19,6 @@ layout(std140) uniform _S1
{
SLANG_ParameterGroup_C_0 _data;
} C_0;
-
layout(binding = 0)
uniform accelerationStructureEXT myAccelerationStructure_0;
@@ -70,40 +68,32 @@ void myMiss_0(inout MyRayPayload_0 payload_4)
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main()
{
+ MyProceduralHitAttrs_0 committedProceduralAttrs_0;
rayQueryEXT query_0;
MyRayPayload_0 payload_5;
payload_5.value_1 = -1;
rayQueryInitializeEXT((query_0), (myAccelerationStructure_0), (C_0._data.rayFlags_0 | 512), (C_0._data.instanceMask_0), (C_0._data.origin_0), (C_0._data.tMin_0), (C_0._data.direction_0), (C_0._data.tMax_0));
-
- MyProceduralHitAttrs_0 committedProceduralAttrs_0;
-
for(;;)
{
-
bool _S2 = rayQueryProceedEXT(query_0);
-
if(!_S2)
{
break;
}
uint _S3 = (rayQueryGetIntersectionTypeEXT((query_0), false));
-
switch(_S3)
{
case 1U:
{
MyProceduralHitAttrs_0 candidateProceduralAttrs_0;
-
candidateProceduralAttrs_0.value_0 = 0;
float tHit_1 = 0.0;
bool _S4 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0);
-
if(_S4)
{
bool _S5 = myProceduralAnyHit_0(payload_5);
-
if(_S5)
{
rayQueryGenerateIntersectionEXT(query_0, tHit_1);
@@ -112,35 +102,22 @@ void main()
{
rayQueryTerminateEXT(query_0);
}
- else
- {
- }
-
committedProceduralAttrs_0 = _S6;
-
}
else
{
-
committedProceduralAttrs_0 = committedProceduralAttrs_0;
-
}
-
}
else
{
-
committedProceduralAttrs_0 = committedProceduralAttrs_0;
-
}
-
break;
}
case 0U:
{
-
bool _S7 = myTriangleAnyHit_0(payload_5);
-
if(_S7)
{
rayQueryConfirmIntersectionEXT(query_0);
@@ -148,12 +125,6 @@ void main()
{
rayQueryTerminateEXT(query_0);
}
- else
- {
- }
- }
- else
- {
}
break;
}
@@ -162,13 +133,8 @@ void main()
break;
}
}
-
- committedProceduralAttrs_0 = committedProceduralAttrs_0;
-
}
-
uint _S8 = (rayQueryGetIntersectionTypeEXT((query_0), true));
-
switch(_S8)
{
case 1U:
diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl b/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl
index 97d972328..b0c798b2d 100644
--- a/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl
+++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl
@@ -1,11 +1,14 @@
-// trace-ray-inline.slang.hlsl
-//TEST_IGNORE_FILE:
+#pragma pack_matrix(column_major)
+#ifdef SLANG_HLSL_ENABLE_NVAPI
+#include "nvHLSLExtns.h"
+#endif
+#pragma warning(disable: 3557)
struct SLANG_ParameterGroup_C_0
{
- vector<float,3> origin_0;
+ float3 origin_0;
float tMin_0;
- vector<float,3> direction_0;
+ float3 direction_0;
float tMax_0;
uint rayFlags_0;
uint instanceMask_0;
@@ -16,7 +19,6 @@ cbuffer C_0 : register(b0)
{
SLANG_ParameterGroup_C_0 C_0;
}
-
RaytracingAccelerationStructure myAccelerationStructure_0 : register(t0);
struct MyProceduralHitAttrs_0
@@ -62,170 +64,92 @@ void myMiss_0(inout MyRayPayload_0 payload_4)
return;
}
-
-[shader("compute")]
-[numthreads(1, 1, 1)]
-void main(vector<uint,3> tid_0 : SV_DISPATCHTHREADID)
+[shader("compute")][numthreads(1, 1, 1)]
+void main(uint3 tid_0 : SV_DISPATCHTHREADID)
{
- MyRayPayload_0 payload_5;
MyProceduralHitAttrs_0 committedProceduralAttrs_0;
- MyProceduralHitAttrs_0 committedProceduralAttrs_1;
- MyRayPayload_0 payload_6;
- MyProceduralHitAttrs_0 committedProceduralAttrs_2;
- MyRayPayload_0 payload_7;
- MyProceduralHitAttrs_0 committedProceduralAttrs_3;
RayQuery<int(512) > query_0;
- MyRayPayload_0 _S1 = { int(-1) };
+ MyRayPayload_0 payload_5;
+ payload_5.value_1 = int(-1);
RayDesc ray_0 = { C_0.origin_0, C_0.tMin_0, C_0.direction_0, C_0.tMax_0 };
query_0.TraceRayInline(myAccelerationStructure_0, C_0.rayFlags_0, C_0.instanceMask_0, ray_0);
-
- MyProceduralHitAttrs_0 _S2;
-
- payload_5 = _S1;
- committedProceduralAttrs_0 = _S2;
for(;;)
{
- bool _S3 = query_0.Proceed();
-
- if(!_S3)
+ bool _S1 = query_0.Proceed();
+ if(!_S1)
{
break;
}
- uint _S4 = query_0.CandidateType();
-
- switch(_S4)
+ uint _S2 = query_0.CandidateType();
+ switch(_S2)
{
- case (uint) int(1):
+ case 1U:
{
- MyProceduralHitAttrs_0 candidateProceduralAttrs_0 = { int(0) };
-
- float _S5;
-
- _S5 = 0.00000000000000000000;
-
- MyProceduralHitAttrs_0 _S6;
-
- _S6 = candidateProceduralAttrs_0;
-
- bool _S7 = myProceduralIntersection_0(_S5, _S6);
-
- float tHit_1 = _S5;
-
- MyProceduralHitAttrs_0 candidateProceduralAttrs_1 = _S6;
-
- if(_S7)
+ MyProceduralHitAttrs_0 candidateProceduralAttrs_0;
+ candidateProceduralAttrs_0.value_0 = int(0);
+ float tHit_1 = 0.0;
+ bool _S3 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0);
+ if(_S3)
{
- MyRayPayload_0 _S8;
-
- _S8 = payload_5;
-
- bool _S9 = myProceduralAnyHit_0(_S8);
-
- MyRayPayload_0 _S10 = _S8;
-
- if(_S9)
+ bool _S4 = myProceduralAnyHit_0(payload_5);
+ if(_S4)
{
query_0.CommitProceduralPrimitiveHit(tHit_1);
-
- if((bool) C_0.shouldStopAtFirstHit_0)
+ MyProceduralHitAttrs_0 _S5 = candidateProceduralAttrs_0;
+ if(C_0.shouldStopAtFirstHit_0 != 0U)
{
-
query_0.Abort();
}
- else
- {
- }
-
- committedProceduralAttrs_1 = candidateProceduralAttrs_1;
+ committedProceduralAttrs_0 = _S5;
}
else
{
- committedProceduralAttrs_1 = committedProceduralAttrs_0;
+ committedProceduralAttrs_0 = committedProceduralAttrs_0;
}
-
- payload_6 = _S10;
- committedProceduralAttrs_2 = committedProceduralAttrs_1;
}
else
{
- payload_6 = payload_5;
- committedProceduralAttrs_2 = committedProceduralAttrs_0;
+ committedProceduralAttrs_0 = committedProceduralAttrs_0;
}
-
- payload_7 = payload_6;
- committedProceduralAttrs_3 = committedProceduralAttrs_2;
break;
}
- case (uint) int(0):
+ case 0U:
{
- MyRayPayload_0 _S11;
- _S11 = payload_5;
-
- bool _S12 = myTriangleAnyHit_0(_S11);
- MyRayPayload_0 _S13 = _S11;
-
- if(_S12)
+ bool _S6 = myTriangleAnyHit_0(payload_5);
+ if(_S6)
{
query_0.CommitNonOpaqueTriangleHit();
- if((bool) C_0.shouldStopAtFirstHit_0)
+ if(C_0.shouldStopAtFirstHit_0 != 0U)
{
query_0.Abort();
}
- else
- {
- }
- }
- else
- {
}
-
- payload_7 = _S13;
- committedProceduralAttrs_3 = committedProceduralAttrs_0;
break;
}
default:
{
- payload_7 = payload_5;
- committedProceduralAttrs_3 = committedProceduralAttrs_0;
break;
}
}
-
- payload_5 = payload_7;
- committedProceduralAttrs_0 = committedProceduralAttrs_3;
}
-
- uint _S14 = query_0.CommittedStatus();
-
- switch(_S14)
+ uint _S7 = query_0.CommittedStatus();
+ switch(_S7)
{
- case (uint) int(1):
+ case 1U:
{
- MyRayPayload_0 _S15;
-
- _S15 = payload_5;
-
- myTriangleClosestHit_0(_S15);
+ myTriangleClosestHit_0(payload_5);
break;
}
- case (uint) int(2):
+ case 2U:
{
-
- MyRayPayload_0 _S16;
- _S16 = payload_5;
-
- myProceduralClosestHit_0(_S16, committedProceduralAttrs_0);
+ myProceduralClosestHit_0(payload_5, committedProceduralAttrs_0);
break;
}
- case (uint) int(0):
+ case 0U:
{
- MyRayPayload_0 _S17;
-
- _S17 = payload_5;
-
- myMiss_0(_S17);
+ myMiss_0(payload_5);
break;
}
default:
@@ -233,6 +157,5 @@ void main(vector<uint,3> tid_0 : SV_DISPATCHTHREADID)
break;
}
}
-
return;
}
diff --git a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl
index 139d55518..fca1fc1fa 100644
--- a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl
+++ b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl
@@ -2,7 +2,6 @@
#extension GL_EXT_shader_atomic_float : require
layout(row_major) uniform;
layout(row_major) buffer;
-
layout(std430, binding = 1) buffer _S1 {
float _data[];
} anotherBuffer_0;
@@ -11,7 +10,7 @@ layout(std430, binding = 0) buffer _S2 {
} _S3;
void RWByteAddressBuffer_InterlockedAddF32_0(uint _S4, float _S5, out float _S6)
{
- uint _S7 = _S4 / uint(4);
+ uint _S7 = _S4 / 4U;
float _S8 = (atomicAdd((((_S3)._data[(_S7)])), (_S5)));
_S6 = _S8;
return;
@@ -19,7 +18,7 @@ void RWByteAddressBuffer_InterlockedAddF32_0(uint _S4, float _S5, out float _S6)
void RWByteAddressBuffer_InterlockedAddF32_1(uint _S9, float _S10)
{
- uint _S11 = _S9 / uint(4);
+ uint _S11 = _S9 / 4U;
float _S12 = (atomicAdd((((_S3)._data[(_S11)])), (_S10)));
return;
}
@@ -28,11 +27,11 @@ layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
void main()
{
uint tid_0 = gl_GlobalInvocationID.x;
- int idx_0 = int(tid_0 & uint(3) ^ tid_0 >> 2);
+ uint _S13 = tid_0 >> 2;
+ int idx_0 = int(tid_0 & 3U ^ _S13);
float delta_0 = ((anotherBuffer_0)._data[(uint(idx_0 & 3))]);
- float previousValue_0;
- previousValue_0 = float(0);
- RWByteAddressBuffer_InterlockedAddF32_0(uint(idx_0 << 2), 1.00000000000000000000, previousValue_0);
- RWByteAddressBuffer_InterlockedAddF32_1(uint(int(tid_0 >> 2) << 2), delta_0);
+ float previousValue_0 = 0.0;
+ RWByteAddressBuffer_InterlockedAddF32_0(uint(idx_0 << 2), 1.0, previousValue_0);
+ RWByteAddressBuffer_InterlockedAddF32_1(uint(int(_S13) << 2), delta_0);
return;
}
diff --git a/tests/vkray/anyhit.slang.glsl b/tests/vkray/anyhit.slang.glsl
index eb39299c5..345dd6624 100644
--- a/tests/vkray/anyhit.slang.glsl
+++ b/tests/vkray/anyhit.slang.glsl
@@ -1,16 +1,8 @@
// anyhit.slang.glsl
#version 460
-
-#if USE_NV_RT
-#extension GL_NV_ray_tracing : require
-#define hitAttributeEXT hitAttributeNV
-#define rayPayloadInEXT rayPayloadInNV
-#define terminateRayEXT terminateRayNV
-#define ignoreIntersectionEXT ignoreIntersectionNV
-#else
#extension GL_EXT_ray_tracing : require
-#endif
-
+layout(row_major) uniform;
+layout(row_major) buffer;
struct Params_0
{
int mode_0;
@@ -47,16 +39,15 @@ void main()
float val_0 = textureLod(
sampler2D(gParams_alphaMap_0, gParams_sampler_0),
_S2.normal_0.xy,
- float(0)).x;
-
+ (0.0)).x;
- if(val_0 > float(0))
+ if(val_0 > 0.0)
{
- terminateRayEXT;
+ terminateRayEXT;;
}
else
{
- ignoreIntersectionEXT;
+ ignoreIntersectionEXT;;
}
}
diff --git a/tests/vkray/callable-caller.slang.glsl b/tests/vkray/callable-caller.slang.glsl
index 0b7a9677b..11049074f 100644
--- a/tests/vkray/callable-caller.slang.glsl
+++ b/tests/vkray/callable-caller.slang.glsl
@@ -1,18 +1,7 @@
-//TEST_IGNORE_FILE:
#version 460
#extension GL_NV_ray_tracing : require
layout(row_major) uniform;
layout(row_major) buffer;
-struct SLANG_ParameterGroup_C_0
-{
- uint shaderIndex_0;
-};
-
-layout(binding = 0)
-layout(std140) uniform _S1
-{
- SLANG_ParameterGroup_C_0 _data;
-} C_0;
struct MaterialPayload_0
{
vec4 albedo_0;
@@ -23,6 +12,16 @@ layout(location = 0)
callableDataNV
MaterialPayload_0 p_0;
+struct SLANG_ParameterGroup_C_0
+{
+ uint shaderIndex_0;
+};
+
+layout(binding = 0)
+layout(std140) uniform _S1
+{
+ SLANG_ParameterGroup_C_0 _data;
+} C_0;
void CallShader_0(uint shaderIndex_1, inout MaterialPayload_0 payload_0)
{
p_0 = payload_0;
@@ -38,7 +37,7 @@ uniform image2D gImage_0;
void main()
{
MaterialPayload_0 payload_1;
- payload_1.albedo_0 = vec4(0);
+ payload_1.albedo_0 = vec4(0.0);
uvec3 _S2 = ((gl_LaunchIDNV));
vec2 _S3 = vec2(_S2.xy);
uvec3 _S4 = ((gl_LaunchSizeNV));
diff --git a/tests/vkray/raygen.slang.glsl b/tests/vkray/raygen.slang.glsl
index e34f1f6e0..f86f67e82 100644
--- a/tests/vkray/raygen.slang.glsl
+++ b/tests/vkray/raygen.slang.glsl
@@ -76,8 +76,7 @@ uniform accelerationStructureEXT as_0;
float saturate_0(float x_0)
{
- float _S2 = clamp(x_0, 0.0, 1.0);
- return _S2;
+ return clamp(x_0, 0.0, 1.0);
}
layout(rgba32f)
@@ -86,24 +85,24 @@ uniform image2D outputImage_0;
void main()
{
- uvec3 _S3 = ((gl_LaunchIDEXT));
- float _S4 = float(_S3.x) + 0.5;
- uvec3 _S5 = ((gl_LaunchSizeEXT));
- float _S6 = _S4 / float(_S5.x);
- uvec3 _S7 = ((gl_LaunchIDEXT));
- float _S8 = float(_S7.y) + 0.5;
- uvec3 _S9 = ((gl_LaunchSizeEXT));
- float _S10 = _S8 / float(_S9.y);
- vec2 inUV_0 = vec2(_S6, _S10);
- vec4 _S11 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0)));
- vec3 P_0 = _S11.xyz;
- vec4 _S12 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0)));
- vec3 N_0 = _S12.xyz * 2.0 - 1.0;
+ uvec3 _S2 = ((gl_LaunchIDEXT));
+ float _S3 = float(_S2.x) + 0.5;
+ uvec3 _S4 = ((gl_LaunchSizeEXT));
+ float _S5 = _S3 / float(_S4.x);
+ uvec3 _S6 = ((gl_LaunchIDEXT));
+ float _S7 = float(_S6.y) + 0.5;
+ uvec3 _S8 = ((gl_LaunchSizeEXT));
+ float _S9 = _S7 / float(_S8.y);
+ vec2 inUV_0 = vec2(_S5, _S9);
+ vec4 _S10 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0)));
+ vec3 P_0 = _S10.xyz;
+ vec4 _S11 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0)));
+ vec3 N_0 = _S11.xyz * 2.0 - 1.0;
vec3 lightDelta_0 = ubo_0._data.light_0.position_0.xyz - P_0;
float lightDist_0 = length(lightDelta_0);
vec3 L_0 = normalize(lightDelta_0);
- float _S13 = 1.0 / (lightDist_0 * lightDist_0);
+ float _S12 = 1.0 / (lightDist_0 * lightDist_0);
RayDesc_0 ray_0;
ray_0.Origin_0 = P_0;
ray_0.TMin_0 = 0.00000099999999747524;
@@ -120,17 +119,14 @@ void main()
}
else
{
- atten_0 = _S13;
+ atten_0 = _S12;
}
- vec3 _S14 = ubo_0._data.light_0.color_1.xyz;
- float _S15 = dot(N_0, L_0);
- float _S16 = saturate_0(_S15);
- vec3 color_2 = _S14 * _S16 * atten_0;
+ vec3 color_2 = ubo_0._data.light_0.color_1.xyz * saturate_0(dot(N_0, L_0)) * atten_0;
ReflectionRay_0 reflectionRay_0;
TraceRay_1(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, reflectionRay_0);
vec3 color_3 = color_2 + reflectionRay_0.color_0;
- uvec3 _S17 = ((gl_LaunchIDEXT));
- imageStore((outputImage_0), ivec2((uvec2(ivec2(_S17.xy)))), vec4(color_3, 1.0));
+ uvec3 _S13 = ((gl_LaunchIDEXT));
+ imageStore((outputImage_0), ivec2((uvec2(ivec2(_S13.xy)))), vec4(color_3, 1.0));
return;
}