src/render/opengles2/SDL_shaders_gles2.c
author Andreas Müller <schnitzeltony@gmail.com>
Tue, 28 Aug 2018 12:57:51 -0700
changeset 12156 e5a666405750
parent 11811 5d94cb6b24d3
child 12208 abf1ced78a16
permissions -rw-r--r--
GLES2: Get sin/cos out of vertex shader
The only place angle is activated and causes effect is RenderCopyEx. All other
methods which use vertex shader, leave angle disabled and cause useless sin/cos
calculation in shader.

To get around shader's interface is changed to a vector that contains results
of sin and cos. To behave properly when disabled, cos value is set with offset
-1.0 making 0.0 default when deactivated.

As nice side effect it simplifies GLES2_UpdateVertexBuffer: All attributes are
vectors now.

Additional background:

* On RaspberryPi it gives a performace win for operations. Tested with
[1] numbers go down for 5-10% (not easy to estimate due to huge variation).
* SDL_RenderCopyEx was tested with [2]
* It works around left rotated display caused by low accuracy sin implemetation
in RaspberryPi/VC4 [3]

[1] https://github.com/schnitzeltony/sdl2box
[2] https://github.com/schnitzeltony/sdl2rendercopyex
[3] https://github.com/anholt/mesa/issues/110

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
slouken@5201
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
slouken@5201
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@5201
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@5201
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@5201
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@5201
    22
slouken@5226
    23
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
slouken@5201
    24
slouken@5201
    25
#include "SDL_video.h"
slouken@5204
    26
#include "SDL_opengles2.h"
slouken@5201
    27
#include "SDL_shaders_gles2.h"
slouken@5201
    28
#include "SDL_stdinc.h"
slouken@5201
    29
slouken@5201
    30
/*************************************************************************************************
slouken@5201
    31
 * Vertex/fragment shader source                                                                 *
slouken@5201
    32
 *************************************************************************************************/
schnitzeltony@12156
    33
/* Notes on a_angle:
schnitzeltony@12156
    34
   * It is a vector containing sin and cos for rotation matrix
schnitzeltony@12156
    35
   * To get correct rotation for most cases when a_angle is disabled cos
schnitzeltony@12156
    36
     value is decremented by 1.0 to get proper output with 0.0 which is
schnitzeltony@12156
    37
     default value
schnitzeltony@12156
    38
*/
slouken@5201
    39
static const Uint8 GLES2_VertexSrc_Default_[] = " \
slouken@5201
    40
    uniform mat4 u_projection; \
gabomdq@6320
    41
    attribute vec2 a_position; \
slouken@5201
    42
    attribute vec2 a_texCoord; \
schnitzeltony@12156
    43
    attribute vec2 a_angle; \
gabomdq@6320
    44
    attribute vec2 a_center; \
slouken@5201
    45
    varying vec2 v_texCoord; \
slouken@5201
    46
    \
slouken@5201
    47
    void main() \
slouken@5201
    48
    { \
schnitzeltony@12156
    49
        float s = a_angle[0]; \
schnitzeltony@12156
    50
        float c = a_angle[1] + 1.0; \
gabomdq@6320
    51
        mat2 rotationMatrix = mat2(c, -s, s, c); \
gabomdq@6320
    52
        vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
slouken@5201
    53
        v_texCoord = a_texCoord; \
gabomdq@6320
    54
        gl_Position = u_projection * vec4(position, 0.0, 1.0);\
slouken@5201
    55
        gl_PointSize = 1.0; \
slouken@5201
    56
    } \
slouken@5201
    57
";
slouken@5201
    58
slouken@5201
    59
static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
slouken@5201
    60
    precision mediump float; \
slouken@5201
    61
    uniform vec4 u_color; \
slouken@5201
    62
    \
slouken@5201
    63
    void main() \
slouken@5201
    64
    { \
slouken@5201
    65
        gl_FragColor = u_color; \
slouken@5201
    66
    } \
slouken@5201
    67
";
slouken@5201
    68
slouken@6113
    69
static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
slouken@5201
    70
    precision mediump float; \
slouken@5201
    71
    uniform sampler2D u_texture; \
slouken@5201
    72
    uniform vec4 u_modulation; \
slouken@5201
    73
    varying vec2 v_texCoord; \
