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. --- docs/cuda-target.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/cuda-target.md b/docs/cuda-target.md index 01803c145..9c82b1dc9 100644 --- a/docs/cuda-target.md +++ b/docs/cuda-target.md @@ -97,7 +97,26 @@ The UniformState and UniformEntryPointParams struct typically vary by shader. Un ## Unsized arrays -WIP: Not implemented yet. +Unsized arrays can be used, which are indicated by an array with no size as in `[]`. For example + +``` + RWStructuredBuffer arrayOfArrays[]; +``` + +With normal 'sized' arrays, the elements are just stored contiguously within wherever they are defined. With an unsized array they map to `Array` which is... + +``` + T* data; + size_t count; +``` + +Note that there is no method in the shader source to get the `count`, even though on the CUDA target it is stored and easily available. This is because of the behavior on GPU targets + +* That the count has to be stored elsewhere (unlike with CUDA) +* On some GPU targets there is no bounds checking - accessing outside the bound values can cause *undefined behavior* +* The elements may be laid out *contiguously* on GPU + +In practice this means if you want to access the `count` in shader code it will need to be passed by another mechanism - such as within a constant buffer. It is possible in the future support may be added to allow direct access of `count` work across targets transparently. ## Prelude -- cgit v1.2.3