diff options
Diffstat (limited to 'tests')
13 files changed, 208 insertions, 39 deletions
diff --git a/tests/bugs/gh-3429.slang b/tests/bugs/gh-3429.slang index e4eda5b38..c9b49e5f4 100644 --- a/tests/bugs/gh-3429.slang +++ b/tests/bugs/gh-3429.slang @@ -50,6 +50,6 @@ void computeMain() // CHECK: loadDataConditionFalse float v = getDataDependingOnCondition(gPushConstants.bufferHasOnlyOneElement); - int2 pixelIndex = int2(DispatchRaysIndex().xy); + int2 pixelIndex = int2(0); gResultImage[pixelIndex] = float4(v, v, v, 1.0); } diff --git a/tests/glsl-intrinsic/intrinsic-basic.slang b/tests/glsl-intrinsic/intrinsic-basic.slang index 14d03bf6c..1d814ffcd 100644 --- a/tests/glsl-intrinsic/intrinsic-basic.slang +++ b/tests/glsl-intrinsic/intrinsic-basic.slang @@ -1,8 +1,8 @@ -//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage fragment -entry computeMain -target glsl -//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage fragment -entry computeMain -target spirv -//TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage fragment -entry computeMain -target hlsl -//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage fragment -entry computeMain -target cuda -DTARGET_CUDA -//TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage fragment -entry computeMain -target cpp +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv +//TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl +//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda -DTARGET_CUDA +//TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp //TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type -emit-spirv-directly diff --git a/tests/glsl-intrinsic/raytracing/glsl-rayGen.slang b/tests/glsl-intrinsic/raytracing/glsl-rayGen.slang index ba4663f12..2969dcb9b 100644 --- a/tests/glsl-intrinsic/raytracing/glsl-rayGen.slang +++ b/tests/glsl-intrinsic/raytracing/glsl-rayGen.slang @@ -328,6 +328,7 @@ void main() && testRecordMissCalls() && testRecordEmptyCalls() && testTraceRayMotion() - && testReadWriteOfObjects(); + && testReadWriteOfObjects() + ; //BUF: 1 } diff --git a/tests/glsl/work-group-builtIn.slang b/tests/glsl/work-group-builtIn.slang new file mode 100644 index 000000000..bce0fa518 --- /dev/null +++ b/tests/glsl/work-group-builtIn.slang @@ -0,0 +1,21 @@ +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +#version 430 +precision highp float; +precision highp int; + +//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer +layout(binding = 0) buffer MyBlockName +{ + int data[6]; +} outputBuffer; + +layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in; +void computeMain() +{ + outputBuffer.data[0] = gl_NumWorkGroups.x; + outputBuffer.data[1] = gl_NumWorkGroups.y; + outputBuffer.data[2] = gl_NumWorkGroups.z; + // BUF: 1 + // BUF-NEXT: 1 + // BUF-NEXT: 1 +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/debug-break.slang b/tests/hlsl-intrinsic/debug-break.slang index 5c783f332..c16139f72 100644 --- a/tests/hlsl-intrinsic/debug-break.slang +++ b/tests/hlsl-intrinsic/debug-break.slang @@ -1,4 +1,4 @@ -//TEST:SIMPLE(filecheck=CHECK):-stage compute -entry computeMain -target glsl -line-directive-mode none +//TEST:SIMPLE(filecheck=CHECK_GLSL):-stage compute -entry computeMain -target glsl -line-directive-mode none // We can't enable because output source includes path to prelude. //DISABLE_TEST:SIMPLE:-stage compute -entry computeMain -target cpp -line-directive-mode none //DISABLE_TEST:SIMPLE:-stage compute -entry computeMain -target cuda -line-directive-mode none @@ -10,10 +10,10 @@ //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer -// CHECK: spirv_instruction(id = 1, set = "NonSemantic.DebugBreak") -// CHECK: void debugBreak{{.*}}(); -// CHECK: void main -// CHECK: debugBreak{{.*}}(); +// CHECK_GLSL: spirv_instruction(id = 1, set = "NonSemantic.DebugBreak") +// CHECK_GLSL: glslDebugBreak{{.*}}(); +// CHECK_GLSL: void main +// CHECK_GLSL: glslDebugBreak{{.*}}(); RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/capability/capability-invalid-compute-in-fragment.slang b/tests/language-feature/capability/capability-invalid-compute-in-fragment.slang new file mode 100644 index 000000000..d36a62adf --- /dev/null +++ b/tests/language-feature/capability/capability-invalid-compute-in-fragment.slang @@ -0,0 +1,10 @@ +//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry main -stage fragment -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -entry main -stage fragment -allow-glsl -ignore-capabilities +// CHECK_IGNORE_CAPS-NOT: error 36107 +// CHECK: error 36107 + +float4 main() +{ + memoryBarrierAtomicCounter(); + return float4(1.0f); +} diff --git a/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang b/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang new file mode 100644 index 000000000..946ba4470 --- /dev/null +++ b/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang @@ -0,0 +1,21 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -DPRE +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -DPOST +//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities -DPRE +//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities -DPOST + +// CHECK_IGNORE_CAPS-NOT: error 36107 +// CHECK: error 36107 +SamplerState samplerState; +Texture2D<int> rw; + +[numthreads(1,1,1)] +void computeMain() +{ +#ifdef PRE + rw.Load(0); +#endif + clip(0.0f); +#ifdef POST + rw.Load(0); +#endif +}
\ No newline at end of file diff --git a/tests/language-feature/capability/capability3.slang b/tests/language-feature/capability/capability3.slang index 02eb7d495..96c07a51f 100644 --- a/tests/language-feature/capability/capability3.slang +++ b/tests/language-feature/capability/capability3.slang @@ -3,47 +3,40 @@ // CHECK_IGNORE_CAPS-NOT: error 36108 // Test that capabilities can be declared on module. - [require(glsl)] [require(spirv)] module test; -void f() -{ - __require_capability glsl; -} - -// CHECK: ([[# @LINE+1]]): error 36108 -public void g() -{ - __require_capability spvAtomicFloat16AddEXT; -} +RWStructuredBuffer<int> sideEffect; -void l() +// CHECK: error 36104 +[require(glsl, _sm_4_0)] +public void use1() { __target_switch { case glsl: - f(); - return; - case spirv: - __require_capability spvAtomicFloat16AddEXT; return; } } -// CHECK: ([[# @LINE+1]]): error 36104: {{.*}} -public void use() +void use2Sub() { - l(); // Error + __target_switch + { + case glsl: + sideEffect[1] = 1; + } } - -// CHECK-NOT: ([[# @LINE+1]]): error -[require(spirv, spvAtomicFloat16AddEXT)] -public void use1() +// CHECK: error 36108 +[require(spirv, spirv_1_0)] +public void use2() { - l(); // Error + use2Sub(); } void main() -{}
\ No newline at end of file +{ + use1(); + use2(); +}
\ No newline at end of file diff --git a/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang new file mode 100644 index 000000000..46ffaf2a7 --- /dev/null +++ b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang @@ -0,0 +1,32 @@ +//TEST:SIMPLE(filecheck=CHECK): -target cpp -entry computeMain -stage compute -allow-glsl + +// CHECK: computeMain( + +layout(binding = 0) buffer MyBlockName +{ + int v[1]; +} outputBuffer; + +// `default` only should try to define `glsl`, but glsl target is +// present in a `case` statment. Therefore this code should error +// since cpp is missing a target for a function called +[require(cpp_glsl)] +void someInternalFunc() +{ + __target_switch + { + case glsl: + outputBuffer.v[0] = 0; + default: + outputBuffer.v[0] = 0; + } +} +void someMin() +{ + someInternalFunc(); +} +[numthreads(1,1,1)] +void computeMain() +{ + someMin(); +} diff --git a/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang new file mode 100644 index 000000000..fc8983ef1 --- /dev/null +++ b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang @@ -0,0 +1,34 @@ +//TEST:SIMPLE(filecheck=CHECK): -target cpp -entry computeMain -stage compute -allow-glsl + +// CHECK: computeMain( + +layout(binding = 0) buffer MyBlockName +{ + int v[1]; +} outputBuffer; + +// `default` only should try to define `glsl`, but glsl target is +// present in a `case` statment. Therefore this code should error +// since cpp is missing a target for a function called +[require(cpp)] +[require(glsl)] +[require(spirv)] +void someInternalFunc() +{ + __target_switch + { + case glsl: + outputBuffer.v[0] = 0; + default: + outputBuffer.v[0] = 0; + } +} +void someMin() +{ + someInternalFunc(); +} +[numthreads(1,1,1)] +void computeMain() +{ + someMin(); +} diff --git a/tests/language-feature/capability/cpp-target-missing-cpp-impl.slang b/tests/language-feature/capability/cpp-target-missing-cpp-impl.slang new file mode 100644 index 000000000..a01993e8f --- /dev/null +++ b/tests/language-feature/capability/cpp-target-missing-cpp-impl.slang @@ -0,0 +1,34 @@ +//TEST:SIMPLE(filecheck=CHECK): -target cpp -entry computeMain -stage compute -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target cpp -entry computeMain -stage compute -allow-glsl -ignore-capabilities +// CHECK_IGNORE_CAPS-NOT: error 36107 +// CHECK: error 36107 + +layout(binding = 0) buffer MyBlockName +{ + int v[1]; +} outputBuffer; + +// `default` only should try to define `glsl`, but glsl target is +// present in a `case` statment. Therefore this code should error +// since cpp is missing a target for a function called +[require(glsl)] +void someInternalFunc() +{ + __target_switch + { + case glsl: + outputBuffer.v[0] = 0; + default: + outputBuffer.v[0] = 0; + } +} +void someMin() +{ + someInternalFunc(); +} + +[numthreads(1,1,1)] +void computeMain() +{ + someMin(); +} diff --git a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang index 523c58984..307394e1a 100644 --- a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang +++ b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang @@ -4,12 +4,17 @@ // We can't do this test, because it relies on nvAPI //DISABLE_TEST:CROSS_COMPILE: -profile cs_6_5 -entry computeMain -target dxil -//TEST_INPUT:ubuffer(data=[0.1 0.2 0.3 0.4]):out,name=outputBuffer RWByteAddressBuffer outputBuffer; -//TEST_INPUT:ubuffer(data=[0.7 0.5 0.2 0.6]):name=anotherBuffer RWStructuredBuffer<float> anotherBuffer; +// CHECK_SPV: OpAtomicFAddEXT +// CHECK_SPV: OpAtomicFAddEXT +// CHECK_GLSL: atomicAdd +// CHECK_GLSL: atomicAdd +// CHECK_HLSL: NvInterlockedAddFp32 +// CHECK_HLSL: NvInterlockedAddFp32 + [numthreads(16, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { diff --git a/tests/slang-extension/atomic-int64-add.slang b/tests/slang-extension/atomic-int64-add.slang new file mode 100644 index 000000000..20057a0bf --- /dev/null +++ b/tests/slang-extension/atomic-int64-add.slang @@ -0,0 +1,18 @@ +//TEST:SIMPLE(filecheck=CHECK_HLSL): -stage compute -entry computeMain -target hlsl +//TEST:SIMPLE(filecheck=CHECK_GLSL): -stage compute -entry computeMain -target glsl + +RWByteAddressBuffer outputBuffer; + +// CHECK_GLSL: atomicAdd +// CHECK_GLSL: atomicAdd +// CHECK_HLSL: InterlockedAdd64 +// CHECK_HLSL: InterlockedAdd64 + +[numthreads(16, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + uint64_t indata1; + int64_t indata2; + outputBuffer.InterlockedAdd64(0, 1, indata1); + outputBuffer.InterlockedAdd64(8, 1, indata2); +}
\ No newline at end of file |
