summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/capability/capability-interface-requirement-1.slang
blob: 687ea51c970909929a719f6a6eca9337ab71a3af (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
//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()
{
}