From 9c17d0be79834a8ebe2888aed8905bae355cb674 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 11 Oct 2019 14:14:08 -0400 Subject: Support for unbounded array of arrays (#1078) * WIP: Unsized arrays on CPU. * unbounded-array-of-array working on CPU. * Remove some left over comments. --- prelude/slang-cpp-types.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'prelude') diff --git a/prelude/slang-cpp-types.h b/prelude/slang-cpp-types.h index 2ba3fe19e..c8f6357a2 100644 --- a/prelude/slang-cpp-types.h +++ b/prelude/slang-cpp-types.h @@ -24,12 +24,20 @@ struct FixedArray T m_data[SIZE]; }; - -// Hmm... I guess a constant buffer should be unwrapped to be just a struct passed in -/* template -struct ConstantBuffer +// An array that has no specified size, becomes a 'Array'. This stores the size so it can potentially +// do bounds checking. +template +struct Array { -}; */ + const T& operator[](size_t index) const { SLANG_PRELUDE_ASSERT(index < count); return data[index]; } + T& operator[](size_t index) { SLANG_PRELUDE_ASSERT(index < count); return data[index]; } + + T* data; + size_t count; +}; + +/* Constant buffers become a pointer to the contained type, so ConstantBuffer becomes T* in C++ code. +*/ template struct Vector; -- cgit v1.2.3