slouken@5201
    74
    \
slouken@5201
    75
    void main() \
slouken@5201
    76
    { \
slouken@5201
    77
        gl_FragColor = texture2D(u_texture, v_texCoord); \
slouken@5201
    78
        gl_FragColor *= u_modulation; \
slouken@5201
    79
    } \
slouken@5201
    80
";
slouken@5201
    81
slouken@7191
    82
/* ARGB to ABGR conversion */
slouken@6113
    83
static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
slouken@6113
    84
    precision mediump float; \
slouken@6113
    85
    uniform sampler2D u_texture; \
slouken@6113
    86
    uniform vec4 u_modulation; \
slouken@6113
    87
    varying vec2 v_texCoord; \
slouken@6113
    88
    \
slouken@6113
    89
    void main() \
slouken@6113
    90
    { \
slouken@6113
    91
        vec4 abgr = texture2D(u_texture, v_texCoord); \
slouken@6113
    92
        gl_FragColor = abgr; \
slouken@6113
    93
        gl_FragColor.r = abgr.b; \
slouken@6113
    94
        gl_FragColor.b = abgr.r; \
slouken@6113
    95
        gl_FragColor *= u_modulation; \
slouken@6113
    96
    } \
slouken@6113
    97
";
slouken@6113
    98
slouken@7191
    99
/* RGB to ABGR conversion */
slouken@6113
   100
static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
slouken@6113
   101
    precision mediump float; \
slouken@6113
   102
    uniform sampler2D u_texture; \
slouken@6113
   103
    uniform vec4 u_modulation; \
slouken@6113
   104
    varying vec2 v_texCoord; \
slouken@6113
   105
    \
slouken@6113
   106
    void main() \
slouken@6113
   107
    { \
slouken@6113
   108
        vec4 abgr = texture2D(u_texture, v_texCoord); \
slouken@6113
   109
        gl_FragColor = abgr; \
slouken@6113
   110
        gl_FragColor.r = abgr.b; \
slouken@6113
   111
        gl_FragColor.b = abgr.r; \
slouken@6113
   112
        gl_FragColor.a = 1.0; \
slouken@6113
   113
        gl_FragColor *= u_modulation; \
slouken@6113
   114
    } \
slouken@6113
   115
";
slouken@6113
   116
slouken@7191
   117
/* BGR to ABGR conversion */
slouken@6113
   118
static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
slouken@6113
   119
    precision mediump float; \
slouken@6113
   120
    uniform sampler2D u_texture; \
slouken@6113
   121
    uniform vec4 u_modulation; \
slouken@6113
   122
    varying vec2 v_texCoord; \
slouken@6113
   123
    \
slouken@6113
   124
    void main() \
slouken@6113
   125
    { \
slouken@6113
   126
        vec4 abgr = texture2D(u_texture, v_texCoord); \
slouken@6113
   127
        gl_FragColor = abgr; \
slouken@6113
   128
        gl_FragColor.a = 1.0; \
slouken@6113
   129
        gl_FragColor *= u_modulation; \
slouken@6113
   130
    } \
slouken@6113
   131
";
slouken@6113
   132
slouken@11702
   133
#define JPEG_SHADER_CONSTANTS                                   \
slouken@11702
   134
"// YUV offset \n"                                              \
slouken@11702
   135
"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n"    \
slouken@11702
   136
"\n"                                                            \
slouken@11702
   137
"// RGB coefficients \n"                                        \
slouken@11702
   138
"const mat3 matrix = mat3( 1,       1,        1,\n"             \
slouken@11702
   139
"                          0,      -0.3441,   1.772,\n"         \
slouken@11702
   140
"                          1.402,  -0.7141,   0);\n"            \
slouken@11702
   141
slouken@11702
   142
#define BT601_SHADER_CONSTANTS                                  \
slouken@11702
   143
"// YUV offset \n"                                              \
slouken@11702
   144
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
slouken@11702
   145
"\n"                                                            \
slouken@11702
   146
"// RGB coefficients \n"                                        \
slouken@11702
   147
"const mat3 matrix = mat3( 1.1644,  1.1644,   1.1644,\n"        \
slouken@11702
   148
"                          0,      -0.3918,   2.0172,\n"        \
slouken@11702
   149
