yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

ArielG-NVError if super-type capabilities are a super-set of sub-type (#7452)07f21ee31

master
1.6 KiB77 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry main -stage compute
2//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target spirv -emit-spirv-directly -entry main -stage compute -ignore-capabilities
3// CHECK_IGNORE_CAPS-NOT: error 36104
4module test;
5
6[require(spvAtomicFloat16AddEXT)]
7interface IFoo
8{
9    [require(spvRayQueryKHR)]
10    void method1();
11
12    void method2();
13}
14
15interface IFoo2
16{
17    void method3();
18}
19
20[require(spvGroupNonUniformArithmetic)]
21void useNonUniformArithmetic()
22{}
23
24[require(spvRayQueryKHR)]
25void useRayQueryKHR()
26{}
27
28[require(spvAtomicFloat16AddEXT)]
29void useAtomicFloat16()
30{}
31
32// This should be OK, uses nothing past what is declared in the interface.
33struct Impl1 : IFoo
34{
35    void method1()
36    {
37        useAtomicFloat16();
38        useRayQueryKHR();
39    }
40
41    void method2()
42    {
43        useAtomicFloat16();
44    }
45}
46
47struct Impl2 : IFoo, IFoo2
48{
49    // error here because explicit requirement is on `method1`
50    // CHECK: error 36104:{{.*}}spvGroupNonUniformArithmetic
51    void method1()
52    {
53        useRayQueryKHR();
54        useNonUniformArithmetic();
55    }
56
57    // error here because capabilities are explicitly tagged on
58    // the requirement parent `IFoo`
59    // CHECK: error 36104: {{.*}}spvGroupNonUniformArithmetic
60    void method2()
61    {
62        useAtomicFloat16();
63        useNonUniformArithmetic();
64    }
65
66    // do not error here because capabilities are not explicitly tagged 
67    // on the requirement parent `IFoo2` or requirment method
68    // CHECK-NOT: error
69    void method3()
70    {
71        useAtomicFloat16();
72        useNonUniformArithmetic();
73    }
74}
75
76void main()
77{}