summaryrefslogtreecommitdiffstats
path: root/tests/render
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-04-04 07:18:33 -0700
committerGitHub <noreply@github.com>2018-04-04 07:18:33 -0700
commit7a8ed51873743e6497db28b5a756e080491d2fa3 (patch)
treeb4f2b7e96c5cb992308500a9ac769af0309402c7 /tests/render
parent3115ba7a3640937df01ecf60f7ff55f71a3ab7c2 (diff)
Pass AST interpolation modifiers through to codegen. (#475)
This is a short-term fix, because we (1) don't have an IR-level representation of interpolation qualifiers, and (2) can't introduce one until *after* the IR-level type system is introduced (to be able to handle `struct` fields). The approach here is to find the AST-level declaration, either from layout information (in the case of an ordinary variable or function parameter), or from struct field information (because structs are being output from the AST form anyway). I've included a single end-to-end rendering test to confirm that we handle the `nointerpolation` modifier the same as HLSL. I also added the `noperspective` modifier, which seemed to be missing from our implementation.
Diffstat (limited to 'tests/render')
-rw-r--r--tests/render/nointerpolation.hlsl77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/render/nointerpolation.hlsl b/tests/render/nointerpolation.hlsl
new file mode 100644
index 000000000..11613b30e
--- /dev/null
+++ b/tests/render/nointerpolation.hlsl
@@ -0,0 +1,77 @@
+//TEST(smoke):COMPARE_HLSL_RENDER:
+
+// Confirm that the `nointerpolation` modifier
+// makes it through Slang codegen with the
+// same effect as for HLSL.
+
+cbuffer Uniforms
+{
+ float4x4 modelViewProjection;
+}
+
+struct AssembledVertex
+{
+ float3 position;
+ float3 color;
+};
+
+struct CoarseVertex
+{
+ nointerpolation float3 color;
+};
+
+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;
+ float3 color = input.assembledVertex.color;
+
+ output.coarseVertex.color = color;
+ output.sv_position = mul(modelViewProjection, float4(position, 1.0));
+
+ return output;
+}
+
+// Fragment Shader
+
+struct FragmentStageInput
+{
+ CoarseVertex coarseVertex : CoarseVertex;
+};
+
+struct FragmentStageOutput
+{
+ Fragment fragment : SV_Target;
+};
+
+FragmentStageOutput fragmentMain(FragmentStageInput input)
+{
+ FragmentStageOutput output;
+
+ float3 color = input.coarseVertex.color;
+
+ output.fragment.color = float4(color, 1.0);
+
+ return output;
+}
+