Chromium Code Reviews| Index: webrtc/sdk/objc/Framework/Classes/metal/Shaders.metal |
| diff --git a/webrtc/sdk/objc/Framework/Classes/metal/Shaders.metal b/webrtc/sdk/objc/Framework/Classes/metal/Shaders.metal |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..38135d867b62debdbdeddd847b720f0aad62fb2c |
| --- /dev/null |
| +++ b/webrtc/sdk/objc/Framework/Classes/metal/Shaders.metal |
| @@ -0,0 +1,59 @@ |
| +/* |
| + * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include <metal_stdlib> |
| +#include <simd/simd.h> |
| + |
| +using namespace metal; |
| + |
| +typedef struct { |
| + packed_float2 position; |
| + packed_float2 texcoord; |
| +} Vertex; |
| + |
| + |
| +typedef struct { |
| + float4 position [[position]]; |
| + float2 texcoord; |
| +} Varyings; |
| + |
| +vertex Varyings vertexPassthrough( |
| + device Vertex* verticies [[ buffer(0) ]], |
| + unsigned int vid [[ vertex_id ]] |
| + ) { |
| + Varyings out; |
| + |
|
magjed_webrtc
2017/02/07 12:12:41
Maybe remove these empty lines between?
daniela-webrtc
2017/02/07 13:36:16
Done.
|
| + device Vertex& v = verticies[vid]; |
| + |
| + out.position = float4(float2(v.position), 0.0, 1.0); |
| + |
| + out.texcoord = v.texcoord; |
| + |
| + return out; |
| +} |
| + |
| +fragment half4 fragmentColorConversion( |
| + Varyings in [[ stage_in ]], |
| + texture2d<float, access::sample> textureY [[ texture(0) ]], |
| + texture2d<float, access::sample> textureCbCr [[ texture(1) ]] |
| + ) { |
| + constexpr sampler s(address::clamp_to_edge, filter::linear); |
| + float y; |
| + float2 uv; |
| + y = textureY.sample(s, in.texcoord).r; |
| + uv = textureCbCr.sample(s, in.texcoord).rg - float2(0.5,0.5); |
|
magjed_webrtc
2017/02/07 12:12:41
nit: add space between '0.5,0.5', i.e. '0.5, 0.5'
daniela-webrtc
2017/02/07 13:36:16
Done.
|
| + |
| + float4 out = float4(y + 1.403 * uv.y, |
| + y - 0.344 * uv.x - 0.714 * uv.y, |
| + y + 1.770 * uv.x, |
| + 1.0); |
| + |
| + return half4(out); |
| +} |