Skip to content

Commit

Permalink
Fix bug in translateGlslGlobalVar(). (#5181)
Browse files Browse the repository at this point in the history
  • Loading branch information
csyonghe authored Sep 28, 2024
1 parent 5a84e52 commit c55805e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/slang/slang-ir-translate-glsl-global-var.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Slang
buildEntryPointReferenceGraph(referencingEntryPoints, module);

List<IRInst*> entryPoints;
List<IRInst*> getWorkGroupSizeInsts;

// Traverse the module to find all entry points.
// If we see a `GetWorkGroupSize` instruction, we will materialize it.
//
Expand All @@ -25,9 +27,10 @@ namespace Slang
if (inst->getOp() == kIROp_Func && inst->findDecoration<IREntryPointDecoration>())
entryPoints.add(inst);
else if (inst->getOp() == kIROp_GetWorkGroupSize)
materializeGetWorkGroupSize(module, referencingEntryPoints, inst);
getWorkGroupSizeInsts.add(inst);
}

for (auto inst : getWorkGroupSizeInsts)
materializeGetWorkGroupSize(module, referencingEntryPoints, inst);
IRBuilder builder(module);

for (auto entryPoint : entryPoints)
Expand Down
16 changes: 16 additions & 0 deletions tests/bugs/gh-5027.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-d3d11 -output-using-type

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;

in uint3 gid : SV_GroupID;

[numthreads(1,1,1)]
void computeMain()
{
uint expr = WorkgroupSize().x + gid.x;
// CHECK: type: uint32_t
// CHECK: 2
outputBuffer[0] = expr + 1;
}

0 comments on commit c55805e

Please sign in to comment.