Implemented more flexible blending modes for accelerated renderers
authorSam Lantinga <slouken@libsdl.org>
Mon, 14 Aug 2017 05:51:44 -0700
changeset 11282180e8906dc3c
parent 11281 42b62c737891
child 11283 4276937a9792
Implemented more flexible blending modes for accelerated renderers

This fixes bug 2594 - Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA

blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
SDL_BLENDOPERATION_ADD,
SDL_BLENDFACTOR_ZERO,
SDL_BLENDFACTOR_ONE,
SDL_BLENDOPERATION_ADD);

This fixes bug 2828 - Subtractive Blending

blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
SDL_BLENDFACTOR_ONE,
SDL_BLENDOPERATION_SUBTRACT,
SDL_BLENDFACTOR_ZERO,
SDL_BLENDFACTOR_ONE,
SDL_BLENDOPERATION_SUBTRACT);


This goes partway to fixing bug 3684 - Add support for a pre-multiplied alpha blending mode

blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE,
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
SDL_BLENDOPERATION_ADD,
SDL_BLENDFACTOR_ONE,
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
SDL_BLENDOPERATION_ADD);
include/SDL_blendmode.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/render/SDL_render.c
src/render/SDL_sysrender.h
src/render/direct3d/SDL_render_d3d.c
src/render/direct3d11/SDL_render_d3d11.c
src/render/opengl/SDL_glfuncs.h
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_glesfuncs.h
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_gles2funcs.h
src/render/opengles2/SDL_render_gles2.c
src/render/opengles2/SDL_shaders_gles2.c
src/render/opengles2/SDL_shaders_gles2.h
test/testsprite2.c
     1.1 --- a/include/SDL_blendmode.h	Sun Aug 13 22:50:23 2017 -0700
     1.2 +++ b/include/SDL_blendmode.h	Mon Aug 14 05:51:44 2017 -0700
     1.3 @@ -47,11 +47,68 @@
     1.4      SDL_BLENDMODE_ADD = 0x00000002,      /**< additive blending
     1.5                                                dstRGB = (srcRGB * srcA) + dstRGB
     1.6                                                dstA = dstA */
     1.7 -    SDL_BLENDMODE_MOD = 0x00000004       /**< color modulate
     1.8 +    SDL_BLENDMODE_MOD = 0x00000004,      /**< color modulate
     1.9                                                dstRGB = srcRGB * dstRGB
    1.10                                                dstA = dstA */
    1.11 +    SDL_BLENDMODE_INVALID = 0x7FFFFFFF
    1.12 +
    1.13 +    /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
    1.14 +
    1.15  } SDL_BlendMode;
    1.16  
    1.17 +/**
    1.18 + *  \brief The blend operation used when combining source and destination pixel components
    1.19 + */
    1.20 +typedef enum
    1.21 +{
    1.22 +    SDL_BLENDOPERATION_ADD              = 0x1,  /**< dst + src: supported by all renderers */
    1.23 +    SDL_BLENDOPERATION_SUBTRACT         = 0x2,  /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
    1.24 +    SDL_BLENDOPERATION_REV_SUBTRACT     = 0x3,  /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
    1.25 +    SDL_BLENDOPERATION_MINIMUM          = 0x4,  /**< min(dst, src) : supported by D3D11 */
    1.26 +    SDL_BLENDOPERATION_MAXIMUM          = 0x5,  /**< max(dst, src) : supported by D3D11 */
    1.27 +
    1.28 +} SDL_BlendOperation;
    1.29 +
    1.30 +/**
    1.31 + *  \brief The normalized factor used to multiply pixel components
    1.32 + */
    1.33 +typedef enum
    1.34 +{
    1.35 +    SDL_BLENDFACTOR_ZERO                = 0x1,  /**< 0, 0, 0, 0 */
    1.36 +    SDL_BLENDFACTOR_ONE                 = 0x2,  /**< 1, 1, 1, 1 */
    1.37 +    SDL_BLENDFACTOR_SRC_COLOR           = 0x3,  /**< srcR, srcG, srcB, srcA */
    1.38 +    SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4,  /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */
    1.39 +    SDL_BLENDFACTOR_SRC_ALPHA           = 0x5,  /**< srcA, srcA, srcA, srcA */
    1.40 +    SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6,  /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */
    1.41 +    SDL_BLENDFACTOR_DST_COLOR           = 0x7,  /**< dstR, dstG, dstB, dstA */
    1.42 +    SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8,  /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
    1.43 +    SDL_BLENDFACTOR_DST_ALPHA           = 0x9,  /**< dstA, dstA, dstA, dstA */
    1.44 +    SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA,  /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
    1.45 +
    1.46 +} SDL_BlendFactor;
    1.47 +
    1.48 +/**
    1.49 + *  \brief Create a custom blend mode, which may or may not be supported by a given renderer
    1.50 + *
    1.51 + *  \param srcColorFactor
    1.52 + *  \param dstColorFactor
    1.53 + *  \param colorOperation
    1.54 + *  \param srcAlphaFactor
    1.55 + *  \param dstAlphaFactor
    1.56 + *  \param alphaOperation
    1.57 + *
    1.58 + *  The result of the blend mode operation will be:
    1.59 + *      dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor
    1.60 + *  and
    1.61 + *      dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor
    1.62 + */
    1.63 +extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor,
    1.64 +                                                                 SDL_BlendFactor dstColorFactor,
    1.65 +                                                                 SDL_BlendOperation colorOperation,
    1.66 +                                                                 SDL_BlendFactor srcAlphaFactor,
    1.67 +                                                                 SDL_BlendFactor dstAlphaFactor,
    1.68 +                                                                 SDL_BlendOperation alphaOperation);
    1.69 +
    1.70  /* Ends C function definitions when using C++ */
    1.71  #ifdef __cplusplus
    1.72  }
     2.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Sun Aug 13 22:50:23 2017 -0700
     2.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Mon Aug 14 05:51:44 2017 -0700
     2.3 @@ -627,3 +627,4 @@
     2.4  #define SDL_utf8strlen SDL_utf8strlen_REAL
     2.5  #define SDL_LoadFile_RW SDL_LoadFile_RW_REAL
     2.6  #define SDL_wcscmp SDL_wcscmp_REAL
     2.7 +#define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL
     3.1 --- a/src/dynapi/SDL_dynapi_procs.h	Sun Aug 13 22:50:23 2017 -0700
     3.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Mon Aug 14 05:51:44 2017 -0700
     3.3 @@ -659,3 +659,4 @@
     3.4  SDL_DYNAPI_PROC(size_t,SDL_utf8strlen,(const char *a),(a),return)
     3.5  SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),return)
     3.6  SDL_DYNAPI_PROC(int,SDL_wcscmp,(const wchar_t *a, const wchar_t *b),(a,b),return)
     3.7 +SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
     4.1 --- a/src/render/SDL_render.c	Sun Aug 13 22:50:23 2017 -0700
     4.2 +++ b/src/render/SDL_render.c	Mon Aug 14 05:51:44 2017 -0700
     4.3 @@ -44,6 +44,31 @@
     4.4          return retval; \
     4.5      }
     4.6  
     4.7 +/* Predefined blend modes */
     4.8 +#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, \
     4.9 +                              srcAlphaFactor, dstAlphaFactor, alphaOperation) \
    4.10 +    (SDL_BlendMode)(((Uint32)colorOperation << 0) | \
    4.11 +                    ((Uint32)srcColorFactor << 4) | \
    4.12 +                    ((Uint32)dstColorFactor << 8) | \
    4.13 +                    ((Uint32)alphaOperation << 16) | \
    4.14 +                    ((Uint32)srcAlphaFactor << 20) | \
    4.15 +                    ((Uint32)dstAlphaFactor << 24))
    4.16 +
    4.17 +#define SDL_BLENDMODE_NONE_FULL \
    4.18 +    SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, \
    4.19 +                          SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD)
    4.20 +
    4.21 +#define SDL_BLENDMODE_BLEND_FULL \
    4.22 +    SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \
    4.23 +                          SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD)
    4.24 +
    4.25 +#define SDL_BLENDMODE_ADD_FULL \
    4.26 +    SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \
    4.27 +                          SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
    4.28 +
    4.29 +#define SDL_BLENDMODE_MOD_FULL \
    4.30 +    SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_SRC_COLOR, SDL_BLENDOPERATION_ADD, \
    4.31 +                          SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
    4.32  
    4.33  #if !SDL_RENDER_DISABLED
    4.34  static const SDL_RenderDriver *render_drivers[] = {
    4.35 @@ -380,6 +405,23 @@
    4.36  }
    4.37  
    4.38  static SDL_bool
    4.39 +IsSupportedBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
    4.40 +{
    4.41 +    switch (blendMode)
    4.42 +    {
    4.43 +    /* These are required to be supported by all renderers */
    4.44 +    case SDL_BLENDMODE_NONE:
    4.45 +    case SDL_BLENDMODE_BLEND:
    4.46 +    case SDL_BLENDMODE_ADD:
    4.47 +    case SDL_BLENDMODE_MOD:
    4.48 +        return SDL_TRUE;
    4.49 +
    4.50 +    default:
    4.51 +        return renderer->SupportsBlendMode && renderer->SupportsBlendMode(renderer, blendMode);
    4.52 +    }
    4.53 +}
    4.54 +
    4.55 +static SDL_bool
    4.56  IsSupportedFormat(SDL_Renderer * renderer, Uint32 format)
    4.57  {
    4.58      Uint32 i;
    4.59 @@ -706,6 +748,9 @@
    4.60      CHECK_TEXTURE_MAGIC(texture, -1);
    4.61  
    4.62      renderer = texture->renderer;
    4.63 +    if (!IsSupportedBlendMode(renderer, blendMode)) {
    4.64 +        return SDL_Unsupported();
    4.65 +    }
    4.66      texture->blendMode = blendMode;
    4.67      if (texture->native) {
    4.68          return SDL_SetTextureBlendMode(texture->native, blendMode);
    4.69 @@ -1452,6 +1497,9 @@
    4.70  {
    4.71      CHECK_RENDERER_MAGIC(renderer, -1);
    4.72  
    4.73 +    if (!IsSupportedBlendMode(renderer, blendMode)) {
    4.74 +        return SDL_Unsupported();
    4.75 +    }
    4.76      renderer->blendMode = blendMode;
    4.77      return 0;
    4.78  }
    4.79 @@ -2042,4 +2090,91 @@
    4.80      return SDL_Unsupported();
    4.81  }
    4.82  
    4.83 +static SDL_BlendMode
    4.84 +SDL_GetShortBlendMode(SDL_BlendMode blendMode)
    4.85 +{
    4.86 +    switch (blendMode) {
    4.87 +    case SDL_BLENDMODE_NONE_FULL:
    4.88 +        return SDL_BLENDMODE_NONE;
    4.89 +    case SDL_BLENDMODE_BLEND_FULL:
    4.90 +        return SDL_BLENDMODE_BLEND;
    4.91 +    case SDL_BLENDMODE_ADD_FULL:
    4.92 +        return SDL_BLENDMODE_ADD;
    4.93 +    case SDL_BLENDMODE_MOD_FULL:
    4.94 +        return SDL_BLENDMODE_MOD;
    4.95 +    default:
    4.96 +        return blendMode;
    4.97 +    }
    4.98 +}
    4.99 +
   4.100 +static SDL_BlendMode
   4.101 +SDL_GetLongBlendMode(SDL_BlendMode blendMode)
   4.102 +{
   4.103 +    switch (blendMode) {
   4.104 +    case SDL_BLENDMODE_NONE:
   4.105 +        return SDL_BLENDMODE_NONE_FULL;
   4.106 +    case SDL_BLENDMODE_BLEND:
   4.107 +        return SDL_BLENDMODE_BLEND_FULL;
   4.108 +    case SDL_BLENDMODE_ADD:
   4.109 +        return SDL_BLENDMODE_ADD_FULL;
   4.110 +    case SDL_BLENDMODE_MOD:
   4.111 +        return SDL_BLENDMODE_MOD_FULL;
   4.112 +    default:
   4.113 +        return blendMode;
   4.114 +    }
   4.115 +}
   4.116 +
   4.117 +SDL_BlendMode
   4.118 +SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor,
   4.119 +                           SDL_BlendOperation colorOperation,
   4.120 +                           SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor,
   4.121 +                           SDL_BlendOperation alphaOperation)
   4.122 +{
   4.123 +    SDL_BlendMode blendMode = SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation,
   4.124 +                                                    srcAlphaFactor, dstAlphaFactor, alphaOperation);
   4.125 +    return SDL_GetShortBlendMode(blendMode);
   4.126 +}
   4.127 +
   4.128 +SDL_BlendFactor
   4.129 +SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode)
   4.130 +{
   4.131 +    blendMode = SDL_GetLongBlendMode(blendMode);
   4.132 +    return (SDL_BlendFactor)(((Uint32)blendMode >> 4) & 0xF);
   4.133 +}
   4.134 +
   4.135 +SDL_BlendFactor
   4.136 +SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode)
   4.137 +{
   4.138 +    blendMode = SDL_GetLongBlendMode(blendMode);
   4.139 +    return (SDL_BlendFactor)(((Uint32)blendMode >> 8) & 0xF);
   4.140 +}
   4.141 +
   4.142 +SDL_BlendOperation
   4.143 +SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode)
   4.144 +{
   4.145 +    blendMode = SDL_GetLongBlendMode(blendMode);
   4.146 +    return (SDL_BlendOperation)(((Uint32)blendMode >> 0) & 0xF);
   4.147 +}
   4.148 +
   4.149 +SDL_BlendFactor
   4.150 +SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode)
   4.151 +{
   4.152 +    blendMode = SDL_GetLongBlendMode(blendMode);
   4.153 +    return (SDL_BlendFactor)(((Uint32)blendMode >> 20) & 0xF);
   4.154 +}
   4.155 +
   4.156 +SDL_BlendFactor
   4.157 +SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode)
   4.158 +{
   4.159 +    blendMode = SDL_GetLongBlendMode(blendMode);
   4.160 +    return (SDL_BlendFactor)(((Uint32)blendMode >> 24) & 0xF);
   4.161 +}
   4.162 +
   4.163 +SDL_BlendOperation
   4.164 +SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode)
   4.165 +{
   4.166 +    blendMode = SDL_GetLongBlendMode(blendMode);
   4.167 +    return (SDL_BlendFactor)(((Uint32)blendMode >> 16) & 0xF);
   4.168 +}
   4.169 +
   4.170  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/render/SDL_sysrender.h	Sun Aug 13 22:50:23 2017 -0700
     5.2 +++ b/src/render/SDL_sysrender.h	Mon Aug 14 05:51:44 2017 -0700
     5.3 @@ -79,6 +79,7 @@
     5.4  
     5.5      void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
     5.6      int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
     5.7 +    SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode);
     5.8      int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
     5.9      int (*SetTextureColorMod) (SDL_Renderer * renderer,
    5.10                                 SDL_Texture * texture);
    5.11 @@ -186,6 +187,14 @@
    5.12  extern SDL_RenderDriver PSP_RenderDriver;
    5.13  extern SDL_RenderDriver SW_RenderDriver;
    5.14  
    5.15 +/* Blend mode functions */
    5.16 +extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
    5.17 +extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode);
    5.18 +extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode);
    5.19 +extern SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode);
    5.20 +extern SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode);
    5.21 +extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode);
    5.22 +
    5.23  #endif /* SDL_sysrender_h_ */
    5.24  
    5.25  /* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/render/direct3d/SDL_render_d3d.c	Sun Aug 13 22:50:23 2017 -0700
     6.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Mon Aug 14 05:51:44 2017 -0700
     6.3 @@ -125,6 +125,7 @@
     6.4  static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
     6.5  static void D3D_WindowEvent(SDL_Renderer * renderer,
     6.6                              const SDL_WindowEvent *event);
     6.7 +static SDL_bool D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode);
     6.8  static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     6.9  static int D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    6.10  static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    6.11 @@ -542,6 +543,7 @@
    6.12      }
    6.13  
    6.14      renderer->WindowEvent = D3D_WindowEvent;
    6.15 +    renderer->SupportsBlendMode = D3D_SupportsBlendMode;
    6.16      renderer->CreateTexture = D3D_CreateTexture;
    6.17      renderer->UpdateTexture = D3D_UpdateTexture;
    6.18      renderer->UpdateTextureYUV = D3D_UpdateTextureYUV;
    6.19 @@ -802,6 +804,58 @@
    6.20      }
    6.21  }
    6.22  
    6.23 +static D3DBLEND GetBlendFunc(SDL_BlendFactor factor)
    6.24 +{
    6.25 +    switch (factor) {
    6.26 +    case SDL_BLENDFACTOR_ZERO:
    6.27 +        return D3DBLEND_ZERO;
    6.28 +    case SDL_BLENDFACTOR_ONE:
    6.29 +        return D3DBLEND_ONE;
    6.30 +    case SDL_BLENDFACTOR_SRC_COLOR:
    6.31 +        return D3DBLEND_SRCCOLOR;
    6.32 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
    6.33 +        return D3DBLEND_INVSRCCOLOR;
    6.34 +    case SDL_BLENDFACTOR_SRC_ALPHA:
    6.35 +        return D3DBLEND_SRCALPHA;
    6.36 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
    6.37 +        return D3DBLEND_INVSRCALPHA;
    6.38 +    case SDL_BLENDFACTOR_DST_COLOR:
    6.39 +        return D3DBLEND_DESTCOLOR;
    6.40 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
    6.41 +        return D3DBLEND_INVDESTCOLOR;
    6.42 +    case SDL_BLENDFACTOR_DST_ALPHA:
    6.43 +        return D3DBLEND_DESTALPHA;
    6.44 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
    6.45 +        return D3DBLEND_INVDESTALPHA;
    6.46 +    default:
    6.47 +        return (D3DBLEND)0;
    6.48 +    }
    6.49 +}
    6.50 +
    6.51 +static SDL_bool
    6.52 +D3D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
    6.53 +{
    6.54 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    6.55 +    SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
    6.56 +    SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
    6.57 +    SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
    6.58 +    SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
    6.59 +    SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
    6.60 +    SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
    6.61 +
    6.62 +    if (!GetBlendFunc(srcColorFactor) || !GetBlendFunc(srcAlphaFactor) ||
    6.63 +        !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor)) {
    6.64 +        return SDL_FALSE;
    6.65 +    }
    6.66 +    if ((srcColorFactor != srcAlphaFactor || dstColorFactor != dstAlphaFactor) && !data->enableSeparateAlphaBlend) {
    6.67 +        return SDL_FALSE;
    6.68 +    }
    6.69 +    if (colorOperation != SDL_BLENDOPERATION_ADD || alphaOperation != SDL_BLENDOPERATION_ADD) {
    6.70 +        return SDL_FALSE;
    6.71 +    }
    6.72 +    return SDL_TRUE;
    6.73 +}
    6.74 +
    6.75  static D3DTEXTUREFILTERTYPE
    6.76  GetScaleQuality(void)
    6.77  {
    6.78 @@ -1353,55 +1407,22 @@
    6.79  }
    6.80  
    6.81  static void
    6.82 -D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
    6.83 +D3D_SetBlendMode(D3D_RenderData * data, SDL_BlendMode blendMode)
    6.84  {
    6.85 -    switch (blendMode) {
    6.86 -    case SDL_BLENDMODE_NONE:
    6.87 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
    6.88 -                                        FALSE);
    6.89 -        break;
    6.90 -    case SDL_BLENDMODE_BLEND:
    6.91 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
    6.92 -                                        TRUE);
    6.93 +    if (blendMode == SDL_BLENDMODE_NONE) {
    6.94 +        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, FALSE);
    6.95 +    } else {
    6.96 +        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, TRUE);
    6.97          IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
    6.98 -                                        D3DBLEND_SRCALPHA);
    6.99 +                                        GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)));
   6.100          IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
   6.101 -                                        D3DBLEND_INVSRCALPHA);
   6.102 +                                        GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)));
   6.103          if (data->enableSeparateAlphaBlend) {
   6.104              IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA,
   6.105 -                                            D3DBLEND_ONE);
   6.106 +                                            GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)));
   6.107              IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA,
   6.108 -                                            D3DBLEND_INVSRCALPHA);
   6.109 +                                            GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode)));
   6.110          }
   6.111 -        break;
   6.112 -    case SDL_BLENDMODE_ADD:
   6.113 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   6.114 -                                        TRUE);
   6.115 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
   6.116 -                                        D3DBLEND_SRCALPHA);
   6.117 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
   6.118 -                                        D3DBLEND_ONE);
   6.119 -        if (data->enableSeparateAlphaBlend) {
   6.120 -            IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA,
   6.121 -                                            D3DBLEND_ZERO);
   6.122 -            IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA,
   6.123 -                                            D3DBLEND_ONE);
   6.124 -        }
   6.125 -        break;
   6.126 -    case SDL_BLENDMODE_MOD:
   6.127 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   6.128 -                                        TRUE);
   6.129 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
   6.130 -                                        D3DBLEND_ZERO);
   6.131 -        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
   6.132 -                                        D3DBLEND_SRCCOLOR);
   6.133 -        if (data->enableSeparateAlphaBlend) {
   6.134 -            IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA,
   6.135 -                                            D3DBLEND_ZERO);
   6.136 -            IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA,
   6.137 -                                            D3DBLEND_ONE);
   6.138 -        }
   6.139 -        break;
   6.140      }
   6.141  }
   6.142  
     7.1 --- a/src/render/direct3d11/SDL_render_d3d11.c	Sun Aug 13 22:50:23 2017 -0700
     7.2 +++ b/src/render/direct3d11/SDL_render_d3d11.c	Mon Aug 14 05:51:44 2017 -0700
     7.3 @@ -93,6 +93,13 @@
     7.4      SDL_Rect locked_rect;
     7.5  } D3D11_TextureData;
     7.6  
     7.7 +/* Blend mode data */
     7.8 +typedef struct
     7.9 +{
    7.10 +    SDL_BlendMode blendMode;
    7.11 +    ID3D11BlendState *blendState;
    7.12 +} D3D11_BlendMode;
    7.13 +
    7.14  /* Private renderer data */
    7.15  typedef struct
    7.16  {
    7.17 @@ -112,9 +119,8 @@
    7.18      ID3D11PixelShader *colorPixelShader;
    7.19      ID3D11PixelShader *texturePixelShader;
    7.20      ID3D11PixelShader *yuvPixelShader;
    7.21 -    ID3D11BlendState *blendModeBlend;
    7.22 -    ID3D11BlendState *blendModeAdd;
    7.23 -    ID3D11BlendState *blendModeMod;
    7.24 +    int blendModesCount;
    7.25 +    D3D11_BlendMode *blendModes;
    7.26      ID3D11SamplerState *nearestPixelSampler;
    7.27      ID3D11SamplerState *linearSampler;
    7.28      D3D_FEATURE_LEVEL featureLevel;
    7.29 @@ -716,6 +722,7 @@
    7.30  static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
    7.31  static void D3D11_WindowEvent(SDL_Renderer * renderer,
    7.32                              const SDL_WindowEvent *event);
    7.33 +static SDL_bool D3D11_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode);
    7.34  static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    7.35  static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    7.36                               const SDL_Rect * rect, const void *srcPixels,
    7.37 @@ -826,6 +833,7 @@
    7.38      }
    7.39  
    7.40      renderer->WindowEvent = D3D11_WindowEvent;
    7.41 +    renderer->SupportsBlendMode = D3D11_SupportsBlendMode;
    7.42      renderer->CreateTexture = D3D11_CreateTexture;
    7.43      renderer->UpdateTexture = D3D11_UpdateTexture;
    7.44      renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
    7.45 @@ -898,6 +906,8 @@
    7.46  
    7.47      /* Release/reset everything else */
    7.48      if (data) {
    7.49 +        int i;
    7.50 +
    7.51          SAFE_RELEASE(data->dxgiFactory);
    7.52          SAFE_RELEASE(data->dxgiAdapter);
    7.53          SAFE_RELEASE(data->d3dDevice);
    7.54 @@ -911,9 +921,14 @@
    7.55          SAFE_RELEASE(data->colorPixelShader);
    7.56          SAFE_RELEASE(data->texturePixelShader);
    7.57          SAFE_RELEASE(data->yuvPixelShader);
    7.58 -        SAFE_RELEASE(data->blendModeBlend);
    7.59 -        SAFE_RELEASE(data->blendModeAdd);
    7.60 -        SAFE_RELEASE(data->blendModeMod);
    7.61 +        if (data->blendModesCount > 0) {
    7.62 +            for (i = 0; i < data->blendModesCount; ++i) {
    7.63 +                SAFE_RELEASE(data->blendModes[i].blendState);
    7.64 +            }
    7.65 +            SDL_free(data->blendModes);
    7.66 +
    7.67 +            data->blendModesCount = 0;
    7.68 +        }
    7.69          SAFE_RELEASE(data->nearestPixelSampler);
    7.70          SAFE_RELEASE(data->linearSampler);
    7.71          SAFE_RELEASE(data->mainRasterizer);
    7.72 @@ -954,37 +969,96 @@
    7.73      SDL_free(renderer);
    7.74  }
    7.75  
    7.76 -static HRESULT
    7.77 -D3D11_CreateBlendMode(SDL_Renderer * renderer,
    7.78 -                      BOOL enableBlending,
    7.79 -                      D3D11_BLEND srcBlend,
    7.80 -                      D3D11_BLEND destBlend,
    7.81 -                      D3D11_BLEND srcBlendAlpha,
    7.82 -                      D3D11_BLEND destBlendAlpha,
    7.83 -                      ID3D11BlendState ** blendStateOutput)
    7.84 +static D3D11_BLEND GetBlendFunc(SDL_BlendFactor factor)
    7.85 +{
    7.86 +    switch (factor) {
    7.87 +    case SDL_BLENDFACTOR_ZERO:
    7.88 +        return D3D11_BLEND_ZERO;
    7.89 +    case SDL_BLENDFACTOR_ONE:
    7.90 +        return D3D11_BLEND_ONE;
    7.91 +    case SDL_BLENDFACTOR_SRC_COLOR:
    7.92 +        return D3D11_BLEND_SRC_COLOR;
    7.93 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
    7.94 +        return D3D11_BLEND_INV_SRC_COLOR;
    7.95 +    case SDL_BLENDFACTOR_SRC_ALPHA:
    7.96 +        return D3D11_BLEND_SRC_ALPHA;
    7.97 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
    7.98 +        return D3D11_BLEND_INV_SRC_ALPHA;
    7.99 +    case SDL_BLENDFACTOR_DST_COLOR:
   7.100 +        return D3D11_BLEND_DEST_COLOR;
   7.101 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
   7.102 +        return D3D11_BLEND_INV_DEST_COLOR;
   7.103 +    case SDL_BLENDFACTOR_DST_ALPHA:
   7.104 +        return D3D11_BLEND_DEST_ALPHA;
   7.105 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
   7.106 +        return D3D11_BLEND_INV_DEST_ALPHA;
   7.107 +    default:
   7.108 +        return (D3D11_BLEND)0;
   7.109 +    }
   7.110 +}
   7.111 +
   7.112 +static D3D11_BLEND_OP GetBlendEquation(SDL_BlendOperation operation)
   7.113 +{
   7.114 +    switch (operation) {
   7.115 +    case SDL_BLENDOPERATION_ADD:
   7.116 +        return D3D11_BLEND_OP_ADD;
   7.117 +    case SDL_BLENDOPERATION_SUBTRACT:
   7.118 +        return D3D11_BLEND_OP_SUBTRACT;
   7.119 +    case SDL_BLENDOPERATION_REV_SUBTRACT:
   7.120 +        return D3D11_BLEND_OP_REV_SUBTRACT;
   7.121 +    case SDL_BLENDOPERATION_MINIMUM:
   7.122 +        return D3D11_BLEND_OP_MIN;
   7.123 +    case SDL_BLENDOPERATION_MAXIMUM:
   7.124 +        return D3D11_BLEND_OP_MAX;
   7.125 +    default:
   7.126 +        return (D3D11_BLEND_OP)0;
   7.127 +    }
   7.128 +}
   7.129 +
   7.130 +static SDL_bool
   7.131 +D3D11_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode)
   7.132  {
   7.133      D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
   7.134 +    SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
   7.135 +    SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
   7.136 +    SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
   7.137 +    SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
   7.138 +    SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
   7.139 +    SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
   7.140 +    ID3D11BlendState *blendState = NULL;
   7.141 +    D3D11_BlendMode *blendModes;
   7.142      HRESULT result = S_OK;
   7.143  
   7.144      D3D11_BLEND_DESC blendDesc;
   7.145      SDL_zero(blendDesc);
   7.146      blendDesc.AlphaToCoverageEnable = FALSE;
   7.147      blendDesc.IndependentBlendEnable = FALSE;
   7.148 -    blendDesc.RenderTarget[0].BlendEnable = enableBlending;
   7.149 -    blendDesc.RenderTarget[0].SrcBlend = srcBlend;
   7.150 -    blendDesc.RenderTarget[0].DestBlend = destBlend;
   7.151 -    blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
   7.152 -    blendDesc.RenderTarget[0].SrcBlendAlpha = srcBlendAlpha;
   7.153 -    blendDesc.RenderTarget[0].DestBlendAlpha = destBlendAlpha;
   7.154 -    blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
   7.155 +    blendDesc.RenderTarget[0].BlendEnable = TRUE;
   7.156 +    blendDesc.RenderTarget[0].SrcBlend = GetBlendFunc(srcColorFactor);
   7.157 +    blendDesc.RenderTarget[0].DestBlend = GetBlendFunc(dstColorFactor);
   7.158 +    blendDesc.RenderTarget[0].BlendOp = GetBlendEquation(colorOperation);
   7.159 +    blendDesc.RenderTarget[0].SrcBlendAlpha = GetBlendFunc(srcAlphaFactor);
   7.160 +    blendDesc.RenderTarget[0].DestBlendAlpha = GetBlendFunc(dstAlphaFactor);
   7.161 +    blendDesc.RenderTarget[0].BlendOpAlpha = GetBlendEquation(alphaOperation);
   7.162      blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
   7.163 -    result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, blendStateOutput);
   7.164 +    result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, &blendState);
   7.165      if (FAILED(result)) {
   7.166          WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBlendState"), result);
   7.167 -        return result;
   7.168 +        return SDL_FALSE;
   7.169      }
   7.170  
   7.171 -    return S_OK;
   7.172 +    blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes));
   7.173 +    if (!blendModes) {
   7.174 +        SAFE_RELEASE(blendState);
   7.175 +        SDL_OutOfMemory();
   7.176 +        return SDL_FALSE;
   7.177 +    }
   7.178 +    blendModes[data->blendModesCount].blendMode = blendMode;
   7.179 +    blendModes[data->blendModesCount].blendState = blendState;
   7.180 +    data->blendModes = blendModes;
   7.181 +    ++data->blendModesCount;
   7.182 +
   7.183 +    return SDL_TRUE;
   7.184  }
   7.185  
   7.186  /* Create resources that depend on the device. */
   7.187 @@ -1286,41 +1360,9 @@
   7.188      }
   7.189  
   7.190      /* Create blending states: */
   7.191 -    result = D3D11_CreateBlendMode(
   7.192 -        renderer,
   7.193 -        TRUE,
   7.194 -        D3D11_BLEND_SRC_ALPHA,          /* srcBlend */
   7.195 -        D3D11_BLEND_INV_SRC_ALPHA,      /* destBlend */
   7.196 -        D3D11_BLEND_ONE,                /* srcBlendAlpha */
   7.197 -        D3D11_BLEND_INV_SRC_ALPHA,      /* destBlendAlpha */
   7.198 -        &data->blendModeBlend);
   7.199 -    if (FAILED(result)) {
   7.200 -        /* D3D11_CreateBlendMode will set the SDL error, if it fails */
   7.201 -        goto done;
   7.202 -    }
   7.203 -
   7.204 -    result = D3D11_CreateBlendMode(
   7.205 -        renderer,
   7.206 -        TRUE,
   7.207 -        D3D11_BLEND_SRC_ALPHA,          /* srcBlend */
   7.208 -        D3D11_BLEND_ONE,                /* destBlend */
   7.209 -        D3D11_BLEND_ZERO,               /* srcBlendAlpha */
   7.210 -        D3D11_BLEND_ONE,                /* destBlendAlpha */
   7.211 -        &data->blendModeAdd);
   7.212 -    if (FAILED(result)) {
   7.213 -        /* D3D11_CreateBlendMode will set the SDL error, if it fails */
   7.214 -        goto done;
   7.215 -    }
   7.216 -
   7.217 -    result = D3D11_CreateBlendMode(
   7.218 -        renderer,
   7.219 -        TRUE,
   7.220 -        D3D11_BLEND_ZERO,               /* srcBlend */
   7.221 -        D3D11_BLEND_SRC_COLOR,          /* destBlend */
   7.222 -        D3D11_BLEND_ZERO,               /* srcBlendAlpha */
   7.223 -        D3D11_BLEND_ONE,                /* destBlendAlpha */
   7.224 -        &data->blendModeMod);
   7.225 -    if (FAILED(result)) {
   7.226 +    if (!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_BLEND) ||
   7.227 +        !D3D11_CreateBlendState(renderer, SDL_BLENDMODE_ADD) ||
   7.228 +        !D3D11_CreateBlendState(renderer, SDL_BLENDMODE_MOD)) {
   7.229          /* D3D11_CreateBlendMode will set the SDL error, if it fails */
   7.230          goto done;
   7.231      }
   7.232 @@ -1694,6 +1736,25 @@
   7.233      }
   7.234  }
   7.235  
   7.236 +static SDL_bool
   7.237 +D3D11_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
   7.238 +{
   7.239 +    SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
   7.240 +    SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
   7.241 +    SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
   7.242 +    SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
   7.243 +    SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
   7.244 +    SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
   7.245 +
   7.246 +    if (!GetBlendFunc(srcColorFactor) || !GetBlendFunc(srcAlphaFactor) ||
   7.247 +        !GetBlendEquation(colorOperation) ||
   7.248 +        !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor) ||
   7.249 +        !GetBlendEquation(alphaOperation)) {
   7.250 +        return SDL_FALSE;
   7.251 +    }
   7.252 +    return SDL_TRUE;
   7.253 +}
   7.254 +
   7.255  static D3D11_FILTER
   7.256  GetScaleQuality(void)
   7.257  {
   7.258 @@ -2443,19 +2504,21 @@
   7.259  {
   7.260      D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
   7.261      ID3D11BlendState *blendState = NULL;
   7.262 -    switch (blendMode) {
   7.263 -    case SDL_BLENDMODE_BLEND:
   7.264 -        blendState = rendererData->blendModeBlend;
   7.265 -        break;
   7.266 -    case SDL_BLENDMODE_ADD:
   7.267 -        blendState = rendererData->blendModeAdd;
   7.268 -        break;
   7.269 -    case SDL_BLENDMODE_MOD:
   7.270 -        blendState = rendererData->blendModeMod;
   7.271 -        break;
   7.272 -    case SDL_BLENDMODE_NONE:
   7.273 -        blendState = NULL;
   7.274 -        break;
   7.275 +    if (blendMode != SDL_BLENDMODE_NONE) {
   7.276 +        int i;
   7.277 +        for (i = 0; i < rendererData->blendModesCount; ++i) {
   7.278 +            if (blendMode == rendererData->blendModes[i].blendMode) {
   7.279 +                blendState = rendererData->blendModes[i].blendState;
   7.280 +                break;
   7.281 +            }
   7.282 +        }
   7.283 +        if (!blendState) {
   7.284 +            if (D3D11_CreateBlendState(renderer, blendMode)) {
   7.285 +                /* Successfully created the blend state, try again */
   7.286 +                D3D11_RenderSetBlendMode(renderer, blendMode);
   7.287 +            }
   7.288 +            return;
   7.289 +        }
   7.290      }
   7.291      if (blendState != rendererData->currentBlendState) {
   7.292          ID3D11DeviceContext_OMSetBlendState(rendererData->d3dContext, blendState, 0, 0xFFFFFFFF);
     8.1 --- a/src/render/opengl/SDL_glfuncs.h	Sun Aug 13 22:50:23 2017 -0700
     8.2 +++ b/src/render/opengl/SDL_glfuncs.h	Mon Aug 14 05:51:44 2017 -0700
     8.3 @@ -35,7 +35,8 @@
     8.4  SDL_PROC_UNUSED(void, glBitmap,
     8.5                  (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat,
     8.6                   const GLubyte *))
     8.7 -SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
     8.8 +SDL_PROC(void, glBlendEquation, (GLenum))
     8.9 +SDL_PROC_UNUSED(void, glBlendFunc, (GLenum, GLenum))
    8.10  SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
    8.11  SDL_PROC_UNUSED(void, glCallList, (GLuint))
    8.12  SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *))
     9.1 --- a/src/render/opengl/SDL_render_gl.c	Sun Aug 13 22:50:23 2017 -0700
     9.2 +++ b/src/render/opengl/SDL_render_gl.c	Mon Aug 14 05:51:44 2017 -0700
     9.3 @@ -55,6 +55,7 @@
     9.4  static void GL_WindowEvent(SDL_Renderer * renderer,
     9.5                             const SDL_WindowEvent *event);
     9.6  static int GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h);
     9.7 +static SDL_bool GL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode);
     9.8  static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     9.9  static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    9.10                              const SDL_Rect * rect, const void *pixels,
    9.11 @@ -126,7 +127,7 @@
    9.12      struct {
    9.13          GL_Shader shader;
    9.14          Uint32 color;
    9.15 -        int blendMode;
    9.16 +        SDL_BlendMode blendMode;
    9.17      } current;
    9.18  
    9.19      SDL_bool GL_EXT_framebuffer_object_supported;
    9.20 @@ -321,7 +322,7 @@
    9.21  
    9.22      data->current.shader = SHADER_NONE;
    9.23      data->current.color = 0xffffffff;
    9.24 -    data->current.blendMode = -1;
    9.25 +    data->current.blendMode = SDL_BLENDMODE_INVALID;
    9.26  
    9.27      data->glDisable(GL_DEPTH_TEST);
    9.28      data->glDisable(GL_CULL_FACE);
    9.29 @@ -428,6 +429,7 @@
    9.30  
    9.31      renderer->WindowEvent = GL_WindowEvent;
    9.32      renderer->GetOutputSize = GL_GetOutputSize;
    9.33 +    renderer->SupportsBlendMode = GL_SupportsBlendMode;
    9.34      renderer->CreateTexture = GL_CreateTexture;
    9.35      renderer->UpdateTexture = GL_UpdateTexture;
    9.36      renderer->UpdateTextureYUV = GL_UpdateTextureYUV;
    9.37 @@ -595,6 +597,73 @@
    9.38      return 0;
    9.39  }
    9.40  
    9.41 +static GLenum GetBlendFunc(SDL_BlendFactor factor)
    9.42 +{
    9.43 +    switch (factor) {
    9.44 +    case SDL_BLENDFACTOR_ZERO:
    9.45 +        return GL_ZERO;
    9.46 +    case SDL_BLENDFACTOR_ONE:
    9.47 +        return GL_ONE;
    9.48 +    case SDL_BLENDFACTOR_SRC_COLOR:
    9.49 +        return GL_SRC_COLOR;
    9.50 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
    9.51 +        return GL_ONE_MINUS_SRC_COLOR;
    9.52 +    case SDL_BLENDFACTOR_SRC_ALPHA:
    9.53 +        return GL_SRC_ALPHA;
    9.54 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
    9.55 +        return GL_ONE_MINUS_SRC_ALPHA;
    9.56 +    case SDL_BLENDFACTOR_DST_COLOR:
    9.57 +        return GL_DST_COLOR;
    9.58 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
    9.59 +        return GL_ONE_MINUS_DST_COLOR;
    9.60 +    case SDL_BLENDFACTOR_DST_ALPHA:
    9.61 +        return GL_DST_ALPHA;
    9.62 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
    9.63 +        return GL_ONE_MINUS_DST_ALPHA;
    9.64 +    default:
    9.65 +        return GL_INVALID_ENUM;
    9.66 +    }
    9.67 +}
    9.68 +
    9.69 +static GLenum GetBlendEquation(SDL_BlendOperation operation)
    9.70 +{
    9.71 +    switch (operation) {
    9.72 +    case SDL_BLENDOPERATION_ADD:
    9.73 +        return GL_FUNC_ADD;
    9.74 +    case SDL_BLENDOPERATION_SUBTRACT:
    9.75 +        return GL_FUNC_SUBTRACT;
    9.76 +    case SDL_BLENDOPERATION_REV_SUBTRACT:
    9.77 +        return GL_FUNC_REVERSE_SUBTRACT;
    9.78 +    default:
    9.79 +        return GL_INVALID_ENUM;
    9.80 +    }
    9.81 +}
    9.82 +
    9.83 +static SDL_bool
    9.84 +GL_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
    9.85 +{
    9.86 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    9.87 +    SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
    9.88 +    SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
    9.89 +    SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
    9.90 +    SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
    9.91 +    SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
    9.92 +    SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
    9.93 +
    9.94 +    if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM ||
    9.95 +        GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM ||
    9.96 +        GetBlendEquation(colorOperation) == GL_INVALID_ENUM ||
    9.97 +        GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM ||
    9.98 +        GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM ||
    9.99 +        GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) {
   9.100 +        return SDL_FALSE;
   9.101 +    }
   9.102 +    if (colorOperation != alphaOperation) {
   9.103 +        return SDL_FALSE;
   9.104 +    }
   9.105 +    return SDL_TRUE;
   9.106 +}
   9.107 +
   9.108  SDL_FORCE_INLINE int
   9.109  power_of_2(int input)
   9.110  {
   9.111 @@ -1092,25 +1161,18 @@
   9.112  }
   9.113  
   9.114  static void
   9.115 -GL_SetBlendMode(GL_RenderData * data, int blendMode)
   9.116 +GL_SetBlendMode(GL_RenderData * data, SDL_BlendMode blendMode)
   9.117  {
   9.118      if (blendMode != data->current.blendMode) {
   9.119 -        switch (blendMode) {
   9.120 -        case SDL_BLENDMODE_NONE:
   9.121 +        if (blendMode == SDL_BLENDMODE_NONE) {
   9.122              data->glDisable(GL_BLEND);
   9.123 -            break;
   9.124 -        case SDL_BLENDMODE_BLEND:
   9.125 +        } else {
   9.126              data->glEnable(GL_BLEND);
   9.127 -            data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
   9.128 -            break;
   9.129 -        case SDL_BLENDMODE_ADD:
   9.130 -            data->glEnable(GL_BLEND);
   9.131 -            data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
   9.132 -            break;
   9.133 -        case SDL_BLENDMODE_MOD:
   9.134 -            data->glEnable(GL_BLEND);
   9.135 -            data->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
   9.136 -            break;
   9.137 +            data->glBlendFuncSeparate(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)),
   9.138 +                                      GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)),
   9.139 +                                      GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)),
   9.140 +                                      GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode)));
   9.141 +            data->glBlendEquation(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode)));
   9.142          }
   9.143          data->current.blendMode = blendMode;
   9.144      }
    10.1 --- a/src/render/opengles/SDL_glesfuncs.h	Sun Aug 13 22:50:23 2017 -0700
    10.2 +++ b/src/render/opengles/SDL_glesfuncs.h	Mon Aug 14 05:51:44 2017 -0700
    10.3 @@ -21,6 +21,8 @@
    10.4  
    10.5  SDL_PROC(void, glBindTexture, (GLenum, GLuint))
    10.6  SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
    10.7 +SDL_PROC_OES(void, glBlendEquationOES, (GLenum))
    10.8 +SDL_PROC_OES(void, glBlendEquationSeparateOES, (GLenum, GLenum))
    10.9  SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum))
   10.10  SDL_PROC(void, glClear, (GLbitfield))
   10.11  SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
    11.1 --- a/src/render/opengles/SDL_render_gles.c	Sun Aug 13 22:50:23 2017 -0700
    11.2 +++ b/src/render/opengles/SDL_render_gles.c	Mon Aug 14 05:51:44 2017 -0700
    11.3 @@ -56,6 +56,7 @@
    11.4  static void GLES_WindowEvent(SDL_Renderer * renderer,
    11.5                               const SDL_WindowEvent *event);
    11.6  static int GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h);
    11.7 +static SDL_bool GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode);
    11.8  static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    11.9  static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   11.10                                const SDL_Rect * rect, const void *pixels,
   11.11 @@ -116,7 +117,7 @@
   11.12      SDL_GLContext context;
   11.13      struct {
   11.14          Uint32 color;
   11.15 -        int blendMode;
   11.16 +        SDL_BlendMode blendMode;
   11.17          SDL_bool tex_coords;
   11.18      } current;
   11.19  
   11.20 @@ -130,6 +131,8 @@
   11.21      GLuint window_framebuffer;
   11.22  
   11.23      SDL_bool GL_OES_blend_func_separate_supported;
   11.24 +    SDL_bool GL_OES_blend_equation_separate_supported;
   11.25 +    SDL_bool GL_OES_blend_subtract_supported;
   11.26  } GLES_RenderData;
   11.27  
   11.28  typedef struct
   11.29 @@ -262,7 +265,7 @@
   11.30      }
   11.31  
   11.32      data->current.color = 0xffffffff;
   11.33 -    data->current.blendMode = -1;
   11.34 +    data->current.blendMode = SDL_BLENDMODE_INVALID;
   11.35      data->current.tex_coords = SDL_FALSE;
   11.36  
   11.37      data->glDisable(GL_DEPTH_TEST);
   11.38 @@ -319,6 +322,7 @@
   11.39  
   11.40      renderer->WindowEvent = GLES_WindowEvent;
   11.41      renderer->GetOutputSize = GLES_GetOutputSize;
   11.42 +    renderer->SupportsBlendMode = GLES_SupportsBlendMode;
   11.43      renderer->CreateTexture = GLES_CreateTexture;
   11.44      renderer->UpdateTexture = GLES_UpdateTexture;
   11.45      renderer->LockTexture = GLES_LockTexture;
   11.46 @@ -388,6 +392,12 @@
   11.47      if (SDL_GL_ExtensionSupported("GL_OES_blend_func_separate")) {
   11.48          data->GL_OES_blend_func_separate_supported = SDL_TRUE;
   11.49      }
   11.50 +    if (SDL_GL_ExtensionSupported("GL_OES_blend_equation_separate")) {
   11.51 +        data->GL_OES_blend_equation_separate_supported = SDL_TRUE;
   11.52 +    }
   11.53 +    if (SDL_GL_ExtensionSupported("GL_OES_blend_subtract")) {
   11.54 +        data->GL_OES_blend_subtract_supported = SDL_TRUE;
   11.55 +    }
   11.56  
   11.57      /* Set up parameters for rendering */
   11.58      GLES_ResetState(renderer);
   11.59 @@ -430,6 +440,79 @@
   11.60      return 0;
   11.61  }
   11.62  
   11.63 +static GLenum GetBlendFunc(SDL_BlendFactor factor)
   11.64 +{
   11.65 +    switch (factor) {
   11.66 +    case SDL_BLENDFACTOR_ZERO:
   11.67 +        return GL_ZERO;
   11.68 +    case SDL_BLENDFACTOR_ONE:
   11.69 +        return GL_ONE;
   11.70 +    case SDL_BLENDFACTOR_SRC_COLOR:
   11.71 +        return GL_SRC_COLOR;
   11.72 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
   11.73 +        return GL_ONE_MINUS_SRC_COLOR;
   11.74 +    case SDL_BLENDFACTOR_SRC_ALPHA:
   11.75 +        return GL_SRC_ALPHA;
   11.76 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
   11.77 +        return GL_ONE_MINUS_SRC_ALPHA;
   11.78 +    case SDL_BLENDFACTOR_DST_COLOR:
   11.79 +        return GL_DST_COLOR;
   11.80 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
   11.81 +        return GL_ONE_MINUS_DST_COLOR;
   11.82 +    case SDL_BLENDFACTOR_DST_ALPHA:
   11.83 +        return GL_DST_ALPHA;
   11.84 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
   11.85 +        return GL_ONE_MINUS_DST_ALPHA;
   11.86 +    default:
   11.87 +        return GL_INVALID_ENUM;
   11.88 +    }
   11.89 +}
   11.90 +
   11.91 +static GLenum GetBlendEquation(SDL_BlendOperation operation)
   11.92 +{
   11.93 +    switch (operation) {
   11.94 +    case SDL_BLENDOPERATION_ADD:
   11.95 +        return GL_FUNC_ADD_OES;
   11.96 +    case SDL_BLENDOPERATION_SUBTRACT:
   11.97 +        return GL_FUNC_SUBTRACT_OES;
   11.98 +    case SDL_BLENDOPERATION_REV_SUBTRACT:
   11.99 +        return GL_FUNC_REVERSE_SUBTRACT_OES;
  11.100 +    default:
  11.101 +        return GL_INVALID_ENUM;
  11.102 +    }
  11.103 +}
  11.104 +
  11.105 +static SDL_bool
  11.106 +GLES_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
  11.107 +{
  11.108 +    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
  11.109 +    SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
  11.110 +    SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
  11.111 +    SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
  11.112 +    SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
  11.113 +    SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
  11.114 +    SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
  11.115 +
  11.116 +    if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM ||
  11.117 +        GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM ||
  11.118 +        GetBlendEquation(colorOperation) == GL_INVALID_ENUM ||
  11.119 +        GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM ||
  11.120 +        GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM ||
  11.121 +        GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) {
  11.122 +        return SDL_FALSE;
  11.123 +    }
  11.124 +    if ((srcColorFactor != srcAlphaFactor || dstColorFactor != dstAlphaFactor) && !data->GL_OES_blend_func_separate_supported) {
  11.125 +        return SDL_FALSE;
  11.126 +    }
  11.127 +    if (colorOperation != alphaOperation && !data->GL_OES_blend_equation_separate_supported) {
  11.128 +        return SDL_FALSE;
  11.129 +    }
  11.130 +    if (colorOperation != SDL_BLENDOPERATION_ADD && !data->GL_OES_blend_subtract_supported) {
  11.131 +        return SDL_FALSE;
  11.132 +    }
  11.133 +    return SDL_TRUE;
  11.134 +}
  11.135 +
  11.136  static SDL_INLINE int
  11.137  power_of_2(int input)
  11.138  {
  11.139 @@ -739,37 +822,28 @@
  11.140  }
  11.141  
  11.142  static void
  11.143 -GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
  11.144 +GLES_SetBlendMode(GLES_RenderData * data, SDL_BlendMode blendMode)
  11.145  {
  11.146      if (blendMode != data->current.blendMode) {
  11.147 -        switch (blendMode) {
  11.148 -        case SDL_BLENDMODE_NONE:
  11.149 +        if (blendMode == SDL_BLENDMODE_NONE) {
  11.150              data->glDisable(GL_BLEND);
  11.151 -            break;
  11.152 -        case SDL_BLENDMODE_BLEND:
  11.153 +        } else {
  11.154              data->glEnable(GL_BLEND);
  11.155              if (data->GL_OES_blend_func_separate_supported) {
  11.156 -                data->glBlendFuncSeparateOES(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
  11.157 +                data->glBlendFuncSeparateOES(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)),
  11.158 +                                             GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)),
  11.159 +                                             GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)),
  11.160 +                                             GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode)));
  11.161              } else {
  11.162 -                data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  11.163 +                data->glBlendFunc(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)),
  11.164 +                                  GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)));
  11.165              }
  11.166 -            break;
  11.167 -        case SDL_BLENDMODE_ADD:
  11.168 -            data->glEnable(GL_BLEND);
  11.169 -            if (data->GL_OES_blend_func_separate_supported) {
  11.170 -                data->glBlendFuncSeparateOES(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
  11.171 -            } else {
  11.172 -                data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  11.173 +            if (data->GL_OES_blend_equation_separate_supported) {
  11.174 +                data->glBlendEquationSeparateOES(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode)),
  11.175 +                                                 GetBlendEquation(SDL_GetBlendModeAlphaOperation(blendMode)));
  11.176 +            } else if (data->GL_OES_blend_subtract_supported) {
  11.177 +                data->glBlendEquationOES(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode)));
  11.178              }
  11.179 -            break;
  11.180 -        case SDL_BLENDMODE_MOD:
  11.181 -            data->glEnable(GL_BLEND);
  11.182 -            if (data->GL_OES_blend_func_separate_supported) {
  11.183 -                data->glBlendFuncSeparateOES(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
  11.184 -            } else {
  11.185 -                data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
  11.186 -            }
  11.187 -            break;
  11.188          }
  11.189          data->current.blendMode = blendMode;
  11.190      }
    12.1 --- a/src/render/opengles2/SDL_gles2funcs.h	Sun Aug 13 22:50:23 2017 -0700
    12.2 +++ b/src/render/opengles2/SDL_gles2funcs.h	Mon Aug 14 05:51:44 2017 -0700
    12.3 @@ -23,6 +23,7 @@
    12.4  SDL_PROC(void, glAttachShader, (GLuint, GLuint))
    12.5  SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
    12.6  SDL_PROC(void, glBindTexture, (GLenum, GLuint))
    12.7 +SDL_PROC(void, glBlendEquationSeparate, (GLenum, GLenum))
    12.8  SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
    12.9  SDL_PROC(void, glClear, (GLbitfield))
   12.10  SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
    13.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sun Aug 13 22:50:23 2017 -0700
    13.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Mon Aug 14 05:51:44 2017 -0700
    13.3 @@ -122,7 +122,6 @@
    13.4  typedef struct GLES2_ProgramCacheEntry
    13.5  {
    13.6      GLuint id;
    13.7 -    SDL_BlendMode blend_mode;
    13.8      GLES2_ShaderCacheEntry *vertex_shader;
    13.9      GLES2_ShaderCacheEntry *fragment_shader;
   13.10      GLuint uniform_locations[16];
   13.11 @@ -177,7 +176,7 @@
   13.12      SDL_bool debug_enabled;
   13.13  
   13.14      struct {
   13.15 -        int blendMode;
   13.16 +        SDL_BlendMode blendMode;
   13.17          SDL_bool tex_coords;
   13.18      } current;
   13.19  
   13.20 @@ -372,6 +371,70 @@
   13.21      return 0;
   13.22  }
   13.23  
   13.24 +static GLenum GetBlendFunc(SDL_BlendFactor factor)
   13.25 +{
   13.26 +    switch (factor) {
   13.27 +    case SDL_BLENDFACTOR_ZERO:
   13.28 +        return GL_ZERO;
   13.29 +    case SDL_BLENDFACTOR_ONE:
   13.30 +        return GL_ONE;
   13.31 +    case SDL_BLENDFACTOR_SRC_COLOR:
   13.32 +        return GL_SRC_COLOR;
   13.33 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
   13.34 +        return GL_ONE_MINUS_SRC_COLOR;
   13.35 +    case SDL_BLENDFACTOR_SRC_ALPHA:
   13.36 +        return GL_SRC_ALPHA;
   13.37 +    case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
   13.38 +        return GL_ONE_MINUS_SRC_ALPHA;
   13.39 +    case SDL_BLENDFACTOR_DST_COLOR:
   13.40 +        return GL_DST_COLOR;
   13.41 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
   13.42 +        return GL_ONE_MINUS_DST_COLOR;
   13.43 +    case SDL_BLENDFACTOR_DST_ALPHA:
   13.44 +        return GL_DST_ALPHA;
   13.45 +    case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
   13.46 +        return GL_ONE_MINUS_DST_ALPHA;
   13.47 +    default:
   13.48 +        return GL_INVALID_ENUM;
   13.49 +    }
   13.50 +}
   13.51 +
   13.52 +static GLenum GetBlendEquation(SDL_BlendOperation operation)
   13.53 +{
   13.54 +    switch (operation) {
   13.55 +    case SDL_BLENDOPERATION_ADD:
   13.56 +        return GL_FUNC_ADD;
   13.57 +    case SDL_BLENDOPERATION_SUBTRACT:
   13.58 +        return GL_FUNC_SUBTRACT;
   13.59 +    case SDL_BLENDOPERATION_REV_SUBTRACT:
   13.60 +        return GL_FUNC_REVERSE_SUBTRACT;
   13.61 +    default:
   13.62 +        return GL_INVALID_ENUM;
   13.63 +    }
   13.64 +}
   13.65 +
   13.66 +static SDL_bool
   13.67 +GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
   13.68 +{
   13.69 +    GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata;
   13.70 +    SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
   13.71 +    SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
   13.72 +    SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
   13.73 +    SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
   13.74 +    SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
   13.75 +    SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
   13.76 +
   13.77 +    if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM ||
   13.78 +        GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM ||
   13.79 +        GetBlendEquation(colorOperation) == GL_INVALID_ENUM ||
   13.80 +        GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM ||
   13.81 +        GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM ||
   13.82 +        GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) {
   13.83 +        return SDL_FALSE;
   13.84 +    }
   13.85 +    return SDL_TRUE;
   13.86 +}
   13.87 +
   13.88  static int
   13.89  GLES2_UpdateViewport(SDL_Renderer * renderer)
   13.90  {
   13.91 @@ -882,19 +945,16 @@
   13.92   * Shader management functions                                                                   *
   13.93   *************************************************************************************************/
   13.94  
   13.95 -static GLES2_ShaderCacheEntry *GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type,
   13.96 -                                                 SDL_BlendMode blendMode);
   13.97 +static GLES2_ShaderCacheEntry *GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type);
   13.98  static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry);
   13.99  static GLES2_ProgramCacheEntry *GLES2_CacheProgram(SDL_Renderer *renderer,
  13.100                                                     GLES2_ShaderCacheEntry *vertex,
  13.101 -                                                   GLES2_ShaderCacheEntry *fragment,
  13.102 -                                                   SDL_BlendMode blendMode);
  13.103 -static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source,
  13.104 -                               SDL_BlendMode blendMode);
  13.105 +                                                   GLES2_ShaderCacheEntry *fragment);
  13.106 +static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source);
  13.107  
  13.108  static GLES2_ProgramCacheEntry *
  13.109  GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
  13.110 -                   GLES2_ShaderCacheEntry *fragment, SDL_BlendMode blendMode)
  13.111 +                   GLES2_ShaderCacheEntry *fragment)
  13.112  {
  13.113      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
  13.114      GLES2_ProgramCacheEntry *entry;
  13.115 @@ -933,7 +993,6 @@
  13.116      }
  13.117      entry->vertex_shader = vertex;
  13.118      entry->fragment_shader = fragment;
  13.119 -    entry->blend_mode = blendMode;
  13.120  
  13.121      /* Create the program and link it */
  13.122      entry->id = data->glCreateProgram();
  13.123 @@ -1011,7 +1070,7 @@
  13.124  }
  13.125  
  13.126  static GLES2_ShaderCacheEntry *
  13.127 -GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode blendMode)
  13.128 +GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type)
  13.129  {
  13.130      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
  13.131      const GLES2_Shader *shader;
  13.132 @@ -1021,7 +1080,7 @@
  13.133      int i, j;
  13.134  
  13.135      /* Find the corresponding shader */
  13.136 -    shader = GLES2_GetShader(type, blendMode);
  13.137 +    shader = GLES2_GetShader(type);
  13.138      if (!shader) {
  13.139          SDL_SetError("No shader matching the requested characteristics was found");
  13.140          return NULL;
  13.141 @@ -1130,7 +1189,7 @@
  13.142  }
  13.143  
  13.144  static int
  13.145 -GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendMode blendMode)
  13.146 +GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source)
  13.147  {
  13.148      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
  13.149      GLES2_ShaderCacheEntry *vertex = NULL;
  13.150 @@ -1170,11 +1229,11 @@
  13.151      }
  13.152  
  13.153      /* Load the requested shaders */
  13.154 -    vertex = GLES2_CacheShader(renderer, vtype, blendMode);
  13.155 +    vertex = GLES2_CacheShader(renderer, vtype);
  13.156      if (!vertex) {
  13.157          goto fault;
  13.158      }
  13.159 -    fragment = GLES2_CacheShader(renderer, ftype, blendMode);
  13.160 +    fragment = GLES2_CacheShader(renderer, ftype);
  13.161      if (!fragment) {
  13.162          goto fault;
  13.163      }
  13.164 @@ -1187,7 +1246,7 @@
  13.165      }
  13.166  
  13.167      /* Generate a matching program */
  13.168 -    program = GLES2_CacheProgram(renderer, vertex, fragment, blendMode);
  13.169 +    program = GLES2_CacheProgram(renderer, vertex, fragment);
  13.170      if (!program) {
  13.171          goto fault;
  13.172      }
  13.173 @@ -1341,26 +1400,19 @@
  13.174  }
  13.175  
  13.176  static void
  13.177 -GLES2_SetBlendMode(GLES2_DriverContext *data, int blendMode)
  13.178 +GLES2_SetBlendMode(GLES2_DriverContext *data, SDL_BlendMode blendMode)
  13.179  {
  13.180      if (blendMode != data->current.blendMode) {
  13.181 -        switch (blendMode) {
  13.182 -        default:
  13.183 -        case SDL_BLENDMODE_NONE:
  13.184 +        if (blendMode == SDL_BLENDMODE_NONE) {
  13.185              data->glDisable(GL_BLEND);
  13.186 -            break;
  13.187 -        case SDL_BLENDMODE_BLEND:
  13.188 +        } else {
  13.189              data->glEnable(GL_BLEND);
  13.190 -            data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
  13.191 -            break;
  13.192 -        case SDL_BLENDMODE_ADD:
  13.193 -            data->glEnable(GL_BLEND);
  13.194 -            data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
  13.195 -            break;
  13.196 -        case SDL_BLENDMODE_MOD:
  13.197 -            data->glEnable(GL_BLEND);
  13.198 -            data->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
  13.199 -            break;
  13.200 +            data->glBlendFuncSeparate(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blendMode)),
  13.201 +                                      GetBlendFunc(SDL_GetBlendModeDstColorFactor(blendMode)),
  13.202 +                                      GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blendMode)),
  13.203 +                                      GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blendMode)));
  13.204 +            data->glBlendEquationSeparate(GetBlendEquation(SDL_GetBlendModeColorOperation(blendMode)),
  13.205 +                                          GetBlendEquation(SDL_GetBlendModeAlphaOperation(blendMode)));
  13.206          }
  13.207          data->current.blendMode = blendMode;
  13.208      }
  13.209 @@ -1383,18 +1435,17 @@
  13.210  GLES2_SetDrawingState(SDL_Renderer * renderer)
  13.211  {
  13.212      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
  13.213 -    const int blendMode = renderer->blendMode;
  13.214      GLES2_ProgramCacheEntry *program;
  13.215      Uint8 r, g, b, a;
  13.216  
  13.217      GLES2_ActivateRenderer(renderer);
  13.218  
  13.219 -    GLES2_SetBlendMode(data, blendMode);
  13.220 +    GLES2_SetBlendMode(data, renderer->blendMode);
  13.221  
  13.222      GLES2_SetTexCoords(data, SDL_FALSE);
  13.223  
  13.224      /* Activate an appropriate shader and set the projection matrix */
  13.225 -    if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) {
  13.226 +    if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID) < 0) {
  13.227          return -1;
  13.228      }
  13.229  
  13.230 @@ -1555,12 +1606,10 @@
  13.231      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
  13.232      GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
  13.233      GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
  13.234 -    SDL_BlendMode blendMode;
  13.235      GLES2_ProgramCacheEntry *program;
  13.236      Uint8 r, g, b, a;
  13.237  
  13.238      /* Activate an appropriate shader and set the projection matrix */
  13.239 -    blendMode = texture->blendMode;
  13.240      if (renderer->target) {
  13.241          /* Check if we need to do color mapping between the source and render target textures */
  13.242          if (renderer->target->format != texture->format) {
  13.243 @@ -1658,7 +1707,7 @@
  13.244          }
  13.245      }
  13.246  
  13.247 -    if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) {
  13.248 +    if (GLES2_SelectProgram(renderer, sourceType) < 0) {
  13.249          return -1;
  13.250      }
  13.251  
  13.252 @@ -1705,7 +1754,7 @@
  13.253      }
  13.254  
  13.255      /* Configure texture blending */
  13.256 -    GLES2_SetBlendMode(data, blendMode);
  13.257 +    GLES2_SetBlendMode(data, renderer->blendMode);
  13.258  
  13.259      GLES2_SetTexCoords(data, SDL_TRUE);
  13.260      return 0;
  13.261 @@ -1938,7 +1987,7 @@
  13.262          GLES2_ActivateRenderer(renderer);
  13.263      }
  13.264  
  13.265 -    data->current.blendMode = -1;
  13.266 +    data->current.blendMode = SDL_BLENDMODE_INVALID;
  13.267      data->current.tex_coords = SDL_FALSE;
  13.268  
  13.269      data->glActiveTexture(GL_TEXTURE0);
  13.270 @@ -2091,28 +2140,29 @@
  13.271      data->window_framebuffer = (GLuint)window_framebuffer;
  13.272  
  13.273      /* Populate the function pointers for the module */
  13.274 -    renderer->WindowEvent         = &GLES2_WindowEvent;
  13.275 -    renderer->GetOutputSize       = &GLES2_GetOutputSize;
  13.276 -    renderer->CreateTexture       = &GLES2_CreateTexture;
  13.277 -    renderer->UpdateTexture       = &GLES2_UpdateTexture;
  13.278 -    renderer->UpdateTextureYUV    = &GLES2_UpdateTextureYUV;
  13.279 -    renderer->LockTexture         = &GLES2_LockTexture;
  13.280 -    renderer->UnlockTexture       = &GLES2_UnlockTexture;
  13.281 -    renderer->SetRenderTarget     = &GLES2_SetRenderTarget;
  13.282 -    renderer->UpdateViewport      = &GLES2_UpdateViewport;
  13.283 -    renderer->UpdateClipRect      = &GLES2_UpdateClipRect;
  13.284 -    renderer->RenderClear         = &GLES2_RenderClear;
  13.285 -    renderer->RenderDrawPoints    = &GLES2_RenderDrawPoints;
  13.286 -    renderer->RenderDrawLines     = &GLES2_RenderDrawLines;
  13.287 -    renderer->RenderFillRects     = &GLES2_RenderFillRects;
  13.288 -    renderer->RenderCopy          = &GLES2_RenderCopy;
  13.289 -    renderer->RenderCopyEx        = &GLES2_RenderCopyEx;
  13.290 -    renderer->RenderReadPixels    = &GLES2_RenderReadPixels;
  13.291 -    renderer->RenderPresent       = &GLES2_RenderPresent;
  13.292 -    renderer->DestroyTexture      = &GLES2_DestroyTexture;
  13.293 -    renderer->DestroyRenderer     = &GLES2_DestroyRenderer;
  13.294 -    renderer->GL_BindTexture      = &GLES2_BindTexture;
  13.295 -    renderer->GL_UnbindTexture    = &GLES2_UnbindTexture;
  13.296 +    renderer->WindowEvent         = GLES2_WindowEvent;
  13.297 +    renderer->GetOutputSize       = GLES2_GetOutputSize;
  13.298 +    renderer->SupportsBlendMode   = GLES2_SupportsBlendMode;
  13.299 +    renderer->CreateTexture       = GLES2_CreateTexture;
  13.300 +    renderer->UpdateTexture       = GLES2_UpdateTexture;
  13.301 +    renderer->UpdateTextureYUV    = GLES2_UpdateTextureYUV;
  13.302 +    renderer->LockTexture         = GLES2_LockTexture;
  13.303 +    renderer->UnlockTexture       = GLES2_UnlockTexture;
  13.304 +    renderer->SetRenderTarget     = GLES2_SetRenderTarget;
  13.305 +    renderer->UpdateViewport      = GLES2_UpdateViewport;
  13.306 +    renderer->UpdateClipRect      = GLES2_UpdateClipRect;
  13.307 +    renderer->RenderClear         = GLES2_RenderClear;
  13.308 +    renderer->RenderDrawPoints    = GLES2_RenderDrawPoints;
  13.309 +    renderer->RenderDrawLines     = GLES2_RenderDrawLines;
  13.310 +    renderer->RenderFillRects     = GLES2_RenderFillRects;
  13.311 +    renderer->RenderCopy          = GLES2_RenderCopy;
  13.312 +    renderer->RenderCopyEx        = GLES2_RenderCopyEx;
  13.313 +    renderer->RenderReadPixels    = GLES2_RenderReadPixels;
  13.314 +    renderer->RenderPresent       = GLES2_RenderPresent;
  13.315 +    renderer->DestroyTexture      = GLES2_DestroyTexture;
  13.316 +    renderer->DestroyRenderer     = GLES2_DestroyRenderer;
  13.317 +    renderer->GL_BindTexture      = GLES2_BindTexture;
  13.318 +    renderer->GL_UnbindTexture    = GLES2_UnbindTexture;
  13.319  
  13.320      renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
  13.321      renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
    14.1 --- a/src/render/opengles2/SDL_shaders_gles2.c	Sun Aug 13 22:50:23 2017 -0700
    14.2 +++ b/src/render/opengles2/SDL_shaders_gles2.c	Mon Aug 14 05:51:44 2017 -0700
    14.3 @@ -259,523 +259,45 @@
    14.4  
    14.5  
    14.6  /*************************************************************************************************
    14.7 - * Vertex/fragment shader binaries (NVIDIA Tegra 1/2)                                            *
    14.8 - *************************************************************************************************/
    14.9 -
   14.10 -#if GLES2_INCLUDE_NVIDIA_SHADERS
   14.11 -
   14.12 -#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
   14.13 -
   14.14 -static const Uint8 GLES2_VertexTegra_Default_[] = {
   14.15 -    243, 193, 1, 142, 31, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
   14.16 -    0, 0, 46, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 85, 0, 0, 0, 2, 0, 0, 0, 24, 0, 0, 0, 3, 0, 0, 0,
   14.17 -    91, 0, 0, 0, 1, 0, 0, 0, 16, 0, 0, 0, 5, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.18 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 95, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0,
   14.19 -    13, 0, 0, 0, 102, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.20 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.21 -    0, 0, 0, 16, 0, 0, 0, 104, 0, 0, 0, 1, 0, 0, 0, 32, 0, 0, 0, 17, 0, 0, 0, 112, 0, 0, 0, 0, 0,
   14.22 -    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 112, 0, 0, 0, 80, 0, 0, 0, 80, 0, 0, 0, 19, 0, 0, 0, 132, 0,
   14.23 -    0, 0, 104, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.24 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 97,
   14.25 -    95, 112, 111, 115, 105, 116, 105, 111, 110, 0, 97, 95, 116, 101, 120, 67, 111, 111, 114, 100,
   14.26 -    0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 112, 114, 111, 106, 101, 99,
   14.27 -    116, 105, 111, 110, 0, 0, 0, 0, 0, 0, 0, 82, 139, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 80, 139, 0,
   14.28 -    0, 1, 0, 0, 0, 22, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 33, 0, 0, 0, 92, 139, 0, 0,
   14.29 -    1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 240, 0, 0, 0, 0, 0, 0, 1, 0,
   14.30 -    0, 0, 64, 0, 0, 0, 80, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 193, 0, 0, 0,
   14.31 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.32 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.33 -    0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 24, 0, 6, 34, 108, 28,
   14.34 -    0, 0, 42, 16, 128, 0, 195, 192, 6, 129, 252, 255, 65, 96, 108, 28, 0, 0, 0, 0, 0, 1, 195, 192,
   14.35 -    6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 8, 1, 64, 0, 131, 192, 6, 1, 156, 159, 65, 96, 108,
   14.36 -    28, 0, 0, 85, 32, 0, 1, 195, 192, 6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 0, 64, 64, 0, 131,
   14.37 -    192, 134, 1, 152, 31, 65, 96, 108, 156, 31, 64, 127, 48, 0, 1, 195, 192, 6, 129, 129, 255, 33,
   14.38 -    96
   14.39 -};
   14.40 -
   14.41 -static const Uint8 GLES2_FragmentTegra_None_SolidSrc_[] = {
   14.42 -    155, 191, 159, 1, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
   14.43 -    0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
   14.44 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
   14.45 -    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
   14.46 -    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.47 -    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
   14.48 -    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
   14.49 -    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
   14.50 -    0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
   14.51 -    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.52 -    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
   14.53 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0,
   14.54 -    0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0,
   14.55 -    0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0,
   14.56 -    0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   14.57 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1,
   14.58 -    0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0, 0, 0,
   14.59 -    0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 0, 40, 0, 0, 0, 242, 65, 63,
   14.60 -    192, 200, 0, 0, 0, 242, 65, 63, 128, 168, 0, 0, 0, 242, 65, 63, 64, 72, 0, 0, 0, 242, 65, 63,
   14.61 -    1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
   14.62 -};
   14.63 -
   14.64 -static const Uint8 GLES2_FragmentTegra_Alpha_SolidSrc_[] = {
   14.65 -    169, 153, 195, 28, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
   14.66 -    0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
   14.67 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
   14.68 -    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
   14.69 -    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.70 -    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
   14.71 -    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
   14.72 -    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
   14.73 -    0, 220, 0, 0, 0, 220, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
   14.74 -    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.75 -    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
   14.76 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 118, 118, 17, 241, 0, 0, 0, 240, 0,
   14.77 -    0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
   14.78 -    0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 21, 32, 0, 0, 0, 0,
   14.79 -    0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
   14.80 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
   14.81 -    1, 0, 0, 0, 3, 0, 0, 0, 3, 0, 65, 37, 8, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 21, 0,
   14.82 -    0, 0, 0, 3, 0, 1, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 39, 0, 0, 0, 0, 0, 0, 0,
   14.83 -    0, 0, 0, 0, 0, 3, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0, 9, 0, 0, 0, 24, 0, 4, 40, 232, 231, 15,
   14.84 -    0, 0, 242, 65, 62, 194, 72, 1, 0, 0, 250, 65, 63, 194, 40, 1, 0, 0, 250, 65, 63, 192, 168, 1,
   14.85 -    0, 0, 242, 1, 64, 192, 168, 1, 0, 0, 242, 1, 68, 168, 32, 0, 0, 0, 50, 64, 0, 192, 168, 15,
   14.86 -    0, 0, 242, 1, 66, 168, 64, 0, 16, 0, 242, 65, 1, 232, 231, 15, 0, 0, 242, 65, 62, 168, 160,
   14.87 -    0, 0, 0, 50, 64, 2, 104, 192, 0, 0, 36, 48, 66, 4, 232, 231, 15, 0, 0, 242, 65, 62, 3, 0, 6,
   14.88 -    40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 41, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 2, 0
   14.89 -};
   14.90 -
   14.91 -static const Uint8 GLES2_FragmentTegra_Additive_SolidSrc_[] = {
   14.92 -    59, 71, 42, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0,
   14.93 -    0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
   14.94 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
   14.95 -    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
   14.96 -    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   14.97 -    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
   14.98 -    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
   14.99 -    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
  14.100 -    0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
  14.101 -    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.102 -    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
  14.103 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 22, 22, 17, 241, 0, 0, 0, 240, 0,
  14.104 -    0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
  14.105 -    0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0,
  14.106 -    0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
  14.107 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
  14.108 -    1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0,
  14.109 -    0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 192, 200, 0, 0, 0, 26,
  14.110 -    0, 70, 192, 40, 0, 0, 0, 2, 0, 64, 192, 72, 0, 0, 0, 10, 0, 66, 192, 168, 0, 0, 0, 18, 0, 68,
  14.111 -    1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
  14.112 -};
  14.113 -
  14.114 -static const Uint8 GLES2_FragmentTegra_Modulated_SolidSrc_[] = {
  14.115 -    37, 191, 49, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0,
  14.116 -    0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
  14.117 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
  14.118 -    75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
  14.119 -    0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.120 -    22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
  14.121 -    0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
  14.122 -    0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
  14.123 -    0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
  14.124 -    0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.125 -    0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
  14.126 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 32, 32, 17, 241, 0, 0, 0, 240, 0,
  14.127 -    0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
  14.128 -    0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0,
  14.129 -    0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
  14.130 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
  14.131 -    1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0,
  14.132 -    0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242,
  14.133 -    1, 70, 8, 32, 0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68,
  14.134 -    1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
  14.135 -};
  14.136 -
  14.137 -static const Uint8 GLES2_FragmentTegra_None_TextureSrc_[] = {
  14.138 -    220, 217, 41, 211, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
  14.139 -    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
  14.140 -    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
  14.141 -    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
  14.142 -    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
  14.143 -    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
  14.144 -    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
  14.145 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
  14.146 -    0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
  14.147 -    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
  14.148 -    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
  14.149 -    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
  14.150 -    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
  14.151 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
  14.152 -    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
  14.153 -    0, 0, 1, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
  14.154 -    0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0,
  14.155 -    0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
  14.156 -    0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.157 -    0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0,
  14.158 -    0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 1, 0, 0, 0, 2, 0, 4, 38, 186, 81, 78, 16, 2, 1, 0, 0, 1, 0,
  14.159 -    1, 39, 0, 4, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242, 1, 70, 8, 32,
  14.160 -    0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68, 1, 0, 6, 40,
  14.161 -    0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
  14.162 -};
  14.163 -
  14.164 -static const Uint8 GLES2_FragmentTegra_Alpha_TextureSrc_[] = {
  14.165 -    71, 202, 114, 229, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
  14.166 -    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
  14.167 -    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
  14.168 -    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
  14.169 -    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
  14.170 -    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
  14.171 -    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
  14.172 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
  14.173 -    0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
  14.174 -    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
  14.175 -    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
  14.176 -    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
  14.177 -    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
  14.178 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
  14.179 -    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
  14.180 -    0, 0, 1, 118, 118, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0,
  14.181 -    240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0,
  14.182 -    1, 0, 0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16,
  14.183 -    0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.184 -    0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0,
  14.185 -    8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186,
  14.186 -    81, 78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0,
  14.187 -    0, 0, 16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0,
  14.188 -    0, 242, 1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 154, 192, 0, 0, 37, 34, 64, 3, 8, 32, 0, 0, 5, 58,
  14.189 -    208, 4, 40, 64, 0, 0, 5, 50, 208, 4, 72, 160, 0, 0, 37, 42, 208, 4, 2, 0, 6, 40, 0, 0, 0, 0,
  14.190 -    0, 0, 0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
  14.191 -};
  14.192 -
  14.193 -static const Uint8 GLES2_FragmentTegra_Additive_TextureSrc_[] = {
  14.194 -    161, 234, 193, 234, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
  14.195 -    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
  14.196 -    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
  14.197 -    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
  14.198 -    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
  14.199 -    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
  14.200 -    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
  14.201 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
  14.202 -    0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
  14.203 -    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
  14.204 -    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
  14.205 -    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
  14.206 -    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
  14.207 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
  14.208 -    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
  14.209 -    0, 0, 1, 22, 22, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
  14.210 -    0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0,
  14.211 -    0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
  14.212 -    0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.213 -    0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0,
  14.214 -    129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81,
  14.215 -    78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0,
  14.216 -    16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 104, 32, 1, 0, 0, 242, 1, 70, 8, 192, 1, 0, 0, 242,
  14.217 -    1, 64, 72, 64, 1, 0, 0, 242, 1, 68, 136, 192, 0, 0, 0, 26, 64, 4, 136, 32, 0, 0, 0, 2, 64, 7,
  14.218 -    136, 64, 0, 0, 0, 10, 64, 6, 136, 160, 0, 0, 0, 18, 64, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0, 0,
  14.219 -    0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
  14.220 -};
  14.221 -
  14.222 -static const Uint8 GLES2_FragmentTegra_Modulated_TextureSrc_[] = {
  14.223 -    75, 132, 201, 227, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
  14.224 -    0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
  14.225 -    82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
  14.226 -    0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
  14.227 -    13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
  14.228 -    0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
  14.229 -    0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
  14.230 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
  14.231 -    0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
  14.232 -    0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
  14.233 -    0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
  14.234 -    97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
  14.235 -    2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
  14.236 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
  14.237 -    0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
  14.238 -    0, 0, 1, 32, 32, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
  14.239 -    0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0,
  14.240 -    0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
  14.241 -    0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.242 -    0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0,
  14.243 -    129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81,
  14.244 -    78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0,
  14.245 -    16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0, 0, 242,
  14.246 -    1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 104, 192, 0, 0, 0, 242, 65, 4, 232, 32, 0, 0, 0, 242, 65,
  14.247 -    0, 40, 64, 0, 0, 0, 242, 65, 6, 72, 160, 0, 0, 0, 242, 65, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0,
  14.248 -    0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
  14.249 -};
  14.250 -
  14.251 -static const GLES2_ShaderInstance GLES2_VertexTegra_Default = {
  14.252 -    GL_VERTEX_SHADER,
  14.253 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.254 -    sizeof(GLES2_VertexTegra_Default_),
  14.255 -    GLES2_VertexTegra_Default_
  14.256 -};
  14.257 -
  14.258 -static const GLES2_ShaderInstance GLES2_FragmentTegra_None_SolidSrc = {
  14.259 -    GL_FRAGMENT_SHADER,
  14.260 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.261 -    sizeof(GLES2_FragmentTegra_None_SolidSrc_),
  14.262 -    GLES2_FragmentTegra_None_SolidSrc_
  14.263 -};
  14.264 -
  14.265 -static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_SolidSrc = {
  14.266 -    GL_FRAGMENT_SHADER,
  14.267 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.268 -    sizeof(GLES2_FragmentTegra_Alpha_SolidSrc_),
  14.269 -    GLES2_FragmentTegra_Alpha_SolidSrc_
  14.270 -};
  14.271 -
  14.272 -static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_SolidSrc = {
  14.273 -    GL_FRAGMENT_SHADER,
  14.274 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.275 -    sizeof(GLES2_FragmentTegra_Additive_SolidSrc_),
  14.276 -    GLES2_FragmentTegra_Additive_SolidSrc_
  14.277 -};
  14.278 -
  14.279 -static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_SolidSrc = {
  14.280 -    GL_FRAGMENT_SHADER,
  14.281 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.282 -    sizeof(GLES2_FragmentTegra_Modulated_SolidSrc_),
  14.283 -    GLES2_FragmentTegra_Modulated_SolidSrc_
  14.284 -};
  14.285 -
  14.286 -static const GLES2_ShaderInstance GLES2_FragmentTegra_None_TextureSrc = {
  14.287 -    GL_FRAGMENT_SHADER,
  14.288 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.289 -    sizeof(GLES2_FragmentTegra_None_TextureSrc_),
  14.290 -    GLES2_FragmentTegra_None_TextureSrc_
  14.291 -};
  14.292 -
  14.293 -static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_TextureSrc = {
  14.294 -    GL_FRAGMENT_SHADER,
  14.295 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.296 -    sizeof(GLES2_FragmentTegra_Alpha_TextureSrc_),
  14.297 -    GLES2_FragmentTegra_Alpha_TextureSrc_
  14.298 -};
  14.299 -
  14.300 -static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_TextureSrc = {
  14.301 -    GL_FRAGMENT_SHADER,
  14.302 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.303 -    sizeof(GLES2_FragmentTegra_Additive_TextureSrc_),
  14.304 -    GLES2_FragmentTegra_Additive_TextureSrc_
  14.305 -};
  14.306 -
  14.307 -static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_TextureSrc = {
  14.308 -    GL_FRAGMENT_SHADER,
  14.309 -    GL_NVIDIA_PLATFORM_BINARY_NV,
  14.310 -    sizeof(GLES2_FragmentTegra_Modulated_TextureSrc_),
  14.311 -    GLES2_FragmentTegra_Modulated_TextureSrc_
  14.312 -};
  14.313 -
  14.314 -#endif /* GLES2_INCLUDE_NVIDIA_SHADERS */
  14.315 -
  14.316 -/*************************************************************************************************
  14.317   * Vertex/fragment shader definitions                                                            *
  14.318   *************************************************************************************************/
  14.319  
  14.320  static GLES2_Shader GLES2_VertexShader_Default = {
  14.321 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.322 -    2,
  14.323 -#else
  14.324      1,
  14.325 -#endif
  14.326      {
  14.327 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.328 -        &GLES2_VertexTegra_Default,
  14.329 -#endif
  14.330          &GLES2_VertexSrc_Default
  14.331      }
  14.332  };
  14.333  
  14.334 -static GLES2_Shader GLES2_FragmentShader_None_SolidSrc = {
  14.335 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.336 -    2,
  14.337 -#else
  14.338 +static GLES2_Shader GLES2_FragmentShader_SolidSrc = {
  14.339      1,
  14.340 -#endif
  14.341      {
  14.342 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.343 -        &GLES2_FragmentTegra_None_SolidSrc,
  14.344 -#endif
  14.345          &GLES2_FragmentSrc_SolidSrc
  14.346      }
  14.347  };
  14.348  
  14.349 -static GLES2_Shader GLES2_FragmentShader_Alpha_SolidSrc = {
  14.350 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.351 -    2,
  14.352 -#else
  14.353 +static GLES2_Shader GLES2_FragmentShader_TextureABGRSrc = {
  14.354      1,
  14.355 -#endif
  14.356      {
  14.357 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.358 -        &GLES2_FragmentTegra_Alpha_SolidSrc,
  14.359 -#endif
  14.360 -        &GLES2_FragmentSrc_SolidSrc
  14.361 -    }
  14.362 -};
  14.363 -
  14.364 -static GLES2_Shader GLES2_FragmentShader_Additive_SolidSrc = {
  14.365 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.366 -    2,
  14.367 -#else
  14.368 -    1,
  14.369 -#endif
  14.370 -    {
  14.371 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.372 -        &GLES2_FragmentTegra_Additive_SolidSrc,
  14.373 -#endif
  14.374 -        &GLES2_FragmentSrc_SolidSrc
  14.375 -    }
  14.376 -};
  14.377 -
  14.378 -static GLES2_Shader GLES2_FragmentShader_Modulated_SolidSrc = {
  14.379 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.380 -    2,
  14.381 -#else
  14.382 -    1,
  14.383 -#endif
  14.384 -    {
  14.385 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.386 -        &GLES2_FragmentTegra_Modulated_SolidSrc,
  14.387 -#endif
  14.388 -        &GLES2_FragmentSrc_SolidSrc
  14.389 -    }
  14.390 -};
  14.391 -
  14.392 -static GLES2_Shader GLES2_FragmentShader_None_TextureABGRSrc = {
  14.393 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.394 -    2,
  14.395 -#else
  14.396 -    1,
  14.397 -#endif
  14.398 -    {
  14.399 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.400 -        &GLES2_FragmentTegra_None_TextureSrc,
  14.401 -#endif
  14.402          &GLES2_FragmentSrc_TextureABGRSrc
  14.403      }
  14.404  };
  14.405  
  14.406 -static GLES2_Shader GLES2_FragmentShader_Alpha_TextureABGRSrc = {
  14.407 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.408 -    2,
  14.409 -#else
  14.410 -    1,
  14.411 -#endif
  14.412 -    {
  14.413 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.414 -        &GLES2_FragmentTegra_Alpha_TextureSrc,
  14.415 -#endif
  14.416 -        &GLES2_FragmentSrc_TextureABGRSrc
  14.417 -    }
  14.418 -};
  14.419 -
  14.420 -static GLES2_Shader GLES2_FragmentShader_Additive_TextureABGRSrc = {
  14.421 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.422 -    2,
  14.423 -#else
  14.424 -    1,
  14.425 -#endif
  14.426 -    {
  14.427 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.428 -        &GLES2_FragmentTegra_Additive_TextureSrc,
  14.429 -#endif
  14.430 -        &GLES2_FragmentSrc_TextureABGRSrc
  14.431 -    }
  14.432 -};
  14.433 -
  14.434 -static GLES2_Shader GLES2_FragmentShader_Modulated_TextureABGRSrc = {
  14.435 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.436 -    2,
  14.437 -#else
  14.438 -    1,
  14.439 -#endif
  14.440 -    {
  14.441 -#if GLES2_INCLUDE_NVIDIA_SHADERS
  14.442 -        &GLES2_FragmentTegra_Modulated_TextureSrc,
  14.443 -#endif
  14.444 -        &GLES2_FragmentSrc_TextureABGRSrc
  14.445 -    }
  14.446 -};
  14.447 -
  14.448 -static GLES2_Shader GLES2_FragmentShader_None_TextureARGBSrc = {
  14.449 +static GLES2_Shader GLES2_FragmentShader_TextureARGBSrc = {
  14.450      1,
  14.451      {
  14.452          &GLES2_FragmentSrc_TextureARGBSrc
  14.453      }
  14.454  };
  14.455  
  14.456 -static GLES2_Shader GLES2_FragmentShader_Alpha_TextureARGBSrc = {
  14.457 -    1,
  14.458 -    {
  14.459 -        &GLES2_FragmentSrc_TextureARGBSrc
  14.460 -    }
  14.461 -};
  14.462 -
  14.463 -static GLES2_Shader GLES2_FragmentShader_Additive_TextureARGBSrc = {
  14.464 -    1,
  14.465 -    {
  14.466 -        &GLES2_FragmentSrc_TextureARGBSrc
  14.467 -    }
  14.468 -};
  14.469 -
  14.470 -static GLES2_Shader GLES2_FragmentShader_Modulated_TextureARGBSrc = {
  14.471 -    1,
  14.472 -    {
  14.473 -        &GLES2_FragmentSrc_TextureARGBSrc
  14.474 -    }
  14.475 -};
  14.476 -
  14.477 -static GLES2_Shader GLES2_FragmentShader_None_TextureRGBSrc = {
  14.478 +static GLES2_Shader GLES2_FragmentShader_TextureRGBSrc = {
  14.479      1,
  14.480      {
  14.481          &GLES2_FragmentSrc_TextureRGBSrc
  14.482      }
  14.483  };
  14.484  
  14.485 -static GLES2_Shader GLES2_FragmentShader_Alpha_TextureRGBSrc = {
  14.486 -    1,
  14.487 -    {
  14.488 -        &GLES2_FragmentSrc_TextureRGBSrc
  14.489 -    }
  14.490 -};
  14.491 -
  14.492 -static GLES2_Shader GLES2_FragmentShader_Additive_TextureRGBSrc = {
  14.493 -    1,
  14.494 -    {
  14.495 -        &GLES2_FragmentSrc_TextureRGBSrc
  14.496 -    }
  14.497 -};
  14.498 -
  14.499 -static GLES2_Shader GLES2_FragmentShader_Modulated_TextureRGBSrc = {
  14.500 -    1,
  14.501 -    {
  14.502 -        &GLES2_FragmentSrc_TextureRGBSrc
  14.503 -    }
  14.504 -};
  14.505 -
  14.506 -static GLES2_Shader GLES2_FragmentShader_None_TextureBGRSrc = {
  14.507 -    1,
  14.508 -    {
  14.509 -        &GLES2_FragmentSrc_TextureBGRSrc
  14.510 -    }
  14.511 -};
  14.512 -
  14.513 -static GLES2_Shader GLES2_FragmentShader_Alpha_TextureBGRSrc = {
  14.514 -    1,
  14.515 -    {
  14.516 -        &GLES2_FragmentSrc_TextureBGRSrc
  14.517 -    }
  14.518 -};
  14.519 -
  14.520 -static GLES2_Shader GLES2_FragmentShader_Additive_TextureBGRSrc = {
  14.521 -    1,
  14.522 -    {
  14.523 -        &GLES2_FragmentSrc_TextureBGRSrc
  14.524 -    }
  14.525 -};
  14.526 -
  14.527 -static GLES2_Shader GLES2_FragmentShader_Modulated_TextureBGRSrc = {
  14.528 +static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = {
  14.529      1,
  14.530      {
  14.531          &GLES2_FragmentSrc_TextureBGRSrc
  14.532 @@ -808,94 +330,27 @@
  14.533   * Shader selector                                                                               *
  14.534   *************************************************************************************************/
  14.535  
  14.536 -const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode)
  14.537 +const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type)
  14.538  {
  14.539      switch (type) {
  14.540      case GLES2_SHADER_VERTEX_DEFAULT:
  14.541          return &GLES2_VertexShader_Default;
  14.542      case GLES2_SHADER_FRAGMENT_SOLID_SRC:
  14.543 -    switch (blendMode) {
  14.544 -    case SDL_BLENDMODE_NONE:
  14.545 -        return &GLES2_FragmentShader_None_SolidSrc;
  14.546 -    case SDL_BLENDMODE_BLEND:
  14.547 -        return &GLES2_FragmentShader_Alpha_SolidSrc;
  14.548 -    case SDL_BLENDMODE_ADD:
  14.549 -        return &GLES2_FragmentShader_Additive_SolidSrc;
  14.550 -    case SDL_BLENDMODE_MOD:
  14.551 -        return &GLES2_FragmentShader_Modulated_SolidSrc;
  14.552 -    default:
  14.553 -        return NULL;
  14.554 -    }
  14.555 +        return &GLES2_FragmentShader_SolidSrc;
  14.556      case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
  14.557 -        switch (blendMode) {
  14.558 -        case SDL_BLENDMODE_NONE:
  14.559 -            return &GLES2_FragmentShader_None_TextureABGRSrc;
  14.560 -        case SDL_BLENDMODE_BLEND:
  14.561 -            return &GLES2_FragmentShader_Alpha_TextureABGRSrc;
  14.562 -        case SDL_BLENDMODE_ADD:
  14.563 -            return &GLES2_FragmentShader_Additive_TextureABGRSrc;
  14.564 -        case SDL_BLENDMODE_MOD:
  14.565 -            return &GLES2_FragmentShader_Modulated_TextureABGRSrc;
  14.566 -        default:
  14.567 -            return NULL;
  14.568 -    }
  14.569 +        return &GLES2_FragmentShader_TextureABGRSrc;
  14.570      case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
  14.571 -        switch (blendMode) {
  14.572 -        case SDL_BLENDMODE_NONE:
  14.573 -            return &GLES2_FragmentShader_None_TextureARGBSrc;
  14.574 -        case SDL_BLENDMODE_BLEND:
  14.575 -            return &GLES2_FragmentShader_Alpha_TextureARGBSrc;
  14.576 -        case SDL_BLENDMODE_ADD:
  14.577 -            return &GLES2_FragmentShader_Additive_TextureARGBSrc;
  14.578 -        case SDL_BLENDMODE_MOD:
  14.579 -            return &GLES2_FragmentShader_Modulated_TextureARGBSrc;
  14.580 -        default:
  14.581 -            return NULL;
  14.582 -    }
  14.583 -
  14.584 +        return &GLES2_FragmentShader_TextureARGBSrc;
  14.585      case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
  14.586 -        switch (blendMode) {
  14.587 -        case SDL_BLENDMODE_NONE:
  14.588 -            return &GLES2_FragmentShader_None_TextureRGBSrc;
  14.589 -        case SDL_BLENDMODE_BLEND:
  14.590 -            return &GLES2_FragmentShader_Alpha_TextureRGBSrc;
  14.591 -        case SDL_BLENDMODE_ADD:
  14.592 -            return &GLES2_FragmentShader_Additive_TextureRGBSrc;
  14.593 -        case SDL_BLENDMODE_MOD:
  14.594 -            return &GLES2_FragmentShader_Modulated_TextureRGBSrc;
  14.595 -        default:
  14.596 -            return NULL;
  14.597 -    }
  14.598 -
  14.599 +        return &GLES2_FragmentShader_TextureRGBSrc;
  14.600      case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
  14.601 -        switch (blendMode) {
  14.602 -        case SDL_BLENDMODE_NONE:
  14.603 -            return &GLES2_FragmentShader_None_TextureBGRSrc;
  14.604 -        case SDL_BLENDMODE_BLEND:
  14.605 -            return &GLES2_FragmentShader_Alpha_TextureBGRSrc;
  14.606 -        case SDL_BLENDMODE_ADD:
  14.607 -            return &GLES2_FragmentShader_Additive_TextureBGRSrc;
  14.608 -        case SDL_BLENDMODE_MOD:
  14.609 -            return &GLES2_FragmentShader_Modulated_TextureBGRSrc;
  14.610 -        default:
  14.611 -            return NULL;
  14.612 -    }
  14.613 -    
  14.614 +        return &GLES2_FragmentShader_TextureBGRSrc;
  14.615      case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC:
  14.616 -    {
  14.617          return &GLES2_FragmentShader_TextureYUVSrc;
  14.618 -    }
  14.619 -
  14.620      case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC:
  14.621 -    {
  14.622          return &GLES2_FragmentShader_TextureNV12Src;
  14.623 -    }
  14.624 -
  14.625      case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC:
  14.626 -    {
  14.627          return &GLES2_FragmentShader_TextureNV21Src;
  14.628 -    }
  14.629 -
  14.630      default:
  14.631          return NULL;
  14.632      }
    15.1 --- a/src/render/opengles2/SDL_shaders_gles2.h	Sun Aug 13 22:50:23 2017 -0700
    15.2 +++ b/src/render/opengles2/SDL_shaders_gles2.h	Mon Aug 14 05:51:44 2017 -0700
    15.3 @@ -54,7 +54,7 @@
    15.4  
    15.5  #define GLES2_SOURCE_SHADER (GLenum)-1
    15.6  
    15.7 -const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode);
    15.8 +const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type);
    15.9  
   15.10  #endif /* SDL_shaders_gles2_h_ */
   15.11  
    16.1 --- a/test/testsprite2.c	Sun Aug 13 22:50:23 2017 -0700
    16.2 +++ b/test/testsprite2.c	Mon Aug 14 05:51:44 2017 -0700
    16.3 @@ -99,7 +99,12 @@
    16.4              SDL_FreeSurface(temp);
    16.5              return (-1);
    16.6          }
    16.7 -        SDL_SetTextureBlendMode(sprites[i], blendMode);
    16.8 +        if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
    16.9 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
   16.10 +            SDL_FreeSurface(temp);
   16.11 +            SDL_DestroyTexture(sprites[i]);
   16.12 +            return (-1);
   16.13 +        }
   16.14      }
   16.15      SDL_FreeSurface(temp);
   16.16  
   16.17 @@ -295,6 +300,9 @@
   16.18                      } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
   16.19                          blendMode = SDL_BLENDMODE_MOD;
   16.20                          consumed = 2;
   16.21 +                    } else if (SDL_strcasecmp(argv[i + 1], "sub") == 0) {
   16.22 +                        blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT);
   16.23 +                        consumed = 2;
   16.24                      }
   16.25                  }
   16.26              } else if (SDL_strcasecmp(argv[i], "--iterations") == 0) {