diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-20 05:28:22 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-11-20 05:28:22 -0500 |
| commit | d6130baa8528c0a5b2e1b10b87fe02d8fc1a1b1a (patch) | |
| tree | 6aa5b2fe3a0fbfd8d2a02b38da9ca96f9fbd10ef /tests/compute | |
| parent | 3dff5a53a21ab2404918e772962004767024c0f3 (diff) | |
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)
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/global-type-param-in-entrypoint.slang | 95 | ||||
| -rw-r--r-- | tests/compute/global-type-param-in-entrypoint.slang.expected.txt | 4 |
2 files changed, 99 insertions, 0 deletions
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<float> 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 |
