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
11 changes: 11 additions & 0 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,17 @@ void SpirvEmitter::doReturnStmt(const ReturnStmt *stmt) {
bool returnsVoid = curFunction->getReturnType().getTypePtr()->isVoidType();
if (!returnsVoid) {
assert(retVal);
const Expr *srcExpr = retVal->IgnoreParenCasts();
if (isDescriptorHeap(srcExpr)) {
const Expr *base = nullptr;
getDescriptorHeapOperands(srcExpr, &base, /* index= */ nullptr);
const Expr *parentExpr = cast<CastExpr>(parentMap->getParent(srcExpr));
QualType resourceType = parentExpr->getType();
const auto *declRefExpr = dyn_cast<DeclRefExpr>(base->IgnoreCasts());
auto *decl = cast<VarDecl>(declRefExpr->getDecl());
declIdMapper.createResourceHeap(decl, resourceType);
}

// Update counter variable associated with function returns
tryToAssignCounterVar(curFunction, retVal);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %dxc -T cs_6_6 -E main -fcgl %s -spirv | FileCheck %s

RWStructuredBuffer<uint> GetBindlessResource_UIntBuffer() {
return ResourceDescriptorHeap[0];
}

[numthreads(1, 1, 1)]
void main() {
// CHECK-DAG: OpDecorate %ResourceDescriptorHeap DescriptorSet 0
// CHECK-DAG: OpDecorate %ResourceDescriptorHeap Binding 0
// CHECK-DAG: OpDecorate %counter_var_ResourceDescriptorHeap DescriptorSet 0
// CHECK-DAG: OpDecorate %counter_var_ResourceDescriptorHeap Binding 1
RWStructuredBuffer<uint> a = GetBindlessResource_UIntBuffer();

a.IncrementCounter();
}