blob: 68ad1111aeb1226eb84aa00895281e2f34f07039 (
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
|
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type
// Test that we can disambiguiate subscript decls by prefering the candidate that contains a super set of
// accessors than the other candidates.
interface IBuf<T>
{
T read(int x);
}
interface IRWBuf<T> : IBuf<T>
{
[mutating]
void write(int x, T v);
}
extension<T, U : IBuf<T>> U
{
__subscript(int x) -> T { get { return read(x); } }
}
extension<T, U : IRWBuf<T>> U
{
__subscript(int x)->T { get { return read(x); } set { write(x, newValue); } }
}
struct MyArray<T> : IRWBuf<T>
{
T data[4];
T read(int x) { return data[x]; }
[mutating]
void write(int x, T v) { data[x] = v; }
}
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(1,1,1)]
void computeMain()
{
MyArray<int> arr = {{1, 2, 3, 4}};
arr[0] = 1;
arr[1] = 2;
// CHECK: 1
// CHECK: 2
outputBuffer[0] = arr[0];
outputBuffer[1] = arr[1];
}
|