Debian Codegraph @

third_party/rust/metal/examples/mesh-shader/shaders.metal

raw
1 #include <metal_stdlib>
2
3 using namespace metal;
4
5 struct VertexOut {
6 float4 position [[position]];
7 };
8
9 using mesh_t = mesh<VertexOut, void, 3, 1, topology::triangle>;
10
11 [[mesh]] void mesh_function(mesh_t m) {
12 VertexOut v;
13 v.position = float4(-1.0, -1.0, 0.0, 1.0);
14
15 m.set_primitive_count(1);
16
17 m.set_vertex(0, v);
18 v.position = float4(0.0, 1.0, 0.0, 1.0);
19 m.set_vertex(1, v);
20 v.position = float4(1.0, -1.0, 0.0, 1.0);
21 m.set_vertex(2, v);
22
23 m.set_index(0, 0);
24 m.set_index(1, 1);
25 m.set_index(2, 2);
26 }
27
28 fragment half4 fragment_function() {
29 return half4(0.1, 1.0, 0.1, 1.0);
30 }