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
962 B41 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
5struct Foo<each A>
6{
7    int val = 0;
8    int getVal()
9    {
10       return val; 
11    }
12}
13
14extension<each A> Foo<A>
15    where A == int
16{
17    [mutating]
18    void setVal1(int dataIn)
19    {
20        val += dataIn;
21    }
22}
23
24//TEST_INPUT: set outBuffer = out ubuffer(data=[0 0 0 0], stride=4)
25RWStructuredBuffer<float4> outBuffer;
26
27void computeMain()
28{
29//CHECK_FAIL: error 30027: 'setVal1'{{.*}}'Foo<float>'
30//CHECK_PASS: OpEntryPoint
31//CHECK: 3
32#ifdef FAIL
33    // fails since while expanding A and applying `where`,
34    // we will find a `float`, not a `int`
35    Foo<float> x = Foo<float>();
36#else
37    Foo<int> x = Foo<int>();
38#endif
39    x.setVal1(3);
40    outBuffer[0] = x.getVal();
41}