"                          1.596,  -0.813,    0);\n"            \
slouken@11702
   150
slouken@11702
   151
#define BT709_SHADER_CONSTANTS                                  \
slouken@11702
   152
"// YUV offset \n"                                              \
slouken@11702
   153
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
slouken@11702
   154
"\n"                                                            \
slouken@11702
   155
"// RGB coefficients \n"                                        \
slouken@11702
   156
"const mat3 matrix = mat3( 1.1644,  1.1644,   1.1644,\n"        \
slouken@11702
   157
"                          0,      -0.2132,   2.1124,\n"        \
slouken@11702
   158
"                          1.7927, -0.5329,   0);\n"            \
slouken@11702
   159
slouken@11702
   160
slouken@11702
   161
#define YUV_SHADER_PROLOGUE                                     \
slouken@11702
   162
"precision mediump float;\n"                                    \
slouken@11702
   163
"uniform sampler2D u_texture;\n"                                \
slouken@11702
   164
"uniform sampler2D u_texture_u;\n"                              \
slouken@11702
   165
"uniform sampler2D u_texture_v;\n"                              \
slouken@11702
   166
"uniform vec4 u_modulation;\n"                                  \
slouken@11702
   167
"varying vec2 v_texCoord;\n"                                    \
slouken@11702
   168
"\n"                                                            \
slouken@11702
   169
slouken@11702
   170
#define YUV_SHADER_BODY                                         \
slouken@11702
   171
"\n"                                                            \
slouken@11702
   172
"void main()\n"                                                 \
slouken@11702
   173
"{\n"                                                           \
slouken@11702
   174
"    mediump vec3 yuv;\n"                                       \
slouken@11702
   175
"    lowp vec3 rgb;\n"                                          \
slouken@11702
   176
"\n"                                                            \
slouken@11702
   177
"    // Get the YUV values \n"                                  \
slouken@11702
   178
"    yuv.x = texture2D(u_texture,   v_texCoord).r;\n"           \
slouken@11702
   179
"    yuv.y = texture2D(u_texture_u, v_texCoord).r;\n"           \
slouken@11702
   180
"    yuv.z = texture2D(u_texture_v, v_texCoord).r;\n"           \
slouken@11702
   181
"\n"                                                            \
slouken@11702
   182
"    // Do the color transform \n"                              \
slouken@11702
   183
"    yuv += offset;\n"                                          \
slouken@11702
   184
"    rgb = matrix * yuv;\n"                                     \
slouken@11702
   185
"\n"                                                            \
slouken@11702
   186
"    // That was easy. :) \n"                                   \
slouken@11702
   187
"    gl_FragColor = vec4(rgb, 1);\n"                            \
slouken@11702
   188
"    gl_FragColor *= u_modulation;\n"                           \
slouken@11702
   189
"}"                                                             \
slouken@11702
   190
slouken@11702
   191
#define NV12_SHADER_BODY                                        \
slouken@11702
   192
"\n"                                                            \
slouken@11702
   193
"void main()\n"                                                 \
slouken@11702
   194
"{\n"                                                           \
slouken@11702
   195
"    mediump vec3 yuv;\n"                                       \
slouken@11702
   196
"    lowp vec3 rgb;\n"                                          \
slouken@11702
   197
"\n"                                                            \
slouken@11702
   198
"    // Get the YUV values \n"                                  \
slouken@11702
   199
"    yuv.x = texture2D(u_texture,   v_texCoord).r;\n"           \
slouken@11702
   200
"    yuv.yz = texture2D(u_texture_u, v_texCoord).ra;\n"         \
slouken@11702
   201
"\n"                                                            \
slouken@11702
   202
"    // Do the color transform \n"                              \
slouken@11702
   203
"    yuv += offset;\n"                                          \
slouken@11702
   204
"    rgb = matrix * yuv;\n"                                     \
slouken@11702
   205
"\n"                                                            \
slouken@11702
   206
"    // That was easy. :) \n"                                   \
slouken@11702
   207
"    gl_FragColor = vec4(rgb, 1);\n"                            \
slouken@11702
   208
"    gl_FragColor *= u_modulation;\n"                           \
slouken@11702
   209
"}"                                                             \
slouken@11702
   210
