Skip to content

Commit 92a48f6

Browse files
authored
Delete invalid ASSERT in isTypeOperandEqual. (shader-slang#6196)
1 parent 4b9a342 commit 92a48f6

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

source/slang/slang-ir.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -7394,8 +7394,6 @@ static bool _isTypeOperandEqual(IRInst* a, IRInst* b)
73947394
{
73957395
return _areTypeOperandsEqual(a, b);
73967396
}
7397-
SLANG_ASSERT(!"Unhandled comparison");
7398-
73997397
// We can't equate any other type..
74007398
return false;
74017399
}

tests/bugs/gh-6194.slang

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

Comments
 (0)