From 6f5c250b19b03a8eb4b6a9254613ce8539769a23 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 23 Apr 2020 14:40:01 -0400 Subject: Small improvements around atomics (#1333) * Use the original value in the test. Run test on VK. * Added RWBuffer and Buffer types to C++ prelude. * Add vk to atomics.slang tests * Update target-compatibility around atomics. When tests disabled in atomics-buffer.slang explained why. * tabs -> spaces. * Small docs improvement. --- prelude/slang-cpp-types.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'prelude/slang-cpp-types.h') diff --git a/prelude/slang-cpp-types.h b/prelude/slang-cpp-types.h index 415d7f941..d57ac0e09 100644 --- a/prelude/slang-cpp-types.h +++ b/prelude/slang-cpp-types.h @@ -116,6 +116,29 @@ struct StructuredBuffer size_t count; }; + +template +struct RWBuffer +{ + SLANG_FORCE_INLINE T& operator[](size_t index) const { SLANG_PRELUDE_ASSERT(index < count); return data[index]; } + const T& Load(size_t index) const { SLANG_PRELUDE_ASSERT(index < count); return data[index]; } + void GetDimensions(uint32_t& outCount) { outCount = uint32_t(count); } + + T* data; + size_t count; +}; + +template +struct Buffer +{ + SLANG_FORCE_INLINE const T& operator[](size_t index) const { SLANG_PRELUDE_ASSERT(index < count); return data[index]; } + const T& Load(size_t index) const { SLANG_PRELUDE_ASSERT(index < count); return data[index]; } + void GetDimensions(uint32_t& outCount) { outCount = uint32_t(count); } + + T* data; + size_t count; +}; + // Missing Load(_In_ int Location, _Out_ uint Status); struct ByteAddressBuffer { -- cgit v1.2.3