slouken@11702
   211
#define NV21_SHADER_BODY                                        \
slouken@11702
   212
"\n"                                                            \
slouken@11702
   213
"void main()\n"                                                 \
slouken@11702
   214
"{\n"                                                           \
slouken@11702
   215
"    mediump vec3 yuv;\n"                                       \
slouken@11702
   216
"    lowp vec3 rgb;\n"                                          \
slouken@11702
   217
"\n"                                                            \
slouken@11702
   218
"    // Get the YUV values \n"                                  \
slouken@11702
   219
"    yuv.x = texture2D(u_texture,   v_texCoord).r;\n"           \
slouken@11702
   220
"    yuv.yz = texture2D(u_texture_u, v_texCoord).ar;\n"         \
slouken@11702
   221
"\n"                                                            \
slouken@11702
   222
"    // Do the color transform \n"                              \
slouken@11702
   223
"    yuv += offset;\n"                                          \
slouken@11702
   224
"    rgb = matrix * yuv;\n"                                     \
slouken@11702
   225
"\n"                                                            \
slouken@11702
   226
"    // That was easy. :) \n"                                   \
slouken@11702
   227
"    gl_FragColor = vec4(rgb, 1);\n"                            \
slouken@11702
   228
"    gl_FragColor *= u_modulation;\n"                           \
slouken@11702
   229
"}"                                                             \
slouken@11702
   230
slouken@8835
   231
/* YUV to ABGR conversion */
slouken@11702
   232
static const Uint8 GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \
slouken@11702
   233
        YUV_SHADER_PROLOGUE \
slouken@11702
   234
        JPEG_SHADER_CONSTANTS \
slouken@11702
   235
        YUV_SHADER_BODY \
slouken@11702
   236
;
slouken@11702
   237
static const Uint8 GLES2_FragmentSrc_TextureYUVBT601Src_[] = \
slouken@11702
   238
        YUV_SHADER_PROLOGUE \
slouken@11702
   239
        BT601_SHADER_CONSTANTS \
slouken@11702
   240
        YUV_SHADER_BODY \
slouken@11702
   241
;
slouken@11702
   242
static const Uint8 GLES2_FragmentSrc_TextureYUVBT709Src_[] = \
slouken@11702
   243
        YUV_SHADER_PROLOGUE \
slouken@11702
   244
        BT709_SHADER_CONSTANTS \
slouken@11702
   245
        YUV_SHADER_BODY \
slouken@11702
   246
;
slouken@8835
   247
slouken@9046
   248
/* NV12 to ABGR conversion */
slouken@11702
   249
static const Uint8 GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \
slouken@11702
   250
        YUV_SHADER_PROLOGUE \
slouken@11702
   251
        JPEG_SHADER_CONSTANTS \
slouken@11702
   252
        NV12_SHADER_BODY \
slouken@11702
   253
;
slouken@11702
   254
static const Uint8 GLES2_FragmentSrc_TextureNV12BT601Src_[] = \
slouken@11702
   255
        YUV_SHADER_PROLOGUE \
slouken@11702
   256
        BT601_SHADER_CONSTANTS \
slouken@11702
   257
        NV12_SHADER_BODY \
slouken@11702
   258
;
slouken@11702
   259
static const Uint8 GLES2_FragmentSrc_TextureNV12BT709Src_[] = \
slouken@11702
   260
        YUV_SHADER_PROLOGUE \
slouken@11702
   261
        BT709_SHADER_CONSTANTS \
slouken@11702
   262
        NV12_SHADER_BODY \
slouken@11702
   263
;
slouken@9046
   264
slouken@9046
   265
/* NV21 to ABGR conversion */
slouken@11702
   266
static const Uint8 GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \
slouken@11702
   267
        YUV_SHADER_PROLOGUE \
slouken@11702
   268
        JPEG_SHADER_CONSTANTS \
slouken@11702
   269
        NV21_SHADER_BODY \
slouken@11702
   270
;
slouken@11702
   271
static const Uint8 GLES2_FragmentSrc_TextureNV21BT601Src_[] = \
slouken@11702
   272
        YUV_SHADER_PROLOGUE \
slouken@11702
   273
        BT601_SHADER_CONSTANTS \
slouken@11702
   274
        NV21_SHADER_BODY \
