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-type-layout.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/slang/slang-type-layout.h') diff --git a/source/slang/slang-type-layout.h b/source/slang/slang-type-layout.h index e3dd719d6..1ebd26098 100644 --- a/source/slang/slang-type-layout.h +++ b/source/slang/slang-type-layout.h @@ -628,6 +628,10 @@ class StructuredBufferTypeLayout : public TypeLayout { public: RefPtr elementTypeLayout; + // If required, this is the VarLayout for a buffer which contains the + // counter associated with the buffer, most often used for + // AppendStructuredBuffer or ConsumeStructuredBuffer + RefPtr counterVarLayout; }; /// Type layout for a logical sequence type @@ -962,6 +966,10 @@ struct SimpleLayoutRulesImpl // End layout for a struct, and finalize its size/alignment. virtual void EndStructLayout(UniformLayoutInfo* ioStructInfo) = 0; + + // Do structured buffers need a separate binding for the counter buffer? + // (DirectX is the exception in managing these together) + virtual bool DoStructuredBuffersNeedSeparateCounterBuffer() = 0; }; struct ObjectLayoutRulesImpl @@ -1021,6 +1029,13 @@ struct LayoutRulesImpl return simpleRules->EndStructLayout(ioStructInfo); } + // Do structured buffers need a separate binding for the counter buffer? + // (DirectX is the exception in managing these together) + bool DoStructuredBuffersNeedSeparateCounterBuffer() + { + return simpleRules->DoStructuredBuffersNeedSeparateCounterBuffer(); + } + // Forward `ObjectLayoutRulesImpl` interface SimpleLayoutInfo GetObjectLayout(ShaderParameterKind kind, const ObjectLayoutRulesImpl::Options& options) @@ -1306,6 +1321,13 @@ createStructuredBufferTypeLayout( Type* structuredBufferType, Type* elementType); +RefPtr +createStructuredBufferTypeLayout( + TypeLayoutContext const& context, + ShaderParameterKind kind, + Type* structuredBufferType, + RefPtr elementTypeLayout); + /// Create a type layout for an unspecialized `globalGenericParamDecl`. RefPtr createTypeLayoutForGlobalGenericTypeParam( TypeLayoutContext const& context, -- cgit v1.2.3