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.2 KiB78 linesraw
1// Starting with a basic test for the ability to render stuff...
2
3//TEST(smoke,render):COMPARE_HLSL_RENDER:
4//DISABLE_TEST(smoke,render):COMPARE_HLSL_RENDER: -mtl
5
6cbuffer Uniforms
7{
8	float4x4 modelViewProjection;
9}
10
11struct AssembledVertex
12{
13	float3	position;
14	float3	color;
15};
16
17struct CoarseVertex
18{
19	float3	color;
20};
21
22struct Fragment
23{
24	float4 color;
25};
26
27
28// Vertex  Shader
29
30struct VertexStageInput
31{
32	AssembledVertex assembledVertex	: A;
33};
34
35struct VertexStageOutput
36{
37	CoarseVertex	coarseVertex	: CoarseVertex;
38	float4			sv_position		: SV_Position;
39};
40
41[shader("vertex")]
42VertexStageOutput vertexMain(VertexStageInput input)
43{
44	VertexStageOutput output;
45
46	float3 position = input.assembledVertex.position;
47	float3 color	= input.assembledVertex.color;
48
49	output.coarseVertex.color = color;
50	output.sv_position = mul(modelViewProjection, float4(position, 1.0));
51
52	return output;
53}
54
55// Fragment Shader
56
57struct FragmentStageInput
58{
59	CoarseVertex	coarseVertex	: CoarseVertex;
60};
61
62struct FragmentStageOutput
63{
64	Fragment fragment	: SV_Target;
65};
66
67[shader("fragment")]
68FragmentStageOutput fragmentMain(FragmentStageInput input)
69{
70	FragmentStageOutput output;
71
72	float3 color = input.coarseVertex.color;
73
74	output.fragment.color = float4(color, 1.0);
75
76	return output;
77}
78