yum-mirror/slang

Making it easier to work with shaders

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

Yong HeDelete invalid ASSERT in `isTypeOperandEqual`. (#6196)92a48f600

master
1.5 KiB64 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv
2//CHECK: OpEntryPoint
3
4interface IMLP
5{
6    associatedtype PrecisionType : __BuiltinFloatingPointType;
7}
8static const int kSize = 4;
9float runAndSum<Pass0 : IMLP, Pass1 : IMLP>(float base)
10{
11    typealias Pass0Precision = Pass0::PrecisionType;
12    typealias WARCastPass0 = Pass0Precision;
13    typealias WARActualTypePass0 = half;
14
15    typealias Pass1Precision = Pass1::PrecisionType;
16    typealias WARCastPass1 = Pass1Precision;
17    typealias WARActualTypePass1 = half;
18
19    Pass0Precision pass0_inputs[kSize];
20    for (uint i = 0; i < kSize; ++i)
21    {
22        // pass0_inputs[i] = (base + float(i)); // Not working, WAR below
23        pass0_inputs[i] = (WARCastPass0)(base + float(i));
24    }
25
26    Pass0Precision pass0_outputs[kSize] = pass0_inputs;
27
28    Pass1Precision pass1_inputs[kSize];
29
30    for (uint i = 0; i < kSize; ++i)
31    {
32        // Fires SLANG_ASSERT(!"Unhandled comparison"); in slang-ir.cpp, _isTypeOperandEqual
33        pass1_inputs[i] = __realCast<Pass1Precision>(pass0_outputs[i]);
34
35        // Working
36        //pass1_inputs[i] = (WARCastPass1)__realCast<WARActualTypePass0>(pass0_outputs[i]);
37    }
38
39    float result = 0;
40    for (uint i = 0; i < kSize; ++i)
41    {
42        result += __realCast<WARActualTypePass1>(pass1_inputs[i]);
43    }
44
45    return result;
46};
47
48RWStructuredBuffer<float> result;
49
50struct Pass0Impl : IMLP
51{
52    typealias PrecisionType = half;
53};
54
55struct Pass1Impl : IMLP
56{
57    typealias PrecisionType = half;
58};
59
60[numthreads(1, 1, 1)]
61void test()
62{
63    result[0] = runAndSum<Pass0Impl, Pass1Impl>(3.f);
64}