yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Anders LeinoMigrate render-test away from deprecated compile request API (#6514)f4d5372d3

master
1.3 KiB81 linesraw
1//TEST(smoke):COMPARE_HLSL_RENDER:
2// TODO: Investigate Metal failure
3//DISABLE_TEST(smoke):COMPARE_HLSL_RENDER: -mtl
4
5// Confirm that the `nointerpolation` modifier
6// makes it through Slang codegen with the
7// same effect as for HLSL.
8
9cbuffer Uniforms
10{
11	float4x4 modelViewProjection;
12}
13
14struct AssembledVertex
15{
16	float3	position;
17	float3	color;
18};
19
20struct CoarseVertex
21{
22	nointerpolation float3	color;
23};
24
25struct Fragment
26{
27	float4 color;
28};
29
30
31// Vertex  Shader
32
33struct VertexStageInput
34{
35	AssembledVertex assembledVertex	: A;
36};
37
38struct VertexStageOutput
39{
40	CoarseVertex	coarseVertex	: CoarseVertex;
41	float4			sv_position		: SV_Position;
42};
43
44[shader("vertex")]
45VertexStageOutput vertexMain(VertexStageInput input)
46{
47	VertexStageOutput output;
48
49	float3 position = input.assembledVertex.position;
50	float3 color	= input.assembledVertex.color;
51
52	output.coarseVertex.color = color;
53	output.sv_position = mul(modelViewProjection, float4(position, 1.0));
54
55	return output;
56}
57
58// Fragment Shader
59
60struct FragmentStageInput
61{
62	CoarseVertex	coarseVertex	: CoarseVertex;
63};
64
65struct FragmentStageOutput
66{
67	Fragment fragment	: SV_Target;
68};
69
70[shader("fragment")]
71FragmentStageOutput fragmentMain(FragmentStageInput input)
72{
73	FragmentStageOutput output;
74
75	float3 color = input.coarseVertex.color;
76
77	output.fragment.color = float4(color, 1.0);
78
79	return output;
80}
81