From 1f401d04e32c6feaeb35243ea5bfc2b14520344b Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 20 Feb 2020 18:24:00 -0500 Subject: WIP on RWTexture types on CUDA/CPU (#1234) * CUDA support for array of resources. * * Add support for Texture2DArray on CPU * Expand texture-simple.slang to test Texture2DArray * Reorganise CUDAComputeUtil to split out createTextureResource. * Add TextureCubeArray support for CPU/CUDA targets. * Pulled out CUDAResource Renamed derived classes to reflect that change. * Creation of SurfObject type. * Functions to return read/write access for simplifying future additions. * WIP for RWTexture access on CPU/CUDA. * CUsurfObject cannot have mips. * Ability to set number of mips on test data. Preliminary support for CUsurfObj and RWTexture1D on CUDA. CUDA docs improvements. * Fix typo. --- tests/compute/rw-texture-simple.slang | 27 ++++++++++++++++++++++ tests/compute/rw-texture-simple.slang.expected.txt | 4 ++++ tests/compute/texture-simple.slang | 7 ++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/compute/rw-texture-simple.slang create mode 100644 tests/compute/rw-texture-simple.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/rw-texture-simple.slang b/tests/compute/rw-texture-simple.slang new file mode 100644 index 000000000..dde0ecd4c --- /dev/null +++ b/tests/compute/rw-texture-simple.slang @@ -0,0 +1,27 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +// Doesn't work on DX11 currently - locks up on binding +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -use-dxil +// TODO(JS): Doesn't work on vk currently, because createTextureView not implemented on vk renderer +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT: RWTexture1D(format=R_Float32, size=4, content = one):name rwt1D +RWTexture1D rwt1D; + +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(4, 4, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = dispatchThreadID.x; + float u = idx * (1.0f / 4); + + float val = 0.0f; + + val += rwt1D.Load(idx); + + outputBuffer[idx] = val; +} diff --git a/tests/compute/rw-texture-simple.slang.expected.txt b/tests/compute/rw-texture-simple.slang.expected.txt new file mode 100644 index 000000000..cc5e55ab6 --- /dev/null +++ b/tests/compute/rw-texture-simple.slang.expected.txt @@ -0,0 +1,4 @@ +3F800000 +3F800000 +3F800000 +3F800000 diff --git a/tests/compute/texture-simple.slang b/tests/compute/texture-simple.slang index 8e72250ff..df990ec7a 100644 --- a/tests/compute/texture-simple.slang +++ b/tests/compute/texture-simple.slang @@ -6,6 +6,10 @@ //DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute //TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute +// Doesn't work on CUDA, not clear why yet +//DISABLE_TEST_INPUT: Texture1D(format=R_Float32, size=4, content = one, mipMaps=1):name tLoad1D +//Texture1D tLoad1D; + //TEST_INPUT: Texture1D(size=4, content = one):name t1D Texture1D t1D; //TEST_INPUT: Texture2D(size=4, content = one):name t2D @@ -35,6 +39,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) float u = idx * (1.0f / 4); float val = 0.0f; + val += t1D.SampleLevel(samplerState, u, 0); val += t2D.SampleLevel(samplerState, float2(u, u), 0); val += t3D.SampleLevel(samplerState, float3(u, u, u), 0); @@ -44,5 +49,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) val += t2DArray.SampleLevel(samplerState, float3(u, u, 0), 0); val += tCubeArray.SampleLevel(samplerState, float4(u, u, u, 0), 0); + //val += tLoad1D.Load(int2(idx, 0)); + outputBuffer[idx] = val; } -- cgit v1.2.3