diff options
Diffstat (limited to 'tests/language-feature')
6 files changed, 168 insertions, 41 deletions
diff --git a/tests/language-feature/capability/capability-inheritance-1.slang b/tests/language-feature/capability/capability-inheritance-1.slang new file mode 100644 index 000000000..b8104b350 --- /dev/null +++ b/tests/language-feature/capability/capability-inheritance-1.slang @@ -0,0 +1,77 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -stage compute + +// Test if InheritanceDecl fail to conform to parent capabilities + +// mismatch of target abstract atoms +[require(hlsl)] +interface IFoo0 +{ +} +[require(hlsl)] +[require(spirv)] +// CHECK-DAG: ([[# @LINE+1]]): error 36108{{.*}}spirv +struct Foo0 : IFoo0 +{ +} + +// mismatch of target abstract atoms +[require(hlsl)] +[require(spirv)] +interface IFoo1 +{ +} +[require(hlsl)] +// CHECK-DAG: ([[# @LINE+1]]): error 36118{{.*}}spirv +struct Foo1 : IFoo1 +{ +} + +// subtype is superset +[require(sm_4_0)] +interface IFoo2 +{ +} +[require(sm_5_0)] +// CHECK-DAG: ([[# @LINE+1]]): error 36104{{.*}}sm_5_0 +struct Foo2 : IFoo2 +{ +} + +// subtype is subset, no error +[require(sm_5_0)] +interface IFoo3 +{ +} +[require(sm_4_0)] +struct Foo3 : IFoo3 +{ +} + +// mismatch of stage abstract atoms +[require(hlsl, compute)] +interface IFoo4 +{ +} +[require(hlsl, fragment)] +// CHECK-DAG: ([[# @LINE+1]]): error 36118{{.*}}compute +struct Foo4 : IFoo4 +{ +} + +// mismatch of stage abstract atoms +[require(fragment)] +[require(vertex)] +interface IFoo5 +{ +} +[require(fragment)] +// CHECK-DAG: ([[# @LINE+1]]): error 36118{{.*}}vertex +struct Foo5 : IFoo5 +{ +} + +[require(hlsl)] +[numthreads(1,1,1)] +void computeMain() +{ +} diff --git a/tests/language-feature/capability/capability-interface-requirement-1.slang b/tests/language-feature/capability/capability-interface-requirement-1.slang new file mode 100644 index 000000000..687ea51c9 --- /dev/null +++ b/tests/language-feature/capability/capability-interface-requirement-1.slang @@ -0,0 +1,56 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -stage compute + +// Test for requirment/implementation conformance given mismatch + +public interface IAtomicAddable_Error1 +{ + [require(sm_5_0, glsl)] + [require(sm_5_0, hlsl)] + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int64_t value); +} +public struct AtomicAddable_Error1 : IAtomicAddable_Error1 +{ + [require(sm_5_0, glsl)] + // CHECK: ([[# @LINE+1]]): error 36118: {{.*}}hlsl + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int64_t value) { } +} + +// ([[# @LINE-9]]): note: see declaration of 'atomicAdd' + +public interface IAtomicAddable_Error2 +{ + [require(sm_5_0, glsl)] + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int64_t value); +} +public struct AtomicAddable_Error2 : IAtomicAddable_Error2 +{ + [require(sm_5_0, glsl)] + [require(sm_5_0, hlsl)] + // CHECK: ([[# @LINE+1]]): error 36108: {{.*}}hlsl + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int64_t value) { } +} + +// ([[# @LINE-9]]): note: see declaration of 'atomicAdd' + +// Test that we do not error (should be implicitly inferring capabilities) +// CHECK-NOT: error + +public interface IAtomicAddable3 +{ + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int value); +} + +public struct AtomicAddable_Error4 : IAtomicAddable3 +{ + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int value) { buf.InterlockedAdd(addr, value); } +} + +public struct AtomicAddable_Error5 : IAtomicAddable3 +{ + public void atomicAdd(RWByteAddressBuffer buf, uint addr, int value) { buf.InterlockedAddI64(addr, value); } +} + +[numthreads(1,1,1)] +void computeMain() +{ +} diff --git a/tests/language-feature/capability/capability2.slang b/tests/language-feature/capability/capability2.slang index 6125c21d3..354b87dd5 100644 --- a/tests/language-feature/capability/capability2.slang +++ b/tests/language-feature/capability/capability2.slang @@ -12,6 +12,11 @@ interface IFoo void method2(); } +interface IFoo2 +{ + void method3(); +} + [require(spvGroupNonUniformArithmetic)] void useNonUniformArithmetic() {} @@ -39,20 +44,32 @@ struct Impl1 : IFoo } } -struct Impl2 : IFoo +struct Impl2 : IFoo, IFoo2 { - // CHECK: error 36104: {{.*}}spvGroupNonUniformArithmetic + // error here because explicit requirement is on `method1` + // CHECK: error 36104:{{.*}}spvGroupNonUniformArithmetic void method1() { - useRayQueryKHR(); // OK. - useNonUniformArithmetic(); // error. + useRayQueryKHR(); + useNonUniformArithmetic(); } + // error here because capabilities are explicitly tagged on + // the requirement parent `IFoo` // CHECK: error 36104: {{.*}}spvGroupNonUniformArithmetic void method2() { useAtomicFloat16(); - useNonUniformArithmetic(); // error. + useNonUniformArithmetic(); + } + + // do not error here because capabilities are not explicitly tagged + // on the requirement parent `IFoo2` or requirment method + // CHECK-NOT: error + void method3() + { + useAtomicFloat16(); + useNonUniformArithmetic(); } } diff --git a/tests/language-feature/capability/capabilitySimplification1.slang b/tests/language-feature/capability/capabilitySimplification1.slang index 440ac1ced..0e6303412 100644 --- a/tests/language-feature/capability/capabilitySimplification1.slang +++ b/tests/language-feature/capability/capabilitySimplification1.slang @@ -1,24 +1,13 @@ //TEST:SIMPLE(filecheck=CHECK): -target glsl -entry computeMain -stage compute -profile sm_5_0 //TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0 -ignore-capabilities - // CHECK_IGNORE_CAPS-NOT: error 36107 -// CHECK: error 36107 -// CHECK-SAME: entrypoint 'computeMain' uses features that are not available in 'compute' stage for 'glsl' target. -// CHECK: capabilitySimplification1.slang(21): note: see using of 'WaveMultiPrefixCountBits' -// CHECK-NOT: see using of 'WaveMultiPrefixCountBits' -// CHECK: {{.*}}.meta.slang({{.*}}): note: see definition of 'WaveMultiPrefixCountBits' -// CHECK: {{.*}}.meta.slang({{.*}}): note: see declaration of 'require' - -void nestedSafeCall() -{ - AllMemoryBarrier(); -} - -void nestedBadCall() +[numthreads(1, 1, 1)] +// CHECK: ([[# @LINE+1]]): error 36107: {{.*}}computeMain{{.*}}compute{{.*}}glsl +void computeMain() { - WaveMultiPrefixCountBits(true, 0); + nestedCall(); } void nestedCall() @@ -27,8 +16,13 @@ void nestedCall() nestedBadCall(); } -[numthreads(1,1,1)] -void computeMain() +void nestedSafeCall() { - nestedCall(); + AllMemoryBarrier(); } + +void nestedBadCall() +{ + // CHECK: ([[# @LINE+1]]): note: see using of 'WaveMultiPrefixCountBits' + WaveMultiPrefixCountBits(true, 0); +}
\ No newline at end of file diff --git a/tests/language-feature/capability/capabilitySimplification3.slang b/tests/language-feature/capability/capabilitySimplification3.slang deleted file mode 100644 index 150f926a9..000000000 --- a/tests/language-feature/capability/capabilitySimplification3.slang +++ /dev/null @@ -1,17 +0,0 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry computeMain -stage compute -profile sm_5_0 -//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0 -ignore-capabilities - - -// CHECK_IGNORE_CAPS-NOT: error 36107 - -// CHECK: error 36107: entrypoint 'computeMain' uses features that are not available in 'compute' stage for 'glsl' target. -// CHECK: capabilitySimplification3.slang(16): note: see using of 'WaveMultiPrefixCountBits' -// CHECK-NOT: see using of 'WaveMultiPrefixCountBits' -// CHECK: {{.*}}.meta.slang({{.*}}): note: see definition of 'WaveMultiPrefixCountBits' -// CHECK: {{.*}}.meta.slang({{.*}}): note: see declaration of 'require' - -[numthreads(1,1,1)] -void computeMain() -{ - WaveMultiPrefixCountBits(true, 0); -} diff --git a/tests/language-feature/capability/explicit-shader-stage-2.slang b/tests/language-feature/capability/explicit-shader-stage-2.slang index a01cff7c2..8ef3e158c 100644 --- a/tests/language-feature/capability/explicit-shader-stage-2.slang +++ b/tests/language-feature/capability/explicit-shader-stage-2.slang @@ -1,7 +1,7 @@ //TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_5_0 //TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -entry main -allow-glsl -profile sm_5_0 -ignore-capabilities -//CHECK: error 36107: entrypoint 'main' uses features that are not available in 'fragment' stage for 'hlsl' target. +// CHECK: error 36107: entrypoint 'main' uses features that are not available in 'fragment' stage for 'hlsl' //CHECK_IGNORE_CAPS-NOT: error 36100 [shader("fragment")] float4 main() |
