Skip to content

Commit

Permalink
Fix for ConstantBuffer<T[...]> causing a segfault (#4705)
Browse files Browse the repository at this point in the history
Fixes: #4704

Change the type we assign when getting the member variable of a legalized `ConstantBuffer<T[...]>`.
  • Loading branch information
ArielG-NV authored Jul 23, 2024
1 parent 6216177 commit 72f7ea6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/slang/slang-ir-lower-buffer-element-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ namespace Slang
for (UInt i = 0; i < user->getOperandCount(); i++)
args.add(user->getOperand(i));
auto newArrayPtrVal = builder.emitFieldAddress(
getLoweredPtrLikeType(ptrVal->getDataType(), loweredElementTypeInfo.loweredInnerArrayType),
builder.getPtrType(loweredElementTypeInfo.loweredInnerArrayType),
ptrVal,
loweredElementTypeInfo.loweredInnerStructKey);
builder.replaceOperand(use, newArrayPtrVal);
Expand Down
18 changes: 18 additions & 0 deletions tests/bugs/gh-4704.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//TEST:SIMPLE(filecheck=SPIRV): -entry computeMain -stage compute -target spirv
//TEST:SIMPLE(filecheck=HLSL): -entry computeMain -stage compute -target spirv
//TEST:SIMPLE(filecheck=GLSL): -entry computeMain -stage compute -target spirv

// SPIRV: OpEntryPoint
// GLSL: main
// HLSL: computeMain


[[vk::binding(0, 0)]] uniform ConstantBuffer<uint64_t[1000]> addresses;
RWStructuredBuffer<uint> buffer;

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex)
{
printf("\nfrom gpu: %llu", addresses[0]);
}

0 comments on commit 72f7ea6

Please sign in to comment.