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

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

Issue 2651743007: Add metal view, shaders and renderer. (Closed)
Patch Set: Link metal libraries only for arm64cpu 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 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <metal_stdlib>
12 #include <simd/simd.h>
13
14 using namespace metal;
tkchin_webrtc 2017/02/10 23:32:10 It is kinda burdensome to force users to include t
daniela-webrtc 2017/02/13 12:32:06 Yes it can be done like that as well. I managed to
tkchin_webrtc 2017/02/14 00:23:55 I'm slightly worried about how to compile dynamic
15
16 typedef struct {
17 packed_float2 position;
18 packed_float2 texcoord;
19 } Vertex;
20
21
22 typedef struct {
23 float4 position [[position]];
24 float2 texcoord;
25 } Varyings;
26
27 vertex Varyings vertexPassthrough(
28 device Vertex* verticies [[ buffer(0) ]],
29 unsigned int vid [[ vertex_id ]]
30 ) {
31 Varyings out;
32 device Vertex& v = verticies[vid];
33 out.position = float4(float2(v.position), 0.0, 1.0);
34 out.texcoord = v.texcoord;
35
36 return out;
37 }
38
39 fragment half4 fragmentColorConversion(
40 Varyings in [[ stage_in ]],
41 texture2d<float, access::sample> textureY [[ texture(0) ]],
42 texture2d<float, access::sample> textureC bCr [[ texture(1) ]]
43 ) {
44 constexpr sampler s(address::clamp_to_edge, filter::linear);
45 float y;
46 float2 uv;
47 y = textureY.sample(s, in.texcoord).r;
48 uv = textureCbCr.sample(s, in.texcoord).rg - float2(0.5, 0.5);
49
50 float4 out = float4(y + 1.403 * uv.y,
51 y - 0.344 * uv.x - 0.714 * uv.y,
52 y + 1.770 * uv.x,
53 1.0);
54
55 return half4(out);
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698