From 49067fd2e97b40649df3fa2ce096f78c2e45da5a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 21 Aug 2020 09:47:29 -0700 Subject: Fix stdlib declarations for texture Gather() (#1510) Fixes #1507 These operations were failing to take into account the way that array textures require an extra coordinate to be passed in for the primary location (but not the additional offsets). Adding `isArray` to the component count is the existing solution used for similar intrinsics elsewhere in the stdlib, and it is adopted here. Because our test framework isn't really set up to do a lot of texture testing (including having no support for texture arrays), the test added here is just a cross-compilation test that compares output with fxc for comparable input. --- tests/hlsl-intrinsic/texture/gather-texture2darray.slang | 16 ++++++++++++++++ .../texture/gather-texture2darray.slang.hlsl | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/hlsl-intrinsic/texture/gather-texture2darray.slang create mode 100644 tests/hlsl-intrinsic/texture/gather-texture2darray.slang.hlsl (limited to 'tests') diff --git a/tests/hlsl-intrinsic/texture/gather-texture2darray.slang b/tests/hlsl-intrinsic/texture/gather-texture2darray.slang new file mode 100644 index 000000000..49ce8e6a1 --- /dev/null +++ b/tests/hlsl-intrinsic/texture/gather-texture2darray.slang @@ -0,0 +1,16 @@ +// gather-texture2darray.slang + +//TEST:CROSS_COMPILE: -target dxbc -profile sm_5_1 -entry main -stage compute + +// Test gathering from a `Texture2DArray` + +Texture2DArray t; +SamplerState s; +RWBuffer b; + +[shader("compute")] +[numthreads(32, 1, 1)] +void main(uint3 tid : SV_DispatchThreadID) +{ + b[tid.x] = t.Gather(s, tid); +} diff --git a/tests/hlsl-intrinsic/texture/gather-texture2darray.slang.hlsl b/tests/hlsl-intrinsic/texture/gather-texture2darray.slang.hlsl new file mode 100644 index 000000000..de07f93ca --- /dev/null +++ b/tests/hlsl-intrinsic/texture/gather-texture2darray.slang.hlsl @@ -0,0 +1,14 @@ +// gather-texture2darray.slang.hlsl + +//TEST_IGNORE_FILE: + +Texture2DArray t_0; +SamplerState s_0; +RWBuffer b_0; + +[shader("compute")] +[numthreads(32, 1, 1)] +void main(uint3 tid : SV_DISPATCHTHREADID) +{ + b_0[tid.x] = t_0.Gather(s_0, tid); +} -- cgit v1.2.3