yum-mirror/slang

Making it easier to work with shaders

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

ArielG-NVFix `extension` incorrectly interacting with `equality` and `type-coercion` constraints (#7578)e036c7f38

master
1.0 KiB50 linesraw
1//TEST:SIMPLE(filecheck=CHECK_FAIL): -target spirv -entry computeMain -stage compute -DFAIL
2//TEST:SIMPLE(filecheck=CHECK_PASS): -target spirv -entry computeMain -stage compute
3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -slang -compute -shaderobj -output-using-type
4
5interface ITwoParamGeneric<A, B>
6{
7    int getVal();
8}
9
10struct Foo<A, B> : ITwoParamGeneric<A, B>
11{
12    int val = 0;
13    int getVal()
14    {
15       return val; 
16    }
17}
18
19struct NotPrimitiveCastable
20{
21    double data;
22}
23
24extension<A, B> Foo<A,B> 
25    where int(A)
26#ifdef FAIL
27    where NotPrimitiveCastable(B)
28#else
29    where float(B)
30#endif
31{
32    [mutating]
33    void setVal(int dataIn)
34    {
35        val = dataIn;
36    }
37}
38
39//TEST_INPUT: set outBuffer = out ubuffer(data=[0 0 0 0], stride=4)
40RWStructuredBuffer<float4> outBuffer;
41
42void computeMain()
43{
44//CHECK_FAIL: error 30027:{{.*}}'setVal'{{.*}}'Foo<float, int>'.
45//CHECK_PASS: OpEntryPoint
46//CHECK: 3
47    Foo<float, int> x = Foo<float, int>();
48    x.setVal(3);
49    outBuffer[0] = x.getVal();
50}