Skip to content

Commit c17369a

Browse files
authored
Fix the logic to determine whether lower generic pass should run. (#5837)
1 parent 0af589b commit c17369a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

source/slang/slang-emit.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,14 @@ void calcRequiredLoweringPassSet(
429429
{
430430
// If any instruction has an interface type, we need to run
431431
// the generics lowering pass.
432-
auto type = inst->getDataType();
432+
auto type = as<IRType>(inst) ? inst : inst->getDataType();
433+
for (;;)
434+
{
435+
if (auto ptrType = as<IRPtrTypeBase>(type))
436+
type = ptrType->getValueType();
437+
else
438+
break;
439+
}
433440
if (type && type->getOp() == kIROp_InterfaceType)
434441
{
435442
result.generics = true;

tests/bugs/ptr-existential.slang

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//TEST:SIMPLE(filecheck=CHECK): -target spirv
2+
3+
//CHECK: OpEntryPoint
4+
5+
interface IBsdf {};
6+
struct Foo : IBsdf {}
7+
//TEST_INPUT:type_conformance Foo:IBsdf = 0
8+
struct Mesh {
9+
float4 *vertices;
10+
IBsdf *bsdf;
11+
}
12+
[[vk::push_constant]] Mesh* mesh;
13+
RWStructuredBuffer<float4> outputBuffer;
14+
15+
[shader("compute")]
16+
[numthreads(1, 1, 1)]
17+
void main(uint3 dispatchThreadID: SV_DispatchThreadID)
18+
{
19+
outputBuffer[0] = mesh.vertices[0];
20+
}

0 commit comments

Comments
 (0)