From fd056b0b2c20949654d28b2a25efc60627c4f0b7 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 13 Nov 2017 18:22:03 -0500 Subject: Legalization of function parameter types. This commit fixes issue #275 This commit includes following changes: 1. legalize function parameter IRParam instructions 2. legalize function parameter types in IRFuncType 3. legalize call sites (IRCall) with proper arguments 4. legalize local vars that has a mixed resource type. --- tests/compute/func-param-legalize.slang | 35 ++++++++++++++++++++++ .../compute/func-param-legalize.slang.expected.txt | 4 +++ 2 files changed, 39 insertions(+) create mode 100644 tests/compute/func-param-legalize.slang create mode 100644 tests/compute/func-param-legalize.slang.expected.txt (limited to 'tests/compute') diff --git a/tests/compute/func-param-legalize.slang b/tests/compute/func-param-legalize.slang new file mode 100644 index 000000000..285fcfbb7 --- /dev/null +++ b/tests/compute/func-param-legalize.slang @@ -0,0 +1,35 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:Texture2D(size=4, content = one) : dxbinding(0),glbinding(0) +//TEST_INPUT: Sampler : dxbinding(0),glbinding(0,1,2,3,4,5,6) +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +struct Param +{ + Texture2D tex; + SamplerState samplerState; + float base; +}; + +Texture2D diffuseMap; +SamplerState samplerState; +RWStructuredBuffer outputBuffer; + +float4 run(Param p) +{ + return p.tex.SampleLevel(p.samplerState, float2(0.0), 0) + p.base; +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + Param p; + p.tex = diffuseMap; + p.samplerState = samplerState; + p.base = -0.5; + float4 outVal = run(p); + + outputBuffer[0] = outVal.x; + outputBuffer[1] = outVal.y; + outputBuffer[2] = outVal.z; + outputBuffer[3] = outVal.w; +} \ No newline at end of file diff --git a/tests/compute/func-param-legalize.slang.expected.txt b/tests/compute/func-param-legalize.slang.expected.txt new file mode 100644 index 000000000..e4e4c642a --- /dev/null +++ b/tests/compute/func-param-legalize.slang.expected.txt @@ -0,0 +1,4 @@ +3F000000 +3F000000 +3F000000 +3F000000 -- cgit v1.2.3