slouken@11702
   275
;
slouken@11702
   276
static const Uint8 GLES2_FragmentSrc_TextureNV21BT709Src_[] = \
slouken@11702
   277
        YUV_SHADER_PROLOGUE \
slouken@11702
   278
        BT709_SHADER_CONSTANTS \
slouken@11702
   279
        NV21_SHADER_BODY \
slouken@11702
   280
;
slouken@9046
   281
slouken@11767
   282
/* Custom Android video format texture */
slouken@11767
   283
static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \
slouken@11767
   284
    #extension GL_OES_EGL_image_external : require\n\
slouken@11767
   285
    precision mediump float; \
slouken@11767
   286
    uniform samplerExternalOES u_texture; \
slouken@11767
   287
    uniform vec4 u_modulation; \
slouken@11767
   288
    varying vec2 v_texCoord; \
slouken@11767
   289
    \
slouken@11767
   290
    void main() \
slouken@11767
   291
    { \
slouken@11767
   292
        gl_FragColor = texture2D(u_texture, v_texCoord); \
slouken@11767
   293
        gl_FragColor *= u_modulation; \
slouken@11767
   294
    } \
slouken@11767
   295
";
slouken@11767
   296
slouken@5201
   297
static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
slouken@5201
   298
    GL_VERTEX_SHADER,
slouken@5201
   299
    GLES2_SOURCE_SHADER,
slouken@5201
   300
    sizeof(GLES2_VertexSrc_Default_),
slouken@5201
   301
    GLES2_VertexSrc_Default_
slouken@5201
   302
};
slouken@5201
   303
slouken@5201
   304
static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = {
slouken@5201
   305
    GL_FRAGMENT_SHADER,
slouken@5201
   306
    GLES2_SOURCE_SHADER,
slouken@5201
   307
    sizeof(GLES2_FragmentSrc_SolidSrc_),
slouken@5201
   308
    GLES2_FragmentSrc_SolidSrc_
slouken@5201
   309
};
slouken@5201
   310
slouken@6113
   311
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = {
slouken@5201
   312
    GL_FRAGMENT_SHADER,
slouken@5201
   313
    GLES2_SOURCE_SHADER,
slouken@6113
   314
    sizeof(GLES2_FragmentSrc_TextureABGRSrc_),
slouken@6113
   315
    GLES2_FragmentSrc_TextureABGRSrc_
slouken@6113
   316
};
slouken@6113
   317
slouken@6113
   318
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = {
slouken@6113
   319
    GL_FRAGMENT_SHADER,
slouken@6113
   320
    GLES2_SOURCE_SHADER,
slouken@6113
   321
    sizeof(GLES2_FragmentSrc_TextureARGBSrc_),
slouken@6113
   322
    GLES2_FragmentSrc_TextureARGBSrc_
slouken@6113
   323
};
slouken@6113
   324
slouken@6113
   325
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = {
slouken@6113
   326
    GL_FRAGMENT_SHADER,
slouken@6113
   327
    GLES2_SOURCE_SHADER,
slouken@6113
   328
    sizeof(GLES2_FragmentSrc_TextureRGBSrc_),
slouken@6113
   329
    GLES2_FragmentSrc_TextureRGBSrc_
slouken@6113
   330
};
slouken@6113
   331
slouken@6113
   332
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = {
slouken@6113
   333
    GL_FRAGMENT_SHADER,
slouken@6113
   334
    GLES2_SOURCE_SHADER,
slouken@6113
   335
    sizeof(GLES2_FragmentSrc_TextureBGRSrc_),
slouken@6113
   336
    GLES2_FragmentSrc_TextureBGRSrc_
slouken@5201
   337
};
slouken@5201
   338
slouken@11702
   339
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVJPEGSrc = {
slouken@8835
   340
    GL_FRAGMENT_SHADER,
slouken@8835
   341
    GLES2_SOURCE_SHADER,
slouken@11702
   342
    sizeof(GLES2_FragmentSrc_TextureYUVJPEGSrc_),
slouken@11702
   343
    GLES2_FragmentSrc_TextureYUVJPEGSrc_
slouken@8835
   344
};
slouken@8835
   345
