Skip to content

Commit 72f7ea6

Browse files
authored
Fix for ConstantBuffer<T[...]> causing a segfault (#4705)
Fixes: #4704 Change the type we assign when getting the member variable of a legalized `ConstantBuffer<T[...]>`.
1 parent 6216177 commit 72f7ea6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

source/slang/slang-ir-lower-buffer-element-type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ namespace Slang
703703
for (UInt i = 0; i < user->getOperandCount(); i++)
704704
args.add(user->getOperand(i));
705705
auto newArrayPtrVal = builder.emitFieldAddress(
706-
getLoweredPtrLikeType(ptrVal->getDataType(), loweredElementTypeInfo.loweredInnerArrayType),
706+
builder.getPtrType(loweredElementTypeInfo.loweredInnerArrayType),
707707
ptrVal,
708708
loweredElementTypeInfo.loweredInnerStructKey);
709709
builder.replaceOperand(use, newArrayPtrVal);

tests/bugs/gh-4704.slang

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//TEST:SIMPLE(filecheck=SPIRV): -entry computeMain -stage compute -target spirv
2+
//TEST:SIMPLE(filecheck=HLSL): -entry computeMain -stage compute -target spirv
3+
//TEST:SIMPLE(filecheck=GLSL): -entry computeMain -stage compute -target spirv
4+
5+
// SPIRV: OpEntryPoint
6+
// GLSL: main
7+
// HLSL: computeMain
8+
9+
10+
[[vk::binding(0, 0)]] uniform ConstantBuffer<uint64_t[1000]> addresses;
11+
RWStructuredBuffer<uint> buffer;
12+
13+
[shader("compute")]
14+
[numthreads(1, 1, 1)]
15+
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex)
16+
{
17+
printf("\nfrom gpu: %llu", addresses[0]);
18+
}

0 commit comments

Comments
 (0)