1/*
2 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
5 * Copyright 2015 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20const char* forward_tonemap_shader = ""
21    "#extension GL_OES_EGL_image_external_essl3 : require                       \n"
22    "precision highp float;                                                     \n"
23    "precision highp sampler2D;                                                 \n"
24    "layout(binding = 0) uniform samplerExternalOES externalTexture;            \n"
25    "layout(binding = 1) uniform sampler3D tonemapper;                          \n"
26    "layout(binding = 2) uniform sampler2D xform;                               \n"
27    "in vec2 uv;                                                                \n"
28    "out vec4 fs_color;                                                         \n"
29    "void main()                                                                \n"
30    "{                                                                          \n"
31    "vec2 flipped = uv;                                                         \n"
32    "flipped.y = 1.0 - flipped.y;                                               \n"
33    "flipped.x = flipped.x;                                                     \n"
34    "vec4 rgb = texture(externalTexture, flipped);                              \n"
35    "#ifdef USE_NONUNIFORM_SAMPLING                                             \n"
36    "float r = texture(xform, vec2(r, 0.0f)).r;                                 \n"
37    "float g = texture(xform, vec2(g, 0.0f)).g;                                 \n"
38    "float b = texture(xform, vec2(b, 0.0f)).b;                                 \n"
39    "#else                                                                      \n"
40    "float r = rgb.r;                                                           \n"
41    "float g = rgb.g;                                                           \n"
42    "float b = rgb.b;                                                           \n"
43    "#endif                                                                     \n"
44    "fs_color.rgb = texture(tonemapper, vec3(r, g, b)).rgb;                     \n"
45    "}                                                                          \n";
46