Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/metal/Shaders.metal

Issue 2651743007: Add metal view, shaders and renderer. (Closed)
Patch Set: Add metal renderer protocol and rename implementation classes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
kthelgason 2017/02/03 09:17:23 Missing copyright header
daniela-webrtc 2017/02/07 10:51:09 Done.
2 #include <metal_stdlib>
3 #include <simd/simd.h>
4
5 using namespace metal;
6
7 typedef struct {
8 packed_float2 position;
9 packed_float2 texcoord;
10 } Vertex;
11
12
13 typedef struct {
14 float4 position [[position]];
15 float2 texcoord;
16 } Varyings;
17
18 vertex Varyings vertexPassthrough(
19 device Vertex* verticies [[ buffer(0) ]],
20 unsigned int vid [[ vertex_id ]]
21 ) {
22 Varyings out;
23
24 device Vertex& v = verticies[vid];
25
26 out.position = float4(float2(v.position), 0.0, 1.0);
27
28 out.texcoord = v.texcoord;
29
30 return out;
31 }
32
33 fragment half4 fragmentColorConversion(
34 Varyings in [[ stage_in ]],
35 texture2d<float, access::sample> textureY [[ texture(0) ]],
36 texture2d<float, access::sample> textureC bCr [[ texture(1) ]]
37 ) {
38 constexpr sampler s(address::clamp_to_edge, filter::linear);
39 float y;
40 float2 uv;
41 y = textureY.sample(s, in.texcoord).r;
42 uv = textureCbCr.sample(s, in.texcoord).rg - float2(0.5,0.5);
43
44 float4 out = float4(y + 1.403 * uv.y,
45 y - 0.344 * uv.x - 0.714 * uv.y,
46 y + 1.770 * uv.x,
47 1.0);
48
49 return half4(out);
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698