diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-22 17:32:15 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-22 17:32:15 -0500 |
| commit | 83d49ce376185f7dc3f40eb531f01ee350220959 (patch) | |
| tree | 7e96f26c6b6e6bf6a8b15ba1820e844e78a31394 /tests | |
| parent | 56e49feea3956d66e41b819c26628c65b3c28197 (diff) | |
| parent | 581b30dd5a4263c90539a8c5cc6063b2485885cd (diff) | |
Merge pull request #293 from csyonghe/generic-param-fix
Fixup global generic parameters
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/global-type-param-in-entrypoint.slang | 96 | ||||
| -rw-r--r-- | tests/compute/global-type-param-in-entrypoint.slang.expected.txt | 4 |
2 files changed, 100 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..5d8036d98 --- /dev/null +++ b/tests/compute/global-type-param-in-entrypoint.slang @@ -0,0 +1,96 @@ +//TEST(compute):COMPARE_RENDER_COMPUTE:-xslang -use-ir +//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 +{ + 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 |
