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..4eeb8c1c2b33a18e55fa57bb91397d6c08f2cd06 |
| --- /dev/null |
| +++ b/webrtc/sdk/objc/Framework/Classes/metal/Shaders.metal |
| @@ -0,0 +1,50 @@ |
| + |
|
kthelgason
2017/02/03 09:17:23
Missing copyright header
daniela-webrtc
2017/02/07 10:51:09
Done.
|
| +#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; |
| + |
| + 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); |
| + |
| + 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); |
| +} |