yum-mirror/slang

Making it easier to work with shaders

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

Julius IkkalaFix #7232 (#7236)8ecb2c704

master
1.4 KiB59 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -dx12
3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu
4
5// CHECK: 5
6// CHECK-NEXT: 5
7// CHECK-NEXT: 5
8// CHECK-NEXT: 1
9// CHECK-NEXT: 1
10// CHECK-NEXT: 1
11// CHECK-NEXT: 1
12
13//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
14RWStructuredBuffer<int> outputBuffer;
15
16interface IFoo
17{
18    property uint value { get; }
19};
20
21struct Foo : IFoo 
22{
23    property uint value
24    {
25        get { return _value; }
26    }
27
28    uint _value;
29};
30
31void issue1(Foo foo)
32{
33    int array[10] = {0,1,2,3,4,5,6,7,8,9};
34    outputBuffer[0] = array[foo._value]; // ok
35    outputBuffer[1] = array[uint(foo.value)]; // ok
36    outputBuffer[2] = array[foo.value]; // Used to cause error, 'value' was not resolved before checking that it's an integer
37}
38
39void issue2(Foo foo, uint arg)
40{
41    bool b1 = foo._value < arg; // ok
42    bool b2 = uint(foo.value) < arg; // ok
43    bool b3 = foo.value < arg; // Used to crash the compiler
44    bool b4 = foo.value > arg; // ok
45    if (b1) outputBuffer[3] = 1;
46    if (b2) outputBuffer[4] = 1;
47    if (b3) outputBuffer[5] = 1;
48    if (!b4) outputBuffer[6] = 1;
49}
50
51[numthreads(1, 1, 1)]
52void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
53{
54    Foo foo;
55    foo._value = 5;
56    issue1(foo);
57    foo._value = 42;
58    issue2(foo, 43);
59}