File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package (
2+ default_applicable_licenses = ["//ink:license" ],
3+ default_visibility = ["//ink:__subpackages__" ],
4+ )
5+
6+ genrule (
7+ name = "stroke_shader_metal" ,
8+ srcs = ["StrokeShader.wgsl" ],
9+ outs = [
10+ "StrokeShader_vs.metal" ,
11+ "StrokeShader_fs.metal" ,
12+ ],
13+ cmd = (
14+ "$(location //third_party/dawn:tint) $< --format msl --ep vertexMain -o $(location StrokeShader_vs.metal) && " +
15+ "$(location //third_party/dawn:tint) $< --format msl --ep fragmentMain -o $(location StrokeShader_fs.metal)"
16+ ),
17+ tools = ["//third_party/dawn:tint" ],
18+ visibility = ["//ink/ios/rendering/metal:__pkg__" ],
19+ )
Original file line number Diff line number Diff line change 1+ struct VertexOut {
2+ @builtin (position ) position : vec4 <f32 >,
3+ @location (0 ) color : vec4 <f32 >,
4+ }
5+
6+ struct Uniforms {
7+ modelTransform : mat4x4 <f32 >,
8+ viewTransform : mat4x4 <f32 >,
9+ projectionTransform : mat4x4 <f32 >,
10+ color : vec4 <f32 >,
11+ vertexStride : u32 ,
12+ }
13+
14+ @group (0 ) @binding (0 ) var <uniform > uniforms : Uniforms ;
15+ @group (0 ) @binding (1 ) var <storage , read > vertices : array <f32 >;
16+
17+ @vertex
18+ fn vertexMain (@builtin (vertex_index ) vertexID : u32 ) -> VertexOut {
19+ var out : VertexOut ;
20+ let floatOffset = (vertexID * uniforms . vertexStride ) / 4u ;
21+ let pos = vec2 <f32 >(vertices [floatOffset ], vertices [floatOffset + 1u ]);
22+
23+ out . position = uniforms . projectionTransform * uniforms . viewTransform * uniforms . modelTransform * vec4 <f32 >(pos , 0 .0 , 1 .0 );
24+ out . color = uniforms . color ;
25+ return out ;
26+ }
27+
28+ @fragment
29+ fn fragmentMain (in : VertexOut ) -> @location (0 ) vec4 <f32 > {
30+ return in . color ;
31+ }
You can’t perform that action at this time.
0 commit comments