From fab1c9f4c745ba84983c2448646376799d461e96 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 9 Oct 2020 11:29:11 -0700 Subject: Support CUDA bindless texture in dynamic dispatch code. (#1575) --- .../dynamic-dispatch-bindless-texture.slang | 40 ++++++++++++++++++++++ ...ic-dispatch-bindless-texture.slang.expected.txt | 4 +++ 2 files changed, 44 insertions(+) create mode 100644 tests/compute/dynamic-dispatch-bindless-texture.slang create mode 100644 tests/compute/dynamic-dispatch-bindless-texture.slang.expected.txt (limited to 'tests/compute') diff --git a/tests/compute/dynamic-dispatch-bindless-texture.slang b/tests/compute/dynamic-dispatch-bindless-texture.slang new file mode 100644 index 000000000..49265fac4 --- /dev/null +++ b/tests/compute/dynamic-dispatch-bindless-texture.slang @@ -0,0 +1,40 @@ +// Test using interface typed shader parameters with texture typed fields. +//TEST(compute):COMPARE_COMPUTE:-cpu +//TEST(compute):COMPARE_COMPUTE:-cuda + +[anyValueSize(8)] +interface IInterface +{ + float run(); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer gOutputBuffer; +//TEST_INPUT: Texture2D(size=8, content = one):name t2D,bindless +//TEST_INPUT:ubuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) handle(t2D) 0 0], stride=4):name=gCb +StructuredBuffer gCb; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + let tid = dispatchThreadID.x; + + let inputVal : int = tid; + IInterface v0 = gCb.Load(0); + SamplerState sampler; + let outputVal = v0.run(); + gOutputBuffer[tid] = trunc(outputVal); +} + +//TEST_INPUT: globalExistentialType __Dynamic + +// Type must be marked `public` to ensure it is visible in the generated DLL. +public struct MyImpl : IInterface +{ + Texture2D tex; + SamplerState sampler; + float run() + { + return tex.Sample(sampler, float2(0.0, 0.0)).x; + } +}; diff --git a/tests/compute/dynamic-dispatch-bindless-texture.slang.expected.txt b/tests/compute/dynamic-dispatch-bindless-texture.slang.expected.txt new file mode 100644 index 000000000..98fb6a686 --- /dev/null +++ b/tests/compute/dynamic-dispatch-bindless-texture.slang.expected.txt @@ -0,0 +1,4 @@ +1 +1 +1 +1 -- cgit v1.2.3