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. --- tools/render-test/cuda/cuda-compute-util.cpp | 12 +++++++----- tools/render-test/cuda/cuda-compute-util.h | 5 +++++ tools/render-test/render-test-main.cpp | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'tools/render-test') diff --git a/tools/render-test/cuda/cuda-compute-util.cpp b/tools/render-test/cuda/cuda-compute-util.cpp index aa82d8d70..a50295063 100644 --- a/tools/render-test/cuda/cuda-compute-util.cpp +++ b/tools/render-test/cuda/cuda-compute-util.cpp @@ -572,13 +572,15 @@ static SlangResult _compute(CUcontext context, CUmodule module, const ShaderComp auto elementCount = int(typeLayout->getElementCount()); if (elementCount == 0) { - void** array = location.getUniform(); - // If set, we setup the data needed for array on CPU side - if (value && array) + CUDAComputeUtil::Array array = { nullptr, 0 }; + auto resource = CUDAResource::getCUDAResource(value); + if (resource) { - // TODO(JS): For now we'll just assume a pointer... - *array = CUDAResource::getCUDAData(value); + array.data = resource->m_cudaMemory; + array.count = value->m_elementCount; } + + location.setUniform(&array, sizeof(array)); } break; } diff --git a/tools/render-test/cuda/cuda-compute-util.h b/tools/render-test/cuda/cuda-compute-util.h index ea58b6343..f739ade91 100644 --- a/tools/render-test/cuda/cuda-compute-util.h +++ b/tools/render-test/cuda/cuda-compute-util.h @@ -21,6 +21,11 @@ struct CUDAComputeUtil void* data; size_t count; }; + struct Array + { + void* data; + size_t count; + }; struct Context { diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 050a6d2c8..16f2d78d1 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -600,9 +600,17 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe #if RENDER_TEST_CUDA + const uint64_t startTicks = ProcessUtil::getClockTick(); + CUDAComputeUtil::Context context; SLANG_RETURN_ON_FAIL(CUDAComputeUtil::execute(compilationAndLayout, context)); + if (gOptions.performanceProfile) + { + const uint64_t endTicks = ProcessUtil::getClockTick(); + _outputProfileTime(startTicks, endTicks); + } + if (gOptions.outputPath) { // Dump everything out that was written -- cgit v1.2.3