From d108bfa677c70808b32bd77e93637ed34c19c75d Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Fri, 23 May 2025 02:22:21 -0400 Subject: Add CoopVec load/store pointer overloads (#6822) * Add pointer/T* variants for coop vec load/store * fix stride decoration and improved test * fix compile warnings * Improve test * Use `coopVecLoad` function in test --- source/slang/hlsl.meta.slang | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source/slang/hlsl.meta.slang') diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 2aa3068fa..87f98adaf 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -24170,6 +24170,7 @@ struct CoopVec : IArray, IArithmeti // /// Store all elements of this CoopVec into a buffer at a specified offset. + /// Pointer accesses are 16-byte aligned. /// @param buffer The destination buffer to store the values into. /// @param byteOffset16ByteAligned The byte offset from the start of the buffer where the data will be stored. Must be 16-byte aligned. [require(cooperative_vector)] @@ -24216,6 +24217,18 @@ struct CoopVec : IArray, IArithmeti } } + [ForceInline] + [require(spirv, cooperative_vector)] + void store(T* buffer, int32_t byteOffset16ByteAligned = 0) + { + let pointer = Ptr(buffer); + let alignment = 16; + return spirv_asm + { + OpCooperativeVectorStoreNV $pointer $byteOffset16ByteAligned $this Aligned !alignment; + }; + } + [ForceInline] [require(cooperative_vector)] [require(hlsl_coopvec_poc)] @@ -24269,6 +24282,7 @@ struct CoopVec : IArray, IArithmeti } /// Load values from a byte-addressable buffer into a cooperative vector. + /// Pointer accesses are 16-byte aligned. /// @param buffer The source buffer to load data from. /// @param byteOffset16ByteAligned The byte offset from the start of the buffer. Must be 16-byte aligned. /// @return A new cooperative vector containing the loaded values. @@ -24368,6 +24382,19 @@ struct CoopVec : IArray, IArithmeti } } + [ForceInline] + [__NoSideEffect] + [require(spirv, cooperative_vector)] + static CoopVec load(T* buffer, int32_t byteOffset16ByteAligned = 0) + { + let pointer = Ptr(buffer); + let alignment = 16; + return spirv_asm + { + result:$$CoopVec = OpCooperativeVectorLoadNV $pointer $byteOffset16ByteAligned Aligned !alignment; + }; + } + // Groupshared [ForceInline] [__NoSideEffect] @@ -25736,6 +25763,13 @@ CoopVec coopVecLoad(RWStructured return CoopVec.load(buffer, byteOffset16ByteAligned); } +[ForceInline] +[require(spirv, cooperative_vector)] +CoopVec coopVecLoad(T* buffer, int32_t byteOffset16ByteAligned = 0) +{ + return CoopVec.load(buffer, byteOffset16ByteAligned); +} + // Groupshared [ForceInline] [require(cooperative_vector)] -- cgit v1.2.3