yum-mirror/slang

Making it easier to work with shaders

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

lucy96chenShader cache bugfixes and test additions (#2467)883d9f7cc

master
1015 B53 linesraw
1// shader-cache-graphics.slang
2
3// Per-vertex attributes to be assembled from bound vertex buffers.
4struct AssembledVertex
5{
6    float3	position : POSITION;
7};
8
9// Output of the vertex shader, and input to the fragment shader.
10struct CoarseVertex
11{
12    float3 color;
13};
14
15// Output of the fragment shader
16struct Fragment
17{
18    float4 color;
19};
20
21// Vertex  Shader
22
23struct VertexStageOutput
24{
25    CoarseVertex    coarseVertex    : CoarseVertex;
26    float4          sv_position     : SV_Position;
27};
28
29[shader("vertex")]
30VertexStageOutput vertexMain(
31    AssembledVertex assembledVertex)
32{
33    VertexStageOutput output;
34
35    float3 position = assembledVertex.position;
36    float3 color    = float3(1.0, 0.0, 0.0);
37
38    output.coarseVertex.color = color;
39    output.sv_position = float4(position, 1.0);
40
41    return output;
42}
43
44// Fragment Shader
45
46[shader("fragment")]
47float4 fragmentMain(
48    CoarseVertex coarseVertex : CoarseVertex) : SV_Target
49{
50    float3 color = coarseVertex.color;
51
52    return float4(color, 1.0);
53}