diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-16 13:55:32 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-16 13:55:32 -0800 |
| commit | 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a (patch) | |
| tree | ed4af0ded878e4f06e9641ce61d26ffd7c89ccbc /tests/hlsl-intrinsic | |
| parent | eda88e513e8b1e2abc05e9dc8555f237d96472df (diff) | |
Overhaul global inst deduplication and cpp/cuda backend. (#2654)
* Overhaul global inst deduplication and cpp/cuda backend.
* Update IR documentation.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/hlsl-intrinsic')
6 files changed, 64 insertions, 57 deletions
diff --git a/tests/hlsl-intrinsic/f16tof32.slang b/tests/hlsl-intrinsic/f16tof32.slang index 78c5fdae6..d45eab00b 100644 --- a/tests/hlsl-intrinsic/f16tof32.slang +++ b/tests/hlsl-intrinsic/f16tof32.slang @@ -2,7 +2,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<float> outputBuffer; diff --git a/tests/hlsl-intrinsic/f32tof16.slang b/tests/hlsl-intrinsic/f32tof16.slang index ebcb6b40a..ad8e8e5df 100644 --- a/tests/hlsl-intrinsic/f32tof16.slang +++ b/tests/hlsl-intrinsic/f32tof16.slang @@ -2,7 +2,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<uint> outputBuffer; diff --git a/tests/hlsl-intrinsic/matrix-double.slang b/tests/hlsl-intrinsic/matrix-double.slang index b9e36bef8..08bd78cee 100644 --- a/tests/hlsl-intrinsic/matrix-double.slang +++ b/tests/hlsl-intrinsic/matrix-double.slang @@ -35,8 +35,7 @@ Float calcTotal(FloatMatrix v) FloatMatrix makeFloatMatrix(Float f) { - FloatMatrix m = { { f, f }, { f, f } }; - return m; + return FloatMatrix(f); } IntMatrix makeIntMatrix(int v) @@ -45,68 +44,58 @@ IntMatrix makeIntMatrix(int v) return m; } -[numthreads(4, 1, 1)] -void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +void test1(inout FloatMatrix ft, inout FloatMatrix f, int idx) { - int idx = int(dispatchThreadID.x); - - Float scalarF = idx * (1.0f / (4.0f)); - - FloatMatrix ft = {}; - - FloatMatrix f = { { scalarF + 0.01, scalarF + 0.02}, { scalarF + 0.011, scalarF + 0.022}}; - // fmod ft += FloatMatrix(IntMatrix(((f % makeFloatMatrix(0.11f)) * makeFloatMatrix(100)) + makeFloatMatrix(0.5))); - + ft += sin(f); - + // Lets try some matrix/matrix ft = f * ft; - + // Lets try some vector matrix - + { - FloatMatrix r = {mul(f[0], ft), mul(ft, f[1])}; + FloatMatrix r = { mul(f[0], ft), mul(ft, f[1]) }; ft += r; } - + // Back to the transcendentals - + ft += cos(f); ft += tan(f); - + ft += asin(f); ft += acos(f); ft += atan(f); - - ft += atan2(f, makeFloatMatrix(2)); + ft += atan2(f, makeFloatMatrix(2)); { FloatMatrix sf, cf; sincos(f, sf, cf); - + ft += sf; ft += cf; } - + ft += rcp(makeFloatMatrix(1.0) + f); ft += FloatMatrix(sign(f - makeFloatMatrix(0.5))); - + ft += saturate(f * makeFloatMatrix(4) - makeFloatMatrix(2.0)); - + ft += sqrt(f); ft += rsqrt(makeFloatMatrix(1.0f) + f); - + ft += exp2(f); ft += exp(f); - + ft += frac(f * makeFloatMatrix(3)); ft += ceil(f * makeFloatMatrix(5) - makeFloatMatrix(3)); - + ft += floor(f * makeFloatMatrix(10) - makeFloatMatrix(7)); ft += trunc(f * makeFloatMatrix(7)); - + ft += log(f + makeFloatMatrix(10.0)); ft += log2(f * makeFloatMatrix(3) + makeFloatMatrix(2)); @@ -114,12 +103,15 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) float scalarVs[] = { 1, 10, 100, 1000 }; ft += FloatMatrix(IntMatrix(log10(makeFloatMatrix(scalarVs[idx])) + makeFloatMatrix(0.5f))); } - + ft += abs(f * makeFloatMatrix(4) - makeFloatMatrix(2.0f)); - + ft += min(makeFloatMatrix(0.5), f); ft += max(f, makeFloatMatrix(0.75)); +} +void test2(inout FloatMatrix ft, inout FloatMatrix f) +{ ft += pow(makeFloatMatrix(0.5), f); ft += smoothstep(makeFloatMatrix(0.2), makeFloatMatrix(0.7), f); @@ -135,7 +127,22 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) UIntMatrix vu = asuint(f); ft += asfloat(vu); -#endif - +#endif +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + Float scalarF = idx * (1.0f / (4.0f)); + + FloatMatrix ft = {}; + + FloatMatrix f = { { scalarF + 0.01, scalarF + 0.02}, { scalarF + 0.011, scalarF + 0.022}}; + + test1(ft, f, idx); + test2(ft, f); + outputBuffer[idx] = calcTotal(ft); }
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected index 58f06cfec..6e3e5d5d8 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected @@ -17,13 +17,17 @@ layout(location = 0) rayPayloadEXT SomeValues_0 p_0; -layout(binding = 0) -uniform accelerationStructureEXT scene_0; - layout(location = 0) hitObjectAttributeNV SomeValues_0 t_0; +layout(location = 1) +rayPayloadEXT +SomeValues_0 p_1; + +layout(binding = 0) +uniform accelerationStructureEXT scene_0; + SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0) { hitObjectGetAttributesNV((this_0), ((0))); @@ -50,15 +54,11 @@ uint calcValue_0(hitObjectNV hit_0) return r_0; } -layout(location = 1) -rayPayloadEXT -SomeValues_0 p_1; - void HitObject_Invoke_0(accelerationStructureEXT AccelerationStructure_0, hitObjectNV HitOrMiss_0, inout SomeValues_0 Payload_0) { - p_1 = Payload_0; - hitObjectExecuteShaderNV(HitOrMiss_0, (1)); - Payload_0 = p_1; + p_0 = Payload_0; + hitObjectExecuteShaderNV(HitOrMiss_0, (0)); + Payload_0 = p_0; return; } @@ -87,10 +87,10 @@ void main() ray_0.Direction_0 = vec3(0.0, 1.0, 0.0); ray_0.TMax_0 = 10000.0; RayDesc_0 _S7 = ray_0; - p_0.a_0 = idx_0; - p_0.b_0 = _S6; + p_1.a_0 = idx_0; + p_1.b_0 = _S6; hitObjectNV hitObj_0; - hitObjectTraceRayNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S7.Origin_0, _S7.TMin_0, _S7.Direction_0, _S7.TMax_0, (0)); + hitObjectTraceRayNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S7.Origin_0, _S7.TMin_0, _S7.Direction_0, _S7.TMax_0, (1)); uint r_1 = calcValue_0(hitObj_0); reorderThreadNV(hitObj_0); float _S8 = _S5 * 4.0; diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected index e6d31a3c8..12025efe0 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected @@ -15,16 +15,16 @@ struct SomeValues_0 }; layout(location = 0) +hitObjectAttributeNV +SomeValues_0 t_0; + +layout(location = 0) rayPayloadEXT SomeValues_0 p_0; layout(binding = 0) uniform accelerationStructureEXT scene_0; -layout(location = 0) -hitObjectAttributeNV -SomeValues_0 t_0; - SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0) { hitObjectGetAttributesNV((this_0), ((0))); diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected index 9b5a4d193..ac4d78234 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected @@ -14,16 +14,16 @@ struct SomeValues_0 }; layout(location = 0) +hitObjectAttributeNV +SomeValues_0 t_0; + +layout(location = 0) rayPayloadEXT SomeValues_0 p_0; layout(binding = 0) uniform accelerationStructureEXT scene_0; -layout(location = 0) -hitObjectAttributeNV -SomeValues_0 t_0; - SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0) { hitObjectGetAttributesNV((this_0), ((0))); |
