summaryrefslogtreecommitdiff
path: root/prelude
diff options
context:
space:
mode:
Diffstat (limited to 'prelude')
-rw-r--r--prelude/slang-cuda-prelude.h17
1 files changed, 17 insertions, 0 deletions
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 <typename T>
+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 <typename T, int ROWS, int COLS>
struct Matrix;