slouken@11702
   346
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT601Src = {
slouken@9046
   347
    GL_FRAGMENT_SHADER,
slouken@9046
   348
    GLES2_SOURCE_SHADER,
slouken@11702
   349
    sizeof(GLES2_FragmentSrc_TextureYUVBT601Src_),
slouken@11702
   350
    GLES2_FragmentSrc_TextureYUVBT601Src_
slouken@9046
   351
};
slouken@9046
   352
slouken@11702
   353
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT709Src = {
slouken@9046
   354
    GL_FRAGMENT_SHADER,
slouken@9046
   355
    GLES2_SOURCE_SHADER,
slouken@11702
   356
    sizeof(GLES2_FragmentSrc_TextureYUVBT709Src_),
slouken@11702
   357
    GLES2_FragmentSrc_TextureYUVBT709Src_
slouken@11702
   358
};
slouken@11702
   359
slouken@11702
   360
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12JPEGSrc = {
slouken@11702
   361
    GL_FRAGMENT_SHADER,
slouken@11702
   362
    GLES2_SOURCE_SHADER,
slouken@11702
   363
    sizeof(GLES2_FragmentSrc_TextureNV12JPEGSrc_),
slouken@11702
   364
    GLES2_FragmentSrc_TextureNV12JPEGSrc_
slouken@11702
   365
};
slouken@11702
   366
slouken@11702
   367
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT601Src = {
slouken@11702
   368
    GL_FRAGMENT_SHADER,
slouken@11702
   369
    GLES2_SOURCE_SHADER,
slouken@11702
   370
    sizeof(GLES2_FragmentSrc_TextureNV12BT601Src_),
slouken@11702
   371
    GLES2_FragmentSrc_TextureNV12BT601Src_
slouken@11702
   372
};
slouken@11702
   373
slouken@11702
   374
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT709Src = {
slouken@11702
   375
    GL_FRAGMENT_SHADER,
slouken@11702
   376
    GLES2_SOURCE_SHADER,
slouken@11702
   377
    sizeof(GLES2_FragmentSrc_TextureNV21BT709Src_),
slouken@11702
   378
    GLES2_FragmentSrc_TextureNV21BT709Src_
slouken@11702
   379
};
slouken@11702
   380
slouken@11702
   381
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21JPEGSrc = {
slouken@11702
   382
    GL_FRAGMENT_SHADER,
slouken@11702
   383
    GLES2_SOURCE_SHADER,
slouken@11702
   384
    sizeof(GLES2_FragmentSrc_TextureNV21JPEGSrc_),
slouken@11702
   385
    GLES2_FragmentSrc_TextureNV21JPEGSrc_
slouken@11702
   386
};
slouken@11702
   387
slouken@11702
   388
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT601Src = {
slouken@11702
   389
    GL_FRAGMENT_SHADER,
slouken@11702
   390
    GLES2_SOURCE_SHADER,
slouken@11702
   391
    sizeof(GLES2_FragmentSrc_TextureNV21BT601Src_),
slouken@11702
   392
    GLES2_FragmentSrc_TextureNV21BT601Src_
slouken@11702
   393
};
slouken@11702
   394
slouken@11702
   395
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT709Src = {
slouken@11702
   396
    GL_FRAGMENT_SHADER,
slouken@11702
   397
    GLES2_SOURCE_SHADER,
slouken@11702
   398
    sizeof(GLES2_FragmentSrc_TextureNV12BT709Src_),
slouken@11702
   399
    GLES2_FragmentSrc_TextureNV12BT709Src_
slouken@9046
   400
};
slouken@9046
   401
slouken@11767
   402
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureExternalOESSrc = {
slouken@11767
   403
    GL_FRAGMENT_SHADER,
slouken@11767
   404
    GLES2_SOURCE_SHADER,
slouken@11767
   405
    sizeof(GLES2_FragmentSrc_TextureExternalOESSrc_),
slouken@11767
   406
    GLES2_FragmentSrc_TextureExternalOESSrc_
slouken@11767
   407
};
slouken@11767
   408
slouken@8835
   409
slouken@5201
   410
/*************************************************************************************************
slouken@5201
   411
 * Vertex/fragment shader definitions                                                            *
slouken@5201
   412
 *************************************************************************************************/
slouken@5201
   413
slouken@5201
   414
