forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh-6194.slang
64 lines (51 loc) · 1.55 KB
/
gh-6194.slang
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//TEST:SIMPLE(filecheck=CHECK): -target spirv
//CHECK: OpEntryPoint
interface IMLP
{
associatedtype PrecisionType : __BuiltinFloatingPointType;
}
static const int kSize = 4;
float runAndSum<Pass0 : IMLP, Pass1 : IMLP>(float base)
{
typealias Pass0Precision = Pass0::PrecisionType;
typealias WARCastPass0 = Pass0Precision;
typealias WARActualTypePass0 = half;
typealias Pass1Precision = Pass1::PrecisionType;
typealias WARCastPass1 = Pass1Precision;
typealias WARActualTypePass1 = half;
Pass0Precision pass0_inputs[kSize];
for (uint i = 0; i < kSize; ++i)
{
// pass0_inputs[i] = (base + float(i)); // Not working, WAR below
pass0_inputs[i] = (WARCastPass0)(base + float(i));
}
Pass0Precision pass0_outputs[kSize] = pass0_inputs;
Pass1Precision pass1_inputs[kSize];
for (uint i = 0; i < kSize; ++i)
{
// Fires SLANG_ASSERT(!"Unhandled comparison"); in slang-ir.cpp, _isTypeOperandEqual
pass1_inputs[i] = __realCast<Pass1Precision>(pass0_outputs[i]);
// Working
//pass1_inputs[i] = (WARCastPass1)__realCast<WARActualTypePass0>(pass0_outputs[i]);
}
float result = 0;
for (uint i = 0; i < kSize; ++i)
{
result += __realCast<WARActualTypePass1>(pass1_inputs[i]);
}
return result;
};
RWStructuredBuffer<float> result;
struct Pass0Impl : IMLP
{
typealias PrecisionType = half;
};
struct Pass1Impl : IMLP
{
typealias PrecisionType = half;
};
[numthreads(1, 1, 1)]
void test()
{
result[0] = runAndSum<Pass0Impl, Pass1Impl>(3.f);
}