From b3e0b0d491c55bfdc1c40d26a421910103c1b9f2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 28 Jan 2020 12:41:09 -0500 Subject: Synthesizing CUDA tests (#1183) * When using setUniform clamp the amount of data written to the buffer size. * CUDA implement StructuredBuffer/ByteAddressBuffer as pointer/count as is on CPU. Allow bounds check to zero index. Update docs. * Synthesize tests. * Fix bug in CUDA output. * Fixing more tests to run on CUDA. * Added BaseType for layout of Vector and Matrix - as they are held as int32_t vector array types. * Enable unbound array support on CUDA. * Added unsized array support for CUDA documentation. --- prelude/slang-cuda-prelude.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'prelude') diff --git a/prelude/slang-cuda-prelude.h b/prelude/slang-cuda-prelude.h index 63388c7f3..7e6e5957d 100644 --- a/prelude/slang-cuda-prelude.h +++ b/prelude/slang-cuda-prelude.h @@ -38,6 +38,18 @@ struct FixedArray T m_data[SIZE]; }; +// An array that has no specified size, becomes a 'Array'. This stores the size so it can potentially +// do bounds checking. +template +struct Array +{ + SLANG_CUDA_CALL const T& operator[](size_t index) const { SLANG_CUDA_BOUND_CHECK(index, count); return data[index]; } + SLANG_CUDA_CALL T& operator[](size_t index) { SLANG_CUDA_BOUND_CHECK(index, count); return data[index]; } + + T* data; + size_t count; +}; + // Typically defined in cuda.h, but we can't ship/rely on that, so just define here typedef unsigned long long CUtexObject; typedef unsigned long long CUsurfObject; @@ -49,6 +61,11 @@ typedef unsigned long long CUsurfObject; struct SamplerStateUnused; typedef SamplerStateUnused* SamplerState; + +// TODO(JS): Not clear yet if this can be handled on CUDA, by just ignoring. +// For now, just map to the index type. +typedef size_t NonUniformResourceIndex; + // Code generator will generate the specific type template struct Matrix; -- cgit v1.2.3