Debian Codegraph @

third_party/rust/metal/examples/circle/shaders.metal

raw
1 #include <metal_stdlib>
2
3 #include <simd/simd.h>
4
5 using namespace metal;
6
7 typedef struct {
8 float x;
9 float y;
10 }position;
11
12 typedef struct {
13 float r;
14 float g;
15 float b;
16 }color;
17
18 typedef struct {
19 position p;
20 color c;
21 }AAPLVertex;
22
23 struct ColorInOut {
24 float4 position[[position]];
25 float4 color;
26 };
27
28 vertex ColorInOut vs(constant AAPLVertex * vertex_array[[buffer(0)]], unsigned int vid[[vertex_id]]) {
29 ColorInOut out;
30
31 out.position = float4(float2(vertex_array[vid].p.x, vertex_array[vid].p.y), 0.0, 1.0);
32 out.color = float4(float3(vertex_array[vid].c.r, vertex_array[vid].c.g, vertex_array[vid].c.b), 1.0);
33
34 return out;
35 }
36
37 fragment float4 ps(ColorInOut in [[stage_in]]) {
38 return in.color;
39 }