From d6130baa8528c0a5b2e1b10b87fe02d8fc1a1b1a Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 20 Nov 2017 05:28:22 -0500 Subject: fixup global generic parameters 1. simplify RoundUpToAlignment() 2. add new a render-compute test case to cover the situation where the entry-point interface (parameter/return types of an entry-point function) is dependent on the global generic type. 3. initial fixes to get this test case to compile (but is not producing correct HLSL output yet) --- .../compute/global-type-param-in-entrypoint.slang | 95 ++++++++++++++++++++++ ...bal-type-param-in-entrypoint.slang.expected.txt | 4 + 2 files changed, 99 insertions(+) create mode 100644 tests/compute/global-type-param-in-entrypoint.slang create mode 100644 tests/compute/global-type-param-in-entrypoint.slang.expected.txt (limited to 'tests/compute') diff --git a/tests/compute/global-type-param-in-entrypoint.slang b/tests/compute/global-type-param-in-entrypoint.slang new file mode 100644 index 000000000..6a7720ad6 --- /dev/null +++ b/tests/compute/global-type-param-in-entrypoint.slang @@ -0,0 +1,95 @@ +//TEST(compute):COMPARE_RENDER_COMPUTE:-xslang -use-ir +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +//TEST_INPUT: type VertImpl + +interface IVertInterpolant +{ + float4 getColor(); +} + +__generic_param TVertInterpolant : IVertInterpolant; + +struct VertImpl : IVertInterpolant +{ + float3 color; + float4 getColor() + { + return float4(1.0); + } +}; + +RWStructuredBuffer outputBuffer; + +cbuffer Uniforms +{ + float4x4 modelViewProjection; +} + +struct AssembledVertex +{ + float3 position; + TVertInterpolant interpolants; + float2 uv; +}; + +struct CoarseVertex +{ + TVertInterpolant interpolants; + float2 uv; +}; + +struct Fragment +{ + float4 color; +}; + + +// Vertex Shader + +struct VertexStageInput +{ + AssembledVertex assembledVertex : A; +}; + +struct VertexStageOutput +{ + CoarseVertex coarseVertex : CoarseVertex; + float4 sv_position : SV_Position; +}; + +VertexStageOutput vertexMain(VertexStageInput input) +{ + VertexStageOutput output; + + float3 position = input.assembledVertex.position; + output.coarseVertex.interpolants = input.assembledVertex.interpolants; + output.sv_position = mul(modelViewProjection, float4(position, 1.0)); + output.coarseVertex.uv = input.assembledVertex.uv; + return output; +} + +// Fragment Shader + +struct FragmentStageInput +{ + CoarseVertex coarseVertex : CoarseVertex; +}; + +struct FragmentStageOutput +{ + Fragment fragment : SV_Target; +}; + +FragmentStageOutput fragmentMain(FragmentStageInput input) +{ + FragmentStageOutput output; + + float4 color = input.coarseVertex.interpolants.getColor(); + float2 uv = input.coarseVertex.uv; + output.fragment.color = color; + outputBuffer[0] = color.x; + outputBuffer[1] = color.y; + outputBuffer[2] = color.z; + outputBuffer[3] = color.w; + return output; +} \ No newline at end of file diff --git a/tests/compute/global-type-param-in-entrypoint.slang.expected.txt b/tests/compute/global-type-param-in-entrypoint.slang.expected.txt new file mode 100644 index 000000000..e143b7f20 --- /dev/null +++ b/tests/compute/global-type-param-in-entrypoint.slang.expected.txt @@ -0,0 +1,4 @@ +3F800000 +3F800000 +3F800000 +3F800000 \ No newline at end of file -- cgit v1.2.3 From 43434bf993870ac19722d3a00df704df130619c1 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 21 Nov 2017 19:26:56 -0500 Subject: update input layout definition of test case `global-type-param-in-entrypoint` --- tests/compute/global-type-param-in-entrypoint.slang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/compute') diff --git a/tests/compute/global-type-param-in-entrypoint.slang b/tests/compute/global-type-param-in-entrypoint.slang index 6a7720ad6..5d8036d98 100644 --- a/tests/compute/global-type-param-in-entrypoint.slang +++ b/tests/compute/global-type-param-in-entrypoint.slang @@ -1,5 +1,6 @@ //TEST(compute):COMPARE_RENDER_COMPUTE:-xslang -use-ir -//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +//TEST_INPUT: cbuffer(data=[1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0], stride=16):dxbinding(0),glbinding(0) +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):dxbinding(1),glbinding(0),out //TEST_INPUT: type VertImpl interface IVertInterpolant -- cgit v1.2.3