Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8861,6 +8861,11 @@ const Expr *SpirvEmitter::collectArrayStructIndices(
}
} else if (castExpr->getCastKind() == CK_UncheckedDerivedToBase ||
castExpr->getCastKind() == CK_HLSLDerivedToBase) {
// First the indices for the sub expression.
const Expr *base =
collectArrayStructIndices(castExpr->getSubExpr(), rawIndex,
rawIndices, indices, isMSOutAttribute);

llvm::SmallVector<uint32_t, 4> BaseIdx;
getBaseClassIndices(castExpr, &BaseIdx);
if (rawIndex) {
Expand All @@ -8871,8 +8876,7 @@ const Expr *SpirvEmitter::collectArrayStructIndices(
llvm::APInt(32, Idx)));
}

return collectArrayStructIndices(castExpr->getSubExpr(), rawIndex,
rawIndices, indices, isMSOutAttribute);
return base;
}
return collectArrayStructIndices(castExpr->getSubExpr(), rawIndex,
rawIndices, indices, isMSOutAttribute);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %dxc -T cs_6_0 -E main -spirv %s | FileCheck %s

struct X { int a1; };
struct Y : X { int2 a2; };
struct Z {
X xs[2];
Y y;
};

cbuffer CBStructs : register(b0) {
Z z;
};
RWStructuredBuffer<int> Out : register(u1);

[numthreads(1,1,1)]
void main() {
// CHECK: OpAccessChain
// CHECK-SAME: %_ptr_Uniform_int
// CHECK-SAME: %CBStructs
// CHECK-SAME: %int_0
// CHECK-SAME: %int_1
// CHECK-SAME: %int_0
// CHECK-SAME: %int_0
Out[0] = z.y.a1;
}