1
+ // TEST:SIMPLE(filecheck=CHECK): -target spirv
2
+ // CHECK: OpEntryPoint
3
+
4
+ interface IMLP
5
+ {
6
+ associatedtype PrecisionType : __BuiltinFloatingPointType;
7
+ }
8
+ static const int kSize = 4 ;
9
+ float 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
+
48
+ RWStructuredBuffer < float > result;
49
+
50
+ struct Pass0Impl : IMLP
51
+ {
52
+ typealias PrecisionType = half ;
53
+ };
54
+
55
+ struct Pass1Impl : IMLP
56
+ {
57
+ typealias PrecisionType = half ;
58
+ };
59
+
60
+ [numthreads(1 , 1 , 1 )]
61
+ void test()
62
+ {
63
+ result [0 ] = runAndSum< Pass0Impl, Pass1Impl> (3 . f );
64
+ }
0 commit comments