static GLES2_Shader GLES2_VertexShader_Default = {
slouken@6113
   415
    1,
slouken@5201
   416
    {
slouken@5201
   417
        &GLES2_VertexSrc_Default
slouken@5201
   418
    }
slouken@5201
   419
};
slouken@5201
   420
slouken@11282
   421
static GLES2_Shader GLES2_FragmentShader_SolidSrc = {
slouken@6113
   422
    1,
slouken@5201
   423
    {
slouken@5201
   424
        &GLES2_FragmentSrc_SolidSrc
slouken@5201
   425
    }
slouken@5201
   426
};
slouken@5201
   427
slouken@11282
   428
static GLES2_Shader GLES2_FragmentShader_TextureABGRSrc = {
slouken@6113
   429
    1,
slouken@5201
   430
    {
slouken@6113
   431
        &GLES2_FragmentSrc_TextureABGRSrc
slouken@5201
   432
    }
slouken@5201
   433
};
slouken@5201
   434
slouken@11282
   435
static GLES2_Shader GLES2_FragmentShader_TextureARGBSrc = {
slouken@6113
   436
    1,
slouken@6113
   437
    {
slouken@6113
   438
        &GLES2_FragmentSrc_TextureARGBSrc
slouken@6113
   439
    }
slouken@6113
   440
};
slouken@6113
   441
slouken@11282
   442
static GLES2_Shader GLES2_FragmentShader_TextureRGBSrc = {
slouken@6113
   443
    1,
slouken@6113
   444
    {
slouken@6113
   445
        &GLES2_FragmentSrc_TextureRGBSrc
slouken@6113
   446
    }
slouken@6113
   447
};
slouken@6113
   448
slouken@11282
   449
static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = {
slouken@6113
   450
    1,
slouken@6113
   451
    {
slouken@6113
   452
        &GLES2_FragmentSrc_TextureBGRSrc
slouken@5201
   453
    }
slouken@5201
   454
};
slouken@5201
   455
slouken@11702
   456
static GLES2_Shader GLES2_FragmentShader_TextureYUVJPEGSrc = {
slouken@8835
   457
    1,
slouken@8835
   458
    {
slouken@11702
   459
        &GLES2_FragmentSrc_TextureYUVJPEGSrc
slouken@8835
   460
    }
slouken@8835
   461
};
slouken@8835
   462
slouken@11702
   463
static GLES2_Shader GLES2_FragmentShader_TextureYUVBT601Src = {
slouken@9046
   464
    1,
slouken@9046
   465
    {
slouken@11702
   466
        &GLES2_FragmentSrc_TextureYUVBT601Src
slouken@9046
   467
    }
slouken@9046
   468
};
slouken@9046
   469
slouken@11702
   470
static GLES2_Shader GLES2_FragmentShader_TextureYUVBT709Src = {
slouken@9046
   471
    1,
slouken@9046
   472
    {
slouken@11702
   473
        &GLES2_FragmentSrc_TextureYUVBT709Src
slouken@11702
   474
    }
slouken@11702
   475
};
slouken@11702
   476
slouken@11702
   477
static GLES2_Shader GLES2_FragmentShader_TextureNV12JPEGSrc = {
slouken@11702
   478
    1,
slouken@11702
   479
    {
slouken@11702
   480
        &GLES2_FragmentSrc_TextureNV12JPEGSrc
slouken@11702
   481
    }
slouken@11702
   482
};
slouken@11702
   483
slouken@11702
   484
static GLES2_Shader GLES2_FragmentShader_TextureNV12BT601Src = {
slouken@11702
   485
    1,
slouken@11702
   486
    {
slouken@11702
   487
        &GLES2_FragmentSrc_TextureNV12BT601Src
slouken@11702
   488
    }
slouken@11702
   489
};
slouken@11702
   490
slouken@11702
   491
static GLES2_Shader GLES2_FragmentShader_TextureNV12BT709Src = {
slouken@11702
   492
    1,
slouken@11702
   493
    {
slouken@11702
   494
        &GLES2_FragmentSrc_TextureNV12BT709Src
slouken@11702
   495
    }
slouken@11702
   496
};
slouken@11702
   497
slouken@11702
   498
static GLES2_Shader GLES2_FragmentShader_TextureNV21JPEGSrc = {
slouken@11702
   499
    1,
slouken@11702
   500
    {
slouken@11702
   501
        &GLES2_FragmentSrc_TextureNV21JPEGSrc
slouken@11702
   502
    }
slouken@11702
   503
};
slouken@11702
   504
slouken@11702
   505
static GLES2_Shader GLES2_FragmentShader_TextureNV21BT601Src = {
slouken@11702
   506
    1,
slouken@11702
   507
    {
slouken@11702
   508
        &GLES2_FragmentSrc_TextureNV21BT601Src
slouken@11702
   509
    }
slouken@11702
   510
};
slouken@11702
   511
slouken@11702
   512
static GLES2_Shader GLES2_FragmentShader_TextureNV21BT709Src = {
slouken@11702
   513
    1,
slouken@11702
   514
    {
slouken@11702
   515
        &GLES2_FragmentSrc_TextureNV21BT709Src
slouken@9046
   516
    }
slouken@9046
   517
};
slouken@9046
   518
slouken@11767
   519
static GLES2_Shader GLES2_FragmentShader_TextureExternalOESSrc = {
slouken@11767
   520
    1,
slouken@11767
   521
    {
slouken@11767
   522
        &GLES2_FragmentSrc_TextureExternalOESSrc
slouken@11767
   523
    }
slouken@11767
   524
};
slouken@11767
   525
slouken@8835
   526
slouken@5201
   527
/*************************************************************************************************
slouken@5201
   528
 * Shader selector                                                                               *
slouken@5201
   529
 *************************************************************************************************/
slouken@5201
   530
slouken@11282
   531
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type)
slouken@5201
   532
{
slime73@9604
   533
    switch (type) {
slouken@5201
   534
    case GLES2_SHADER_VERTEX_DEFAULT:
slouken@5201
   535
        return &GLES2_VertexShader_Default;
slouken@5201
   536
    case GLES2_SHADER_FRAGMENT_SOLID_SRC:
slouken@11282
   537
        return &GLES2_FragmentShader_SolidSrc;
slouken@6113
   538
    case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
slouken@11282
   539
        return &GLES2_FragmentShader_TextureABGRSrc;
slouken@6113
   540
    case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
slouken@11282
   541
        return &GLES2_FragmentShader_TextureARGBSrc;
slouken@6113
   542
    case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
slouken@11282
   543
        return &GLES2_FragmentShader_TextureRGBSrc;
slouken@6113
   544
    case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
slouken@11282
   545
        return &GLES2_FragmentShader_TextureBGRSrc;
slouken@11702
   546
    case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC:
slouken@11702
   547
        return &GLES2_FragmentShader_TextureYUVJPEGSrc;
slouken@11702
   548
    case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC:
slouken@11702
   549
        return &GLES2_FragmentShader_TextureYUVBT601Src;
slouken@11702
   550
    case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC:
slouken@11702
   551
        return &GLES2_FragmentShader_TextureYUVBT709Src;
slouken@11702
   552
    case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC:
slouken@11702
   553
        return &GLES2_FragmentShader_TextureNV12JPEGSrc;
slouken@11702
   554
    case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC:
slouken@11702
   555
        return &GLES2_FragmentShader_TextureNV12BT601Src;
slouken@11702
   556
    case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC:
slouken@11702
   557
        return &GLES2_FragmentShader_TextureNV12BT709Src;
slouken@11702
   558
    case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC:
slouken@11702
   559
        return &GLES2_FragmentShader_TextureNV21JPEGSrc;
slouken@11702
   560
    case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC:
slouken@11702
   561
        return &GLES2_FragmentShader_TextureNV21BT601Src;
slouken@11702
   562
    case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC:
slouken@11702
   563
        return &GLES2_FragmentShader_TextureNV21BT709Src;
slouken@11767
   564
    case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC:
slouken@11767
   565
        return &GLES2_FragmentShader_TextureExternalOESSrc;
slouken@5201
   566
    default:
slouken@5201
   567
        return NULL;
slouken@5201
   568
    }
slouken@5201
   569
}
slouken@5201
   570
slouken@5226
   571
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
slouken@5201
   572
slouken@5201
   573
/* vi: set ts=4 sw=4 expandtab: */