Skip to content

Commit

Permalink
Fix the logic to determine whether lower generic pass should run. (#5837
Browse files Browse the repository at this point in the history
)
  • Loading branch information
csyonghe authored Dec 11, 2024
1 parent 0af589b commit c17369a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/slang/slang-emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,14 @@ void calcRequiredLoweringPassSet(
{
// If any instruction has an interface type, we need to run
// the generics lowering pass.
auto type = inst->getDataType();
auto type = as<IRType>(inst) ? inst : inst->getDataType();
for (;;)
{
if (auto ptrType = as<IRPtrTypeBase>(type))
type = ptrType->getValueType();
else
break;
}
if (type && type->getOp() == kIROp_InterfaceType)
{
result.generics = true;
Expand Down
20 changes: 20 additions & 0 deletions tests/bugs/ptr-existential.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//TEST:SIMPLE(filecheck=CHECK): -target spirv

//CHECK: OpEntryPoint

interface IBsdf {};
struct Foo : IBsdf {}
//TEST_INPUT:type_conformance Foo:IBsdf = 0
struct Mesh {
float4 *vertices;
IBsdf *bsdf;
}
[[vk::push_constant]] Mesh* mesh;
RWStructuredBuffer<float4> outputBuffer;

[shader("compute")]
[numthreads(1, 1, 1)]
void main(uint3 dispatchThreadID: SV_DispatchThreadID)
{
outputBuffer[0] = mesh.vertices[0];
}

0 comments on commit c17369a

Please sign in to comment.