summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/capability/capability2.slang
blob: 354b87dd5ce46f9e377fe5945076a6305fd2102b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry main -stage compute
//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target spirv -emit-spirv-directly -entry main -stage compute -ignore-capabilities
// CHECK_IGNORE_CAPS-NOT: error 36104
module test;

[require(spvAtomicFloat16AddEXT)]
interface IFoo
{
    [require(spvRayQueryKHR)]
    void method1();

    void method2();
}

interface IFoo2
{
    void method3();
}

[require(spvGroupNonUniformArithmetic)]
void useNonUniformArithmetic()
{}

[require(spvRayQueryKHR)]
void useRayQueryKHR()
{}

[require(spvAtomicFloat16AddEXT)]
void useAtomicFloat16()
{}

// This should be OK, uses nothing past what is declared in the interface.
struct Impl1 : IFoo
{
    void method1()
    {
        useAtomicFloat16();
        useRayQueryKHR();
    }

    void method2()
    {
        useAtomicFloat16();
    }
}

struct Impl2 : IFoo, IFoo2
{
    // error here because explicit requirement is on `method1`
    // CHECK: error 36104:{{.*}}spvGroupNonUniformArithmetic
    void method1()
    {
        useRayQueryKHR();
        useNonUniformArithmetic();
    }

    // error here because capabilities are explicitly tagged on
    // the requirement parent `IFoo`
    // CHECK: error 36104: {{.*}}spvGroupNonUniformArithmetic
    void method2()
    {
        useAtomicFloat16();
        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();
    }
}

void main()
{}