From 7826afcaad78cc33c976bb3db3cdc9eada4c77e8 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Wed, 18 Oct 2023 06:26:00 +0800 Subject: Type layouts for structured buffers with counters (#3269) * More tests for append structured buffer * Append and Consume structured buffer tests for DX12 * neaten * test wobble * Add counter layout information to append/consume structured buffers * add getRWStructuredBufferType * Correct definition of get size for append/consume structured buffers * tweak append structured buffer test * Allow initializing counter buffer in render test * vulkan test for consume structured buffer * Handle null counterVarLayout in getExplicitCounterBindingRangeOffset * remove dead code * Implement atomic counter increment/decrement for spirv * explicit spirv test * Add missing check on result * Hold on to counter resources --------- Co-authored-by: Yong He --- source/slang/slang-lower-to-ir.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index c90230c1f..2813918b6 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -8633,6 +8633,23 @@ struct DeclLoweringVisitor : DeclVisitor return v; } + void addSpecializedForTargetDecorations(IRInst* inst, Decl* decl) + { + // If this declaration was marked as being an intrinsic for a particular + // target, then we should reflect that here. + for (auto targetMod : decl->getModifiersOfType()) + { + // `targetMod` indicates that this particular declaration represents + // a specialized definition of the particular function for the given + // target, and we need to reflect that at the IR level. + + auto targetName = targetMod->targetToken.getContent(); + auto targetCap = findCapabilityAtom(targetName); + + getBuilder()->addTargetDecoration(inst, CapabilitySet(targetCap)); + } + } + // Attach target-intrinsic decorations to an instruction, // based on modifiers on an AST declaration. void addTargetIntrinsicDecorations( @@ -9170,19 +9187,7 @@ struct DeclLoweringVisitor : DeclVisitor getBuilder()->addHighLevelDeclDecoration(irFunc, decl); - // If this declaration was marked as being an intrinsic for a particular - // target, then we should reflect that here. - for (auto targetMod : decl->getModifiersOfType()) - { - // `targetMod` indicates that this particular declaration represents - // a specialized definition of the particular function for the given - // target, and we need to reflect that at the IR level. - - auto targetName = targetMod->targetToken.getContent(); - auto targetCap = findCapabilityAtom(targetName); - - getBuilder()->addTargetDecoration(irFunc, CapabilitySet(targetCap)); - } + addSpecializedForTargetDecorations(irFunc, decl); // If this declaration was marked as having a target-specific lowering // for a particular target, then handle that here. -- cgit v1.2.3