summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-22 23:21:50 -0700
committerGitHub <noreply@github.com>2023-08-22 23:21:50 -0700
commit036a2b78151816075f1c86221028f0ebdff3c8a5 (patch)
tree24c69f2d0a89f1bdb1024e7798aefaa7061b2acb /source
parente2e10fb6b065ff78f40ff19e01a7fdd234b1b560 (diff)
Make `-fvk-u-shift` work on AppendStructuredBuffer. (#3144)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-lower-append-consume-structured-buffer.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-ir-lower-append-consume-structured-buffer.cpp b/source/slang/slang-ir-lower-append-consume-structured-buffer.cpp
index fa9f16223..eeafd1866 100644
--- a/source/slang/slang-ir-lower-append-consume-structured-buffer.cpp
+++ b/source/slang/slang-ir-lower-append-consume-structured-buffer.cpp
@@ -177,13 +177,29 @@ namespace Slang
IRBuilder subBuilder(typeUser);
IRVarLayout::Builder newVarLayoutBuilder(&subBuilder, typeLayout);
newVarLayoutBuilder.cloneEverythingButOffsetsFrom(varLayout);
+ IRVarOffsetAttr* uavOffsetAttr = nullptr;
+ IRVarOffsetAttr* descriptorTableSlotOffsetAttr = nullptr;
+
for (auto offsetAttr : varLayout->getOffsetAttrs())
{
+ if (offsetAttr->getResourceKind() == LayoutResourceKind::UnorderedAccess)
+ uavOffsetAttr = offsetAttr;
+ else if (offsetAttr->getResourceKind() == LayoutResourceKind::DescriptorTableSlot)
+ descriptorTableSlotOffsetAttr = offsetAttr;
auto info = newVarLayoutBuilder.findOrAddResourceInfo(offsetAttr->getResourceKind());
info->offset = offsetAttr->getOffset();
info->space = offsetAttr->getSpace();
info->kind = offsetAttr->getResourceKind();
}
+ // If the user provided an layout offset for UAV but not for descriptor table slot, then
+ // we use the UAV offset for the descriptor table slot offset.
+ if (uavOffsetAttr && !descriptorTableSlotOffsetAttr)
+ {
+ auto info = newVarLayoutBuilder.findOrAddResourceInfo(LayoutResourceKind::DescriptorTableSlot);
+ info->offset = uavOffsetAttr->getOffset();
+ info->space = uavOffsetAttr->getSpace();
+ info->kind = LayoutResourceKind::DescriptorTableSlot;
+ }
auto newVarLayout = newVarLayoutBuilder.build();
subBuilder.addLayoutDecoration(typeUser, newVarLayout);
varLayout->removeAndDeallocate();