1
0
Эх сурвалжийг харах

Remove SDL_HAVE_YUV checks from render drivers

This doesn't actually save much code size and complicates the drivers a fair bit.

Upside is that you'll now be able to build SDL without software YUV support and still be able to play videos with hardware acceleration enabled.
Sam Lantinga 1 долоо хоног өмнө
parent
commit
21f4bc47b6

+ 8 - 10
src/render/SDL_render.c

@@ -2468,7 +2468,6 @@ bool SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect,
                          const Uint8 *Uplane, int Upitch,
                          const Uint8 *Vplane, int Vpitch)
 {
-#ifdef SDL_HAVE_YUV
     SDL_Renderer *renderer;
     SDL_Rect real_rect;
 
@@ -2513,9 +2512,12 @@ bool SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect,
         return true; // nothing to do.
     }
 
+#ifdef SDL_HAVE_YUV
     if (texture->yuv) {
         return SDL_UpdateTextureYUVPlanar(texture, &real_rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
-    } else {
+    } else
+#endif
+    {
         SDL_assert(!texture->native);
         renderer = texture->renderer;
         SDL_assert(renderer->UpdateTextureYUV);
@@ -2528,16 +2530,12 @@ bool SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect,
             return SDL_Unsupported();
         }
     }
-#else
-    return false;
-#endif
 }
 
 bool SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect,
                         const Uint8 *Yplane, int Ypitch,
                         const Uint8 *UVplane, int UVpitch)
 {
-#ifdef SDL_HAVE_YUV
     SDL_Renderer *renderer;
     SDL_Rect real_rect;
 
@@ -2574,9 +2572,12 @@ bool SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect,
         return true; // nothing to do.
     }
 
+#ifdef SDL_HAVE_YUV
     if (texture->yuv) {
         return SDL_UpdateTextureNVPlanar(texture, &real_rect, Yplane, Ypitch, UVplane, UVpitch);
-    } else {
+    } else
+#endif
+    {
         SDL_assert(!texture->native);
         renderer = texture->renderer;
         SDL_assert(renderer->UpdateTextureNV);
@@ -2589,9 +2590,6 @@ bool SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect,
             return SDL_Unsupported();
         }
     }
-#else
-    return false;
-#endif
 }
 
 #ifdef SDL_HAVE_YUV

+ 0 - 2
src/render/SDL_sysrender.h

@@ -252,7 +252,6 @@ struct SDL_Renderer
     bool (*UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
                          const SDL_Rect *rect, const void *pixels,
                          int pitch);
-#ifdef SDL_HAVE_YUV
     bool (*UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture,
                             const SDL_Rect *rect,
                             const Uint8 *Yplane, int Ypitch,
@@ -262,7 +261,6 @@ struct SDL_Renderer
                            const SDL_Rect *rect,
                            const Uint8 *Yplane, int Ypitch,
                            const Uint8 *UVplane, int UVpitch);
-#endif
     bool (*LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
                        const SDL_Rect *rect, void **pixels, int *pitch);
     void (*UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture);

+ 0 - 32
src/render/direct3d/SDL_render_d3d.c

@@ -104,7 +104,6 @@ typedef struct
     const float *shader_params;
     float palette_shader_params[4];
 
-#ifdef SDL_HAVE_YUV
     // YV12 texture support
     bool yuv;
     D3D_TextureRep utexture;
@@ -112,7 +111,6 @@ typedef struct
     Uint8 *pixels;
     int pitch;
     SDL_Rect locked_rect;
-#endif
 } D3D_TextureData;
 
 typedef struct
@@ -628,7 +626,6 @@ static bool D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     if (!D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch)) {
         return false;
     }
-#ifdef SDL_HAVE_YUV
     if (texturedata->yuv) {
         if (texture->format == SDL_PIXELFORMAT_I444) {
             // Skip to the correct offset into the next texture
@@ -656,7 +653,6 @@ static bool D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             }
         }
     }
-#endif
     return true;
 }
 
@@ -690,7 +686,6 @@ static bool D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
         texturedata->palette_shader_params[2] = texture->w;
         texturedata->palette_shader_params[3] = texture->h;
     }
-#ifdef SDL_HAVE_YUV
     if (texture->format == SDL_PIXELFORMAT_YV12 ||
         texture->format == SDL_PIXELFORMAT_IYUV) {
         texturedata->yuv = true;
@@ -726,7 +721,6 @@ static bool D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
             return SDL_SetError("Unsupported YUV colorspace");
         }
     }
-#endif
     return true;
 }
 
@@ -742,7 +736,6 @@ static bool D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (!D3D_RecreateTextureRep(data->device, &texturedata->texture)) {
         return false;
     }
-#ifdef SDL_HAVE_YUV
     if (texturedata->yuv) {
         if (!D3D_RecreateTextureRep(data->device, &texturedata->utexture)) {
             return false;
@@ -752,11 +745,9 @@ static bool D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
             return false;
         }
     }
-#endif
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                 const SDL_Rect *rect,
                                 const Uint8 *Yplane, int Ypitch,
@@ -790,7 +781,6 @@ static bool D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
     }
     return true;
 }
-#endif
 
 static bool D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                            const SDL_Rect *rect, void **pixels, int *pitch)
@@ -802,7 +792,6 @@ static bool D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     if (!texturedata) {
         return SDL_SetError("Texture is not currently available");
     }
-#ifdef SDL_HAVE_YUV
     texturedata->locked_rect = *rect;
 
     if (texturedata->yuv) {
@@ -823,7 +812,6 @@ static bool D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                      rect->x * SDL_BYTESPERPIXEL(texture->format));
         *pitch = texturedata->pitch;
     } else
-#endif
     {
         RECT d3drect;
         D3DLOCKED_RECT locked;
@@ -856,7 +844,6 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (!texturedata) {
         return;
     }
-#ifdef SDL_HAVE_YUV
     if (texturedata->yuv) {
         const SDL_Rect *rect = &texturedata->locked_rect;
         void *pixels =
@@ -864,7 +851,6 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
                      rect->x * SDL_BYTESPERPIXEL(texture->format));
         D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
     } else
-#endif
     {
         IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0);
         texturedata->texture.dirty = true;
@@ -1117,10 +1103,8 @@ static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_Sc
         } else {
             *shader = SHADER_PALETTE_NEAREST;
         }
-#ifdef SDL_HAVE_YUV
     } else if (texturedata->yuv) {
         *shader = SHADER_YUV;
-#endif // SDL_HAVE_YUV
     }
     *shader_params = texturedata->shader_params;
 
@@ -1133,7 +1117,6 @@ static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_Sc
             return false;
         }
     }
-#ifdef SDL_HAVE_YUV
     if (texturedata->yuv) {
         if (!BindTextureRep(data->device, &texturedata->utexture, 1)) {
             return false;
@@ -1142,7 +1125,6 @@ static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_Sc
             return false;
         }
     }
-#endif
     return true;
 }
 
@@ -1165,12 +1147,10 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
             ((oldtexturedata && data->drawstate.texture->palette) || data->drawstate.texture_state_dirty)) {
             IDirect3DDevice9_SetTexture(data->device, 1, NULL);
         }
-#ifdef SDL_HAVE_YUV
         if ((!newtexturedata || !newtexturedata->yuv) && ((oldtexturedata && oldtexturedata->yuv) || data->drawstate.texture_state_dirty)) {
             IDirect3DDevice9_SetTexture(data->device, 1, NULL);
             IDirect3DDevice9_SetTexture(data->device, 2, NULL);
         }
-#endif
         if (texture && !SetupTextureState(data, texture, cmd->data.draw.texture_scale_mode, &shader, &shader_params)) {
             return false;
         }
@@ -1204,12 +1184,10 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
                 D3D_PaletteData *palettedata = (D3D_PaletteData *)texture->palette->internal;
                 UpdateDirtyTexture(data->device, &palettedata->texture);
             }
-#ifdef SDL_HAVE_YUV
             if (texturedata->yuv) {
                 UpdateDirtyTexture(data->device, &texturedata->utexture);
                 UpdateDirtyTexture(data->device, &texturedata->vtexture);
             }
-#endif // SDL_HAVE_YUV
         }
     }
 
@@ -1217,7 +1195,6 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
         UpdateTextureScaleMode(data, cmd->data.draw.texture_scale_mode, 0);
         UpdateTextureAddressMode(data, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v, 0);
 
-#ifdef SDL_HAVE_YUV
         D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
         if (texturedata && texturedata->yuv) {
             UpdateTextureScaleMode(data, cmd->data.draw.texture_scale_mode, 1);
@@ -1225,7 +1202,6 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
             UpdateTextureAddressMode(data, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v, 1);
             UpdateTextureAddressMode(data, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v, 2);
         }
-#endif // SDL_HAVE_YUV
     }
 
     if (blend != data->drawstate.blend) {
@@ -1678,12 +1654,10 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
         if (texture->palette) {
             IDirect3DDevice9_SetTexture(renderdata->device, 1, NULL);
         }
-#ifdef SDL_HAVE_YUV
         if (data && data->yuv) {
             IDirect3DDevice9_SetTexture(renderdata->device, 1, NULL);
             IDirect3DDevice9_SetTexture(renderdata->device, 2, NULL);
         }
-#endif
     }
 
     if (!data) {
@@ -1691,11 +1665,9 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     }
 
     D3D_DestroyTextureRep(&data->texture);
-#ifdef SDL_HAVE_YUV
     D3D_DestroyTextureRep(&data->utexture);
     D3D_DestroyTextureRep(&data->vtexture);
     SDL_free(data->pixels);
-#endif
     SDL_free(data);
     texture->internal = NULL;
 }
@@ -1913,9 +1885,7 @@ static bool D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
     renderer->DestroyPalette = D3D_DestroyPalette;
     renderer->CreateTexture = D3D_CreateTexture;
     renderer->UpdateTexture = D3D_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = D3D_UpdateTextureYUV;
-#endif
     renderer->LockTexture = D3D_LockTexture;
     renderer->UnlockTexture = D3D_UnlockTexture;
     renderer->SetRenderTarget = D3D_SetRenderTarget;
@@ -2046,13 +2016,11 @@ static bool D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
         data->shaders[SHADER_PALETTE_LINEAR]) {
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_INDEX8);
     }
-#ifdef SDL_HAVE_YUV
     if (caps.MaxSimultaneousTextures >= 3 && data->shaders[SHADER_YUV]) {
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12);
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_IYUV);
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_I444);
     }
-#endif
 
     SDL_SetPointerProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_D3D9_DEVICE_POINTER, data->device);
 

+ 0 - 22
src/render/direct3d11/SDL_render_d3d11.c

@@ -128,7 +128,6 @@ typedef struct
     int lockedTexturePositionX;
     int lockedTexturePositionY;
     const float *YCbCr_matrix;
-#ifdef SDL_HAVE_YUV
     // YV12 texture support
     bool yuv;
     ID3D11Texture2D *mainTextureU;
@@ -143,7 +142,6 @@ typedef struct
     Uint8 *pixels;
     int pitch;
     SDL_Rect locked_rect;
-#endif
 } D3D11_TextureData;
 
 // Blend mode data
@@ -1272,7 +1270,6 @@ static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
     }
     SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER, textureData->mainTexture);
 
-#ifdef SDL_HAVE_YUV
     if (texture->format == SDL_PIXELFORMAT_YV12 ||
         texture->format == SDL_PIXELFORMAT_IYUV ||
         texture->format == SDL_PIXELFORMAT_I0FL) {
@@ -1364,7 +1361,6 @@ static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             return SDL_SetError("Unsupported YUV colorspace");
         }
     }
-#endif // SDL_HAVE_YUV
     SDL_zero(resourceViewDesc);
     resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format, renderer->output_colorspace);
     resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
@@ -1378,7 +1374,6 @@ static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
         return WIN_SetErrorFromHRESULT("ID3D11Device1::CreateShaderResourceView", result);
     }
 
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv) {
         result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
                                                        (ID3D11Resource *)textureData->mainTextureU,
@@ -1413,7 +1408,6 @@ static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             return WIN_SetErrorFromHRESULT("ID3D11Device1::CreateShaderResourceView", result);
         }
     }
-#endif // SDL_HAVE_YUV
 
     if (texture->access & SDL_TEXTUREACCESS_TARGET) {
         D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
@@ -1447,14 +1441,12 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer,
     SAFE_RELEASE(data->mainTextureResourceView);
     SAFE_RELEASE(data->mainTextureRenderTargetView);
     SAFE_RELEASE(data->stagingTexture);
-#ifdef SDL_HAVE_YUV
     SAFE_RELEASE(data->mainTextureU);
     SAFE_RELEASE(data->mainTextureResourceViewU);
     SAFE_RELEASE(data->mainTextureV);
     SAFE_RELEASE(data->mainTextureResourceViewV);
     SAFE_RELEASE(data->mainTextureResourceViewNV);
     SDL_free(data->pixels);
-#endif
     SDL_free(data);
     texture->internal = NULL;
 }
@@ -1562,7 +1554,6 @@ static bool D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Te
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
                                  const SDL_Rect *rect,
                                  const Uint8 *Yplane, int Ypitch,
@@ -1573,7 +1564,6 @@ static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const Uint8 *Yplane, int Ypitch,
                                   const Uint8 *Uplane, int Upitch,
                                   const Uint8 *Vplane, int Vpitch);
-#endif
 
 static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                                const SDL_Rect *rect, const void *srcPixels,
@@ -1586,7 +1576,6 @@ static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
         return SDL_SetError("Texture is not currently available");
     }
 
-#ifdef SDL_HAVE_YUV
     if (textureData->nv12) {
         int UVbpp = SDL_BYTESPERPIXEL(texture->format) * 2;
         int Ypitch = srcPitch;
@@ -1623,7 +1612,6 @@ static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             }
         }
     }
-#endif
 
     if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch)) {
         return false;
@@ -1631,7 +1619,6 @@ static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const SDL_Rect *rect,
                                   const Uint8 *Yplane, int Ypitch,
@@ -1779,7 +1766,6 @@ static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
 
     return true;
 }
-#endif
 
 static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                              const SDL_Rect *rect, void **pixels, int *pitch)
@@ -1793,7 +1779,6 @@ static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     if (!textureData) {
         return SDL_SetError("Texture is not currently available");
     }
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv || textureData->nv12) {
         // It's more efficient to upload directly...
         if (!textureData->pixels) {
@@ -1814,7 +1799,6 @@ static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
         *pitch = textureData->pitch;
         return true;
     }
-#endif
     if (textureData->stagingTexture) {
         return SDL_SetError("texture is already locked");
     }
@@ -1874,7 +1858,6 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (!textureData) {
         return;
     }
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv || textureData->nv12) {
         const SDL_Rect *rect = &textureData->locked_rect;
         void *pixels =
@@ -1883,7 +1866,6 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
         D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
         return;
     }
-#endif
     // Commit the pixel buffer's changes back to the staging texture:
     ID3D11DeviceContext_Unmap(rendererData->d3dContext,
                               (ID3D11Resource *)textureData->stagingTexture,
@@ -2590,14 +2572,12 @@ static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *
         ++numShaderSamplers;
     }
 
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv) {
         shaderResources[numShaderResources++] = textureData->mainTextureResourceViewU;
         shaderResources[numShaderResources++] = textureData->mainTextureResourceViewV;
     } else if (textureData->nv12) {
         shaderResources[numShaderResources++] = textureData->mainTextureResourceViewNV;
     }
-#endif // SDL_HAVE_YUV
     return D3D11_SetDrawState(renderer, cmd, &constants, numShaderResources, shaderResources, numShaderSamplers, shaderSamplers, matrix);
 }
 
@@ -3011,10 +2991,8 @@ static bool D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
     renderer->DestroyPalette = D3D11_DestroyPalette;
     renderer->CreateTexture = D3D11_CreateTexture;
     renderer->UpdateTexture = D3D11_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
     renderer->UpdateTextureNV = D3D11_UpdateTextureNV;
-#endif
     renderer->LockTexture = D3D11_LockTexture;
     renderer->UnlockTexture = D3D11_UnlockTexture;
     renderer->SetRenderTarget = D3D11_SetRenderTarget;

+ 0 - 20
src/render/direct3d12/SDL_render_d3d12.c

@@ -127,7 +127,6 @@ typedef struct
     ID3D12Resource *stagingBuffer;
     D3D12_RESOURCE_STATES stagingResourceState;
     const float *YCbCr_matrix;
-#ifdef SDL_HAVE_YUV
     // YV12 texture support
     bool yuv;
     ID3D12Resource *mainTextureU;
@@ -146,7 +145,6 @@ typedef struct
 
     Uint8 *pixels;
     int pitch;
-#endif
     SDL_Rect lockedRect;
 } D3D12_TextureData;
 
@@ -1691,7 +1689,6 @@ static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
     textureData->mainResourceState = D3D12_RESOURCE_STATE_COPY_DEST;
     SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER, textureData->mainTexture);
 
-#ifdef SDL_HAVE_YUV
     if (texture->format == SDL_PIXELFORMAT_YV12 ||
         texture->format == SDL_PIXELFORMAT_IYUV ||
         texture->format == SDL_PIXELFORMAT_I0FL) {
@@ -1805,7 +1802,6 @@ static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             return SDL_SetError("Unsupported YUV colorspace");
         }
     }
-#endif // SDL_HAVE_YUV
     SDL_zero(resourceViewDesc);
     resourceViewDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
     resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format, renderer->output_colorspace);
@@ -1821,7 +1817,6 @@ static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
              &resourceViewDesc,
              textureData->mainTextureResourceView);
 
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv) {
         D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU);
         textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer);
@@ -1858,7 +1853,6 @@ static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
                  &nvResourceViewDesc,
                  textureData->mainTextureResourceViewNV);
     }
-#endif // SDL_HAVE_YUV
 
     if (texture->access & SDL_TEXTUREACCESS_TARGET) {
         D3D12_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
@@ -1896,7 +1890,6 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
     D3D_SAFE_RELEASE(textureData->mainTexture);
     D3D_SAFE_RELEASE(textureData->stagingBuffer);
     D3D12_FreeSRVIndex(renderer, textureData->mainSRVIndex);
-#ifdef SDL_HAVE_YUV
     D3D_SAFE_RELEASE(textureData->mainTextureU);
     D3D_SAFE_RELEASE(textureData->mainTextureV);
     if (textureData->yuv) {
@@ -1907,7 +1900,6 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
         D3D12_FreeSRVIndex(renderer, textureData->mainSRVIndexNV);
     }
     SDL_free(textureData->pixels);
-#endif
     SDL_free(textureData);
     texture->internal = NULL;
 }
@@ -2064,7 +2056,6 @@ static bool D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState)) {
         return false;
     }
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv) {
         if (texture->format == SDL_PIXELFORMAT_I444 || texture->format == SDL_PIXELFORMAT_I4FL) {
             // Skip to the correct offset into the next texture
@@ -2109,7 +2100,6 @@ static bool D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             return false;
         }
     }
-#endif // SDL_HAVE_YUV
     if (textureData->mainTextureResourceView.ptr == rendererData->currentShaderResource.ptr) {
         // We'll need to rebind this resource after updating it
         rendererData->currentShaderResource.ptr = 0;
@@ -2117,7 +2107,6 @@ static bool D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const SDL_Rect *rect,
                                   const Uint8 *Yplane, int Ypitch,
@@ -2180,7 +2169,6 @@ static bool D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
     }
     return true;
 }
-#endif
 
 static bool D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                              const SDL_Rect *rect, void **pixels, int *pitch)
@@ -2199,7 +2187,6 @@ static bool D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     if (!textureData) {
         return SDL_SetError("Texture is not currently available");
     }
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv || textureData->nv12) {
         // It's more efficient to upload directly...
         if (!textureData->pixels) {
@@ -2220,7 +2207,6 @@ static bool D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
         *pitch = textureData->pitch;
         return true;
     }
-#endif
     if (textureData->stagingBuffer) {
         return SDL_SetError("texture is already locked");
     }
@@ -2322,7 +2308,6 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (!textureData) {
         return;
     }
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv || textureData->nv12) {
         const SDL_Rect *rect = &textureData->lockedRect;
         void *pixels =
@@ -2331,7 +2316,6 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
         D3D12_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
         return;
     }
-#endif
     // Commit the pixel buffer's changes back to the staging texture:
     ID3D12Resource_Unmap(textureData->stagingBuffer, 0, NULL);
 
@@ -3071,7 +3055,6 @@ static bool D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *
         shaderSamplers[numShaderSamplers++] = *textureSampler;
     }
 
-#ifdef SDL_HAVE_YUV
     if (textureData->yuv) {
         D3D12_TransitionResource(rendererData, textureData->mainTextureU, textureData->mainResourceStateU, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
         textureData->mainResourceStateU = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
@@ -3085,7 +3068,6 @@ static bool D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *
         textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
         shaderResources[numShaderResources++] = textureData->mainTextureResourceViewNV;
     }
-#endif // SDL_HAVE_YUV
     return D3D12_SetDrawState(renderer, cmd, &constants, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, numShaderResources, shaderResources, numShaderSamplers, shaderSamplers);
 }
 
@@ -3612,10 +3594,8 @@ bool D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Proper
     renderer->DestroyPalette = D3D12_DestroyPalette;
     renderer->CreateTexture = D3D12_CreateTexture;
     renderer->UpdateTexture = D3D12_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = D3D12_UpdateTextureYUV;
     renderer->UpdateTextureNV = D3D12_UpdateTextureNV;
-#endif
     renderer->LockTexture = D3D12_LockTexture;
     renderer->UnlockTexture = D3D12_UnlockTexture;
     renderer->SetRenderTarget = D3D12_SetRenderTarget;

+ 0 - 20
src/render/gpu/SDL_render_gpu.c

@@ -141,7 +141,6 @@ typedef struct GPU_TextureData
     int pitch;
     SDL_Rect locked_rect;
     const float *YCbCr_matrix;
-#ifdef SDL_HAVE_YUV
     // YV12 texture support
     bool yuv;
     bool external_texture_u;
@@ -153,7 +152,6 @@ typedef struct GPU_TextureData
     bool nv12;
     bool external_texture_nv;
     SDL_GPUTexture *textureNV;
-#endif
 } GPU_TextureData;
 
 // TODO: Sort this list based on what the GPU driver prefers?
@@ -325,7 +323,6 @@ static bool GPU_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
         size_t size, pitch;
         if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
             if (!SDL_CalculateYUVSize(texture->format, texture->w, texture->h, &size, &pitch)) {
-                SDL_free(data);
                 return false;
             }
             data->pitch = (int)pitch;
@@ -335,7 +332,6 @@ static bool GPU_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
         }
         data->pixels = SDL_calloc(1, size);
         if (!data->pixels) {
-            SDL_free(data);
             return false;
         }
 
@@ -370,7 +366,6 @@ static bool GPU_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
     SDL_PropertiesID props = SDL_GetTextureProperties(texture);
     SDL_SetPointerProperty(props, SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER, data->texture);
 
-#ifdef SDL_HAVE_YUV
     if (texture->format == SDL_PIXELFORMAT_YV12 ||
         texture->format == SDL_PIXELFORMAT_IYUV ||
         texture->format == SDL_PIXELFORMAT_I0FL) {
@@ -469,7 +464,6 @@ static bool GPU_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
             return SDL_SetError("Unsupported YUV colorspace");
         }
     }
-#endif // SDL_HAVE_YUV
     return true;
 }
 
@@ -528,7 +522,6 @@ static bool GPU_UpdateTextureInternal(GPU_RenderData *renderdata, SDL_GPUCopyPas
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool GPU_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
                                 const SDL_Rect *rect,
                                 const Uint8 *Yplane, int Ypitch,
@@ -539,7 +532,6 @@ static bool GPU_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                  const Uint8 *Yplane, int Ypitch,
                                  const Uint8 *Uplane, int Upitch,
                                  const Uint8 *Vplane, int Vpitch);
-#endif
 
 static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
 {
@@ -553,7 +545,6 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, cons
 
     retval = GPU_UpdateTextureInternal(renderdata, cpass, data->texture, bpp, rect->x, rect->y, rect->w, rect->h, pixels, pitch);
 
-#ifdef SDL_HAVE_YUV
     if (data->nv12) {
         const Uint8 *Yplane = (const Uint8 *)pixels;
         const Uint8 *UVplane = Yplane + rect->h * pitch;
@@ -591,13 +582,11 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, cons
             }
         }
     }
-#endif
 
     SDL_EndGPUCopyPass(cpass);
     return retval;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool GPU_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const SDL_Rect *rect,
                                   const Uint8 *Yplane, int Ypitch,
@@ -641,7 +630,6 @@ static bool GPU_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
     SDL_EndGPUCopyPass(cpass);
     return retval;
 }
-#endif // SDL_HAVE_YUV
 
 static bool GPU_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                             const SDL_Rect *rect, void **pixels, int *pitch)
@@ -989,12 +977,10 @@ static void CalculateAdvancedShaderConstants(SDL_Renderer *renderer, const SDL_R
         constants->tonemap_factor2 = (1.0f / output_headroom);
     }
 
-#ifdef SDL_HAVE_YUV
     GPU_TextureData *data = (GPU_TextureData *)texture->internal;
     if (data->yuv || data->nv12) {
         SDL_memcpy(constants->YCbCr_matrix, data->YCbCr_matrix, sizeof(constants->YCbCr_matrix));
     }
-#endif
 }
 
 static void Draw(
@@ -1085,7 +1071,6 @@ static void Draw(
                 sampler_bind.sampler = GetSampler(data, SDL_PIXELFORMAT_UNKNOWN, SDL_SCALEMODE_NEAREST, SDL_TEXTURE_ADDRESS_CLAMP, SDL_TEXTURE_ADDRESS_CLAMP);
                 sampler_bind.texture = palette->texture;
                 SDL_BindGPUFragmentSamplers(pass, sampler_slot++, &sampler_bind, 1);
-#ifdef SDL_HAVE_YUV
             } else if (tdata->yuv) {
                 sampler_bind.texture = tdata->textureU;
                 SDL_BindGPUFragmentSamplers(pass, sampler_slot++, &sampler_bind, 1);
@@ -1094,7 +1079,6 @@ static void Draw(
             } else if (tdata->nv12) {
                 sampler_bind.texture = tdata->textureNV;
                 SDL_BindGPUFragmentSamplers(pass, sampler_slot++, &sampler_bind, 1);
-#endif
             }
 
             // We need to fill 3 sampler slots for the advanced shader
@@ -1597,7 +1581,6 @@ static void GPU_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (!data->external_texture) {
         SDL_ReleaseGPUTexture(renderdata->device, data->texture);
     }
-#ifdef SDL_HAVE_YUV
     if (!data->external_texture_u) {
         SDL_ReleaseGPUTexture(renderdata->device, data->textureU);
     }
@@ -1607,7 +1590,6 @@ static void GPU_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (!data->external_texture_nv) {
         SDL_ReleaseGPUTexture(renderdata->device, data->textureNV);
     }
-#endif
     SDL_free(data->pixels);
     SDL_free(data);
     texture->internal = NULL;
@@ -1760,10 +1742,8 @@ static bool GPU_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
     renderer->DestroyPalette = GPU_DestroyPalette;
     renderer->CreateTexture = GPU_CreateTexture;
     renderer->UpdateTexture = GPU_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = GPU_UpdateTextureYUV;
     renderer->UpdateTextureNV = GPU_UpdateTextureNV;
-#endif
     renderer->LockTexture = GPU_LockTexture;
     renderer->UnlockTexture = GPU_UnlockTexture;
     renderer->SetRenderTarget = GPU_SetRenderTarget;

+ 1 - 22
src/render/metal/SDL_render_metal.m

@@ -166,11 +166,9 @@ typedef struct METAL_ShaderPipelines
 @property(nonatomic, retain) id<MTLTexture> mtltextureU;
 @property(nonatomic, retain) id<MTLTexture> mtltextureV;
 @property(nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction;
-#ifdef SDL_HAVE_YUV
 @property(nonatomic, assign) BOOL yuv;
 @property(nonatomic, assign) BOOL nv12;
 @property(nonatomic, assign) size_t conversionBufferOffset;
-#endif
 @property(nonatomic, assign) BOOL hasdata;
 @property(nonatomic, retain) id<MTLBuffer> lockedbuffer;
 @property(nonatomic, assign) SDL_Rect lockedrect;
@@ -807,7 +805,6 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
         texturedata.mtltexture = mtltexture;
         SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_METAL_TEXTURE_POINTER, (__bridge void *)mtltexture);
 
-#ifdef SDL_HAVE_YUV
         BOOL yuv = (texture->format == SDL_PIXELFORMAT_IYUV || texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_I444 || texture->format == SDL_PIXELFORMAT_I0FL || texture->format == SDL_PIXELFORMAT_I4FL);
         BOOL nv12 = (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21 || texture->format == SDL_PIXELFORMAT_P010);
 
@@ -877,19 +874,15 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_METAL_TEXTURE_UV_POINTER, (__bridge void *)mtltexture);
         }
 
-#endif // SDL_HAVE_YUV
         if (texture->format == SDL_PIXELFORMAT_INDEX8) {
             texturedata.fragmentFunction = SDL_METAL_FRAGMENT_PALETTE;
-#ifdef SDL_HAVE_YUV
         } else if (yuv) {
             texturedata.fragmentFunction = SDL_METAL_FRAGMENT_YUV;
         } else if (nv12) {
             texturedata.fragmentFunction = SDL_METAL_FRAGMENT_NV12;
-#endif
         } else {
             texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY;
         }
-#ifdef SDL_HAVE_YUV
         texturedata.yuv = yuv;
         texturedata.nv12 = nv12;
         if (yuv || nv12) {
@@ -899,7 +892,6 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             }
             texturedata.conversionBufferOffset = offset;
         }
-#endif
         texture->internal = (void *)CFBridgingRetain(texturedata);
 
         return true;
@@ -999,7 +991,6 @@ static bool METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
         if (!METAL_UpdateTextureInternal(renderer, texturedata.hasdata, texturedata.mtltexture, *rect, 0, pixels, pitch)) {
             return false;
         }
-#ifdef SDL_HAVE_YUV
         if (texturedata.yuv) {
             // YV12 stores V before U, so the plane order is swapped for it.
             id<MTLTexture> firstplane = texture->format == SDL_PIXELFORMAT_YV12 ? texturedata.mtltextureV : texturedata.mtltextureU;
@@ -1042,14 +1033,12 @@ static bool METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                 return false;
             }
         }
-#endif
         texturedata.hasdata = YES;
 
         return true;
     }
 }
 
-#ifdef SDL_HAVE_YUV
 static bool METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const SDL_Rect *rect,
                                   const Uint8 *Yplane, int Ypitch,
@@ -1116,7 +1105,6 @@ static bool METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
         return true;
     }
 }
-#endif
 
 static bool METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                              const SDL_Rect *rect, void **pixels, int *pitch)
@@ -1131,13 +1119,11 @@ static bool METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             return SDL_SetError("Invalid rectangle dimensions for LockTexture.");
         }
 
-#ifdef SDL_HAVE_YUV
         if (texturedata.yuv || texturedata.nv12) {
             if (!SDL_CalculateYUVSize(texture->format, rect->w, rect->h, &size, &calculated_pitch)) {
                 return false;
             }
         } else
-#endif
         {
             calculated_pitch = SDL_BYTESPERPIXEL(texture->format) * rect->w;
             size = rect->h * calculated_pitch;
@@ -1165,9 +1151,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
         id<MTLBlitCommandEncoder> blitcmd;
         SDL_Rect rect = texturedata.lockedrect;
         int pitch = SDL_BYTESPERPIXEL(texture->format) * rect.w;
-#ifdef SDL_HAVE_YUV
         SDL_Rect UVrect = { rect.x / 2, rect.y / 2, (rect.w + 1) / 2, (rect.h + 1) / 2 };
-#endif
 
         if (texturedata.lockedbuffer == nil) {
             return;
@@ -1193,7 +1177,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
                destinationSlice:0
                destinationLevel:0
               destinationOrigin:MTLOriginMake(rect.x, rect.y, 0)];
-#ifdef SDL_HAVE_YUV
+
         if (texturedata.yuv) {
             // YV12 stores V before U, so the plane order is swapped for it.
             id<MTLTexture> firstplane = texture->format == SDL_PIXELFORMAT_YV12 ? texturedata.mtltextureV : texturedata.mtltextureU;
@@ -1236,7 +1220,6 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
                    destinationLevel:0
                   destinationOrigin:MTLOriginMake(UVrect.x, UVrect.y, 0)];
         }
-#endif
         [blitcmd endEncoding];
 
         [data.mtlcmdbuffer commit];
@@ -1756,7 +1739,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, c
             SDL3METAL_PaletteData *palette = (__bridge SDL3METAL_PaletteData *)texture->palette->internal;
             [data.mtlcmdencoder setFragmentTexture:palette.mtltexture atIndex:1];
         }
-#ifdef SDL_HAVE_YUV
         if (texturedata.yuv || texturedata.nv12) {
             if (texturedata.yuv) {
                 [data.mtlcmdencoder setFragmentTexture:texturedata.mtltextureU atIndex:1];
@@ -1766,7 +1748,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, c
             }
             [data.mtlcmdencoder setFragmentBuffer:data.mtlbufconstants offset:texturedata.conversionBufferOffset atIndex:1];
         }
-#endif
         statecache->texture = texture;
     }
 
@@ -2589,10 +2570,8 @@ static bool METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
         renderer->DestroyPalette = METAL_DestroyPalette;
         renderer->CreateTexture = METAL_CreateTexture;
         renderer->UpdateTexture = METAL_UpdateTexture;
-#ifdef SDL_HAVE_YUV
         renderer->UpdateTextureYUV = METAL_UpdateTextureYUV;
         renderer->UpdateTextureNV = METAL_UpdateTextureNV;
-#endif
         renderer->LockTexture = METAL_LockTexture;
         renderer->UnlockTexture = METAL_UnlockTexture;
         renderer->SetRenderTarget = METAL_SetRenderTarget;

+ 0 - 22
src/render/opengl/SDL_render_gl.c

@@ -150,7 +150,6 @@ typedef struct
     void *pixels;
     int pitch;
     SDL_Rect locked_rect;
-#ifdef SDL_HAVE_YUV
     // YUV texture support
     bool yuv;
     bool nv12;
@@ -158,7 +157,6 @@ typedef struct
     bool utexture_external;
     GLuint vtexture;
     bool vtexture_external;
-#endif
     SDL_ScaleMode texture_scale_mode;
     SDL_TextureAddressMode texture_address_mode_u;
     SDL_TextureAddressMode texture_address_mode_v;
@@ -696,7 +694,6 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
     SetTextureScaleMode(renderdata, textype, texture->format, data->texture_scale_mode);
     SetTextureAddressMode(renderdata, textype, data->texture_address_mode_u, data->texture_address_mode_v);
 
-#ifdef SDL_HAVE_YUV
     if (texture->format == SDL_PIXELFORMAT_YV12 ||
         texture->format == SDL_PIXELFORMAT_IYUV) {
         data->yuv = true;
@@ -775,7 +772,6 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
         SetTextureAddressMode(renderdata, textype, data->texture_address_mode_u, data->texture_address_mode_v);
         SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER, data->utexture);
     }
-#endif
 
     if (texture->format == SDL_PIXELFORMAT_INDEX8) {
         data->shader = SHADER_PALETTE_NEAREST;
@@ -790,7 +786,6 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
     data->texel_size[2] = texture->w;
     data->texel_size[3] = texture->h;
 
-#ifdef SDL_HAVE_YUV
     if (data->yuv || data->nv12) {
         if (data->yuv) {
             data->shader = SHADER_YUV;
@@ -812,7 +807,6 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
             return SDL_SetError("Unsupported YUV colorspace");
         }
     }
-#endif // SDL_HAVE_YUV
 
     renderdata->glDisable(textype);
 
@@ -839,7 +833,6 @@ static bool GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w,
                                 rect->h, data->format, data->formattype,
                                 pixels);
-#ifdef SDL_HAVE_YUV
     if (data->yuv) {
         if (texture->format == SDL_PIXELFORMAT_I444) {
             // Skip to the correct offset into the next texture
@@ -890,11 +883,9 @@ static bool GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                                     (rect->w + 1) / 2, (rect->h + 1) / 2,
                                     GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels);
     }
-#endif
     return GL_CheckError("glTexSubImage2D()", renderer);
 }
 
-#ifdef SDL_HAVE_YUV
 static bool GL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                const SDL_Rect *rect,
                                const Uint8 *Yplane, int Ypitch,
@@ -971,7 +962,6 @@ static bool GL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
 
     return GL_CheckError("glTexSubImage2D()", renderer);
 }
-#endif
 
 static bool GL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                           const SDL_Rect *rect, void **pixels, int *pitch)
@@ -1304,7 +1294,6 @@ static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
     SetDrawState(data, cmd, shader, shader_params);
 
     if (texture != data->drawstate.texture) {
-#ifdef SDL_HAVE_YUV
         if (texturedata->yuv) {
             data->glActiveTextureARB(GL_TEXTURE2_ARB);
             data->glBindTexture(textype, texturedata->vtexture);
@@ -1316,7 +1305,6 @@ static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
             data->glActiveTextureARB(GL_TEXTURE1_ARB);
             data->glBindTexture(textype, texturedata->utexture);
         }
-#endif
         if (texture->palette) {
             GL_PaletteData *palette = (GL_PaletteData *)texture->palette->internal;
             data->glActiveTextureARB(GL_TEXTURE1_ARB);
@@ -1331,7 +1319,6 @@ static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
     }
 
     if (cmd->data.draw.texture_scale_mode != texturedata->texture_scale_mode) {
-#ifdef SDL_HAVE_YUV
         if (texturedata->yuv) {
             data->glActiveTextureARB(GL_TEXTURE2);
             if (!SetTextureScaleMode(data, textype, texture->format, cmd->data.draw.texture_scale_mode)) {
@@ -1352,7 +1339,6 @@ static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
 
             data->glActiveTextureARB(GL_TEXTURE0);
         }
-#endif
         if (texture->palette) {
             data->glActiveTextureARB(GL_TEXTURE1);
             if (!SetTextureScaleMode(data, textype, SDL_PIXELFORMAT_UNKNOWN, SDL_SCALEMODE_NEAREST)) {
@@ -1370,7 +1356,6 @@ static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
 
     if (cmd->data.draw.texture_address_mode_u != texturedata->texture_address_mode_u ||
         cmd->data.draw.texture_address_mode_v != texturedata->texture_address_mode_v) {
-#ifdef SDL_HAVE_YUV
         if (texturedata->yuv) {
             data->glActiveTextureARB(GL_TEXTURE2);
             SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v);
@@ -1385,7 +1370,6 @@ static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
 
             data->glActiveTextureARB(GL_TEXTURE0);
         }
-#endif
         if (texture->palette) {
             data->glActiveTextureARB(GL_TEXTURE1);
             SetTextureAddressMode(data, textype, SDL_TEXTURE_ADDRESS_CLAMP, SDL_TEXTURE_ADDRESS_CLAMP);
@@ -1746,7 +1730,6 @@ static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     if (data->texture && !data->texture_external) {
         renderdata->glDeleteTextures(1, &data->texture);
     }
-#ifdef SDL_HAVE_YUV
     if (data->yuv) {
         if (!data->utexture_external) {
             renderdata->glDeleteTextures(1, &data->utexture);
@@ -1760,7 +1743,6 @@ static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
             renderdata->glDeleteTextures(1, &data->utexture);
         }
     }
-#endif
     SDL_free(data->pixels);
     SDL_free(data);
     texture->internal = NULL;
@@ -1878,10 +1860,8 @@ static bool GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
     renderer->DestroyPalette = GL_DestroyPalette;
     renderer->CreateTexture = GL_CreateTexture;
     renderer->UpdateTexture = GL_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = GL_UpdateTextureYUV;
     renderer->UpdateTextureNV = GL_UpdateTextureNV;
-#endif
     renderer->LockTexture = GL_LockTexture;
     renderer->UnlockTexture = GL_UnlockTexture;
     renderer->SetRenderTarget = GL_SetRenderTarget;
@@ -2031,7 +2011,6 @@ static bool GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
     } else {
         SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL palette shaders not supported");
     }
-#ifdef SDL_HAVE_YUV
     // We support YV12 textures using 3 textures and a shader
     if (GL_SupportsShader(data->shaders, SHADER_YUV) &&
         data->num_texture_units >= 3) {
@@ -2053,7 +2032,6 @@ static bool GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
     } else {
         SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL NV12/NV21 not supported");
     }
-#endif
 #ifdef SDL_PLATFORM_MACOS
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_UYVY);
 #endif

+ 0 - 6
src/render/opengl/SDL_shaders_gl.c

@@ -443,7 +443,6 @@ static struct {
         "#version 130\n"
     },
 
-#ifdef SDL_HAVE_YUV
     // SHADER_YUV
     {
         // vertex shader
@@ -494,7 +493,6 @@ static struct {
         // fragment version
         NULL
     },
-#endif // SDL_HAVE_YUV
 };
 
 /* *INDENT-ON* */ // clang-format on
@@ -709,10 +707,8 @@ void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shade
         shader == SHADER_RGB_PIXELART ||
         shader == SHADER_RGBA_PIXELART) {
         shader_params_len = 4 * sizeof(float);
-#ifdef SDL_HAVE_YUV
     } else if (shader >= SHADER_YUV) {
         shader_params_len = 16 * sizeof(float);
-#endif
     }
     SDL_assert(!shader_params || shader_params_len > 0);
 
@@ -729,7 +725,6 @@ void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shade
             }
         }
 
-#ifdef SDL_HAVE_YUV
         if (shader >= SHADER_YUV) {
             // YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0
             location = ctx->glGetUniformLocationARB(program, "Yoffset");
@@ -749,7 +744,6 @@ void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shade
                 ctx->glUniform3fARB(location, shader_params[12], shader_params[13], shader_params[14]);
             }
         }
-#endif // SDL_HAVE_YUV
 
         if (!ctx->shader_params[shader]) {
             ctx->shader_params[shader] = (float *)SDL_malloc(shader_params_len);

+ 0 - 2
src/render/opengl/SDL_shaders_gl.h

@@ -38,13 +38,11 @@ typedef enum
     SHADER_RGB_PIXELART,
     SHADER_RGBA,
     SHADER_RGBA_PIXELART,
-#ifdef SDL_HAVE_YUV
     SHADER_YUV,
     SHADER_NV12_RA,
     SHADER_NV12_RG,
     SHADER_NV21_RA,
     SHADER_NV21_RG,
-#endif
     NUM_SHADERS
 } GL_Shader;
 

+ 0 - 34
src/render/opengles2/SDL_render_gles2.c

@@ -69,7 +69,6 @@ typedef struct
     GLenum pixel_type;
     void *pixel_data;
     int pitch;
-#ifdef SDL_HAVE_YUV
     // YUV texture support
     bool yuv;
     bool nv12;
@@ -77,7 +76,6 @@ typedef struct
     GLuint texture_v_external;
     GLuint texture_u;
     GLuint texture_u_external;
-#endif
     GLfloat texel_size[4];
     SDL_ScaleMode texture_scale_mode;
     SDL_TextureAddressMode texture_address_mode_u;
@@ -684,7 +682,6 @@ static bool GLES2_SelectProgram(GLES2_RenderData *data, SDL_Texture *texture, GL
             ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR;
         }
         break;
-#ifdef SDL_HAVE_YUV
     case GLES2_IMAGESOURCE_TEXTURE_YUV:
         ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV;
         shader_params = SDL_GetYCbCRtoRGBConversionMatrix(colorspace, 0, 0, 8);
@@ -720,7 +717,6 @@ static bool GLES2_SelectProgram(GLES2_RenderData *data, SDL_Texture *texture, GL
         }
         shader_params_len = 16 * sizeof(float);
         break;
-#endif // SDL_HAVE_YUV
     case GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES:
         ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES;
         break;
@@ -770,7 +766,6 @@ static bool GLES2_SelectProgram(GLES2_RenderData *data, SDL_Texture *texture, GL
     if (shader_params &&
         (!program->shader_params ||
          SDL_memcmp(shader_params, program->shader_params, shader_params_len) != 0)) {
-#ifdef SDL_HAVE_YUV
         if (ftype >= GLES2_SHADER_FRAGMENT_TEXTURE_YUV) {
             // YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0
             if (program->uniform_locations[GLES2_UNIFORM_OFFSET] != -1) {
@@ -792,7 +787,6 @@ static bool GLES2_SelectProgram(GLES2_RenderData *data, SDL_Texture *texture, GL
             }
         }
         else
-#endif
         {
             data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_TEXEL_SIZE], shader_params[0], shader_params[1], shader_params[2], shader_params[3]);
         }
@@ -1242,7 +1236,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
                     break;
                 }
                 break;
-#ifdef SDL_HAVE_YUV
             case SDL_PIXELFORMAT_IYUV:
             case SDL_PIXELFORMAT_YV12:
             case SDL_PIXELFORMAT_I444:
@@ -1254,7 +1247,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
             case SDL_PIXELFORMAT_NV21:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21;
                 break;
-#endif
             case SDL_PIXELFORMAT_EXTERNAL_OES:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES;
                 break;
@@ -1281,7 +1273,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
         case SDL_PIXELFORMAT_RGBX32:
             sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
             break;
-#ifdef SDL_HAVE_YUV
         case SDL_PIXELFORMAT_IYUV:
         case SDL_PIXELFORMAT_YV12:
         case SDL_PIXELFORMAT_I444:
@@ -1293,7 +1284,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
         case SDL_PIXELFORMAT_NV21:
             sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21;
             break;
-#endif
         case SDL_PIXELFORMAT_EXTERNAL_OES:
             sourceType = GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES;
             break;
@@ -1305,7 +1295,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
     ret = SetDrawState(data, cmd, sourceType, vertices);
 
     if (texture != data->drawstate.texture) {
-#ifdef SDL_HAVE_YUV
         if (tdata->yuv) {
             data->glActiveTexture(GL_TEXTURE2);
             data->glBindTexture(tdata->texture_type, tdata->texture_v);
@@ -1320,7 +1309,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
 
             data->glActiveTexture(GL_TEXTURE0);
         }
-#endif
         if (texture->palette) {
             GLES2_PaletteData *palette = (GLES2_PaletteData *)texture->palette->internal;
             data->glActiveTexture(GL_TEXTURE1);
@@ -1334,7 +1322,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
     }
 
     if (cmd->data.draw.texture_scale_mode != tdata->texture_scale_mode) {
-#ifdef SDL_HAVE_YUV
         if (tdata->yuv) {
             data->glActiveTexture(GL_TEXTURE2);
             if (!SetTextureScaleMode(data, tdata->texture_type, texture->format, cmd->data.draw.texture_scale_mode)) {
@@ -1355,7 +1342,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
 
             data->glActiveTexture(GL_TEXTURE0);
         }
-#endif
         if (texture->palette) {
             data->glActiveTexture(GL_TEXTURE1);
             if (!SetTextureScaleMode(data, tdata->texture_type, SDL_PIXELFORMAT_UNKNOWN, SDL_SCALEMODE_NEAREST)) {
@@ -1373,7 +1359,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
 
     if (cmd->data.draw.texture_address_mode_u != tdata->texture_address_mode_u ||
         cmd->data.draw.texture_address_mode_v != tdata->texture_address_mode_v) {
-#ifdef SDL_HAVE_YUV
         if (tdata->yuv) {
             data->glActiveTexture(GL_TEXTURE2);
             SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v);
@@ -1388,7 +1373,6 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, v
 
             data->glActiveTexture(GL_TEXTURE0);
         }
-#endif
         if (texture->palette) {
             data->glActiveTexture(GL_TEXTURE1);
             SetTextureAddressMode(data, tdata->texture_type, SDL_TEXTURE_ADDRESS_CLAMP, SDL_TEXTURE_ADDRESS_CLAMP);
@@ -1744,13 +1728,11 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
         type = GL_UNSIGNED_BYTE;
         break;
     case SDL_PIXELFORMAT_INDEX8:
-#ifdef SDL_HAVE_YUV
     case SDL_PIXELFORMAT_IYUV:
     case SDL_PIXELFORMAT_YV12:
     case SDL_PIXELFORMAT_I444:
     case SDL_PIXELFORMAT_NV12:
     case SDL_PIXELFORMAT_NV21:
-#endif
         format = GL_LUMINANCE;
         type = GL_UNSIGNED_BYTE;
         break;
@@ -1785,10 +1767,8 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
 #endif
     data->pixel_format = format;
     data->pixel_type = type;
-#ifdef SDL_HAVE_YUV
     data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12) || (texture->format == SDL_PIXELFORMAT_I444));
     data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
-#endif
     data->texture_scale_mode = texture->scaleMode;
     data->texture_address_mode_u = SDL_TEXTURE_ADDRESS_CLAMP;
     data->texture_address_mode_v = SDL_TEXTURE_ADDRESS_CLAMP;
@@ -1798,7 +1778,6 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
         size_t size;
         data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
         size = (size_t)texture->h * data->pitch;
-#ifdef SDL_HAVE_YUV
         if (data->yuv) {
             // Need to add size for the U and V planes
             if (texture->format == SDL_PIXELFORMAT_I444) {
@@ -1810,7 +1789,6 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             // Need to add size for the U/V plane
             size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
         }
-#endif
         data->pixel_data = SDL_calloc(1, size);
         if (!data->pixel_data) {
             SDL_free(data);
@@ -1826,7 +1804,6 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
     data->texel_size[2] = texture->w;
     data->texel_size[3] = texture->h;
 
-#ifdef SDL_HAVE_YUV
     if (data->yuv) {
         int yuv_texture_w, yuv_texture_h;
         if (texture->format == SDL_PIXELFORMAT_I444) {
@@ -1918,7 +1895,6 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
             return SDL_SetError("Unsupported YUV colorspace");
         }
     }
-#endif
 
     data->texture = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER, 0);
     if (data->texture) {
@@ -2029,7 +2005,6 @@ static bool GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, co
                         tdata->pixel_type,
                         pixels, pitch, SDL_BYTESPERPIXEL(texture->format));
 
-#ifdef SDL_HAVE_YUV
     if (tdata->yuv) {
         if (texture->format == SDL_PIXELFORMAT_I444) {
             // Skip to the correct offset into the next texture
@@ -2097,12 +2072,10 @@ static bool GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, co
                             GL_UNSIGNED_BYTE,
                             pixels, 2 * ((pitch + 1) / 2), 2);
     }
-#endif
 
     return GL_CheckError("glTexSubImage2D()", renderer);
 }
 
-#ifdef SDL_HAVE_YUV
 static bool GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const SDL_Rect *rect,
                                   const Uint8 *Yplane, int Ypitch,
@@ -2211,7 +2184,6 @@ static bool GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
 
     return GL_CheckError("glTexSubImage2D()", renderer);
 }
-#endif
 
 static bool GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
                              void **pixels, int *pitch)
@@ -2271,14 +2243,12 @@ static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
         if (tdata->texture && !tdata->texture_external) {
             data->glDeleteTextures(1, &tdata->texture);
         }
-#ifdef SDL_HAVE_YUV
         if (tdata->texture_v && !tdata->texture_v_external) {
             data->glDeleteTextures(1, &tdata->texture_v);
         }
         if (tdata->texture_u && !tdata->texture_u_external) {
             data->glDeleteTextures(1, &tdata->texture_u);
         }
-#endif
         SDL_free(tdata->pixel_data);
         SDL_free(tdata);
         texture->internal = NULL;
@@ -2403,10 +2373,8 @@ static bool GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
     renderer->DestroyPalette = GLES2_DestroyPalette;
     renderer->CreateTexture = GLES2_CreateTexture;
     renderer->UpdateTexture = GLES2_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV;
     renderer->UpdateTextureNV = GLES2_UpdateTextureNV;
-#endif
     renderer->LockTexture = GLES2_LockTexture;
     renderer->UnlockTexture = GLES2_UnlockTexture;
     renderer->SetRenderTarget = GLES2_SetRenderTarget;
@@ -2465,13 +2433,11 @@ static bool GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_BGRX32);
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBX32);
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_INDEX8);
-#ifdef SDL_HAVE_YUV
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12);
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_IYUV);
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_I444);
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV12);
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV21);
-#endif
 #ifdef GL_TEXTURE_EXTERNAL_OES
     if (SDL_GL_ExtensionSupported("GL_OES_EGL_image_external")) {
         data->GL_OES_EGL_image_external_supported = true;

+ 0 - 4
src/render/opengles2/SDL_shaders_gles2.c

@@ -341,7 +341,6 @@ static const char GLES2_Fragment_TextureABGR_PixelArt[] =
 "}\n"
 ;
 
-#ifdef SDL_HAVE_YUV
 
 #define YUV_SHADER_PROLOGUE                                     \
 "uniform sampler2D u_texture;\n"                                \
@@ -474,7 +473,6 @@ static const char GLES2_Fragment_TextureNV21_RG[] =
     YUV_SHADER_PROLOGUE
     NV21_RG_SHADER_BODY
 ;
-#endif
 
 // Custom Android video format texture
 static const char GLES2_Fragment_TextureExternalOES_Prologue[] =
@@ -578,7 +576,6 @@ const char *GLES2_GetShader(GLES2_ShaderType type)
         return GLES2_Fragment_TextureABGR;
     case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_PIXELART:
         return GLES2_Fragment_TextureABGR_PixelArt;
-#ifdef SDL_HAVE_YUV
     case GLES2_SHADER_FRAGMENT_TEXTURE_YUV:
         return GLES2_Fragment_TextureYUV;
     case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_RA:
@@ -589,7 +586,6 @@ const char *GLES2_GetShader(GLES2_ShaderType type)
         return GLES2_Fragment_TextureNV21_RA;
     case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RG:
         return GLES2_Fragment_TextureNV21_RG;
-#endif
     case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES:
         return GLES2_Fragment_TextureExternalOES;
     default:

+ 0 - 2
src/render/opengles2/SDL_shaders_gles2.h

@@ -53,13 +53,11 @@ typedef enum
     GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_PIXELART,
     GLES2_SHADER_FRAGMENT_TEXTURE_ABGR,
     GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_PIXELART,
-#ifdef SDL_HAVE_YUV
     GLES2_SHADER_FRAGMENT_TEXTURE_YUV,
     GLES2_SHADER_FRAGMENT_TEXTURE_NV12_RA,
     GLES2_SHADER_FRAGMENT_TEXTURE_NV12_RG,
     GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RA,
     GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RG,
-#endif
     // Shaders beyond this point are optional and not cached at render creation
     GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES,
     GLES2_SHADER_COUNT

+ 0 - 10
src/render/vitagxm/SDL_render_vita_gxm.c

@@ -208,10 +208,8 @@ static bool VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window,
     renderer->SupportsBlendMode = VITA_GXM_SupportsBlendMode;
     renderer->CreateTexture = VITA_GXM_CreateTexture;
     renderer->UpdateTexture = VITA_GXM_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = VITA_GXM_UpdateTextureYUV;
     renderer->UpdateTextureNV = VITA_GXM_UpdateTextureNV;
-#endif
     renderer->LockTexture = VITA_GXM_LockTexture;
     renderer->UnlockTexture = VITA_GXM_UnlockTexture;
     renderer->SetRenderTarget = VITA_GXM_SetRenderTarget;
@@ -299,10 +297,8 @@ static bool VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
 
     texture->internal = vita_texture;
 
-#ifdef SDL_HAVE_YUV
     vita_texture->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12));
     vita_texture->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
-#endif
 
     return true;
 }
@@ -340,11 +336,9 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     Uint8 *dst;
     int row, length, dpitch;
 
-#ifdef SDL_HAVE_YUV
     if (vita_texture->yuv || vita_texture->nv12) {
         VITA_GXM_SetYUVProfile(renderer, texture);
     }
-#endif
 
     VITA_GXM_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch);
     length = rect->w * SDL_BYTESPERPIXEL(texture->format);
@@ -359,7 +353,6 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
         }
     }
 
-#ifdef SDL_HAVE_YUV
     if (vita_texture->yuv) {
         Uint8 *Udst;
         Uint8 *Vdst;
@@ -421,13 +414,11 @@ static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             }
         }
     }
-#endif
 
     data->drawstate.texture = NULL;
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                      const SDL_Rect *rect,
                                      const Uint8 *Yplane, int Ypitch,
@@ -561,7 +552,6 @@ static bool VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *textur
     return true;
 }
 
-#endif
 
 static bool VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                                 const SDL_Rect *rect, void **pixels, int *pitch)

+ 0 - 14
src/render/vulkan/SDL_render_vulkan.c

@@ -2661,7 +2661,6 @@ static bool VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, S
     }
     texture->internal = textureData;
 
-#ifdef SDL_HAVE_YUV
     // YUV textures must have even width and height.  Also create Ycbcr conversion
     if (texture->format == SDL_PIXELFORMAT_YV12 ||
         texture->format == SDL_PIXELFORMAT_IYUV ||
@@ -2789,7 +2788,6 @@ static bool VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, S
             return false;
         }
     }
-#endif
     textureData->width = width;
     textureData->height = height;
 
@@ -2841,7 +2839,6 @@ static void VULKAN_DestroyTexture(SDL_Renderer *renderer,
 
     VULKAN_DestroyImage(rendererData, &textureData->mainImage);
 
-#ifdef SDL_HAVE_YUV
     if (textureData->samplerYcbcrConversion != VK_NULL_HANDLE) {
         vkDestroySamplerYcbcrConversionKHR(rendererData->device, textureData->samplerYcbcrConversion, NULL);
         textureData->samplerYcbcrConversion = VK_NULL_HANDLE;
@@ -2858,7 +2855,6 @@ static void VULKAN_DestroyTexture(SDL_Renderer *renderer,
         vkDestroyDescriptorSetLayout(rendererData->device, textureData->descriptorSetLayoutYcbcr, NULL);
         textureData->descriptorSetLayoutYcbcr = VK_NULL_HANDLE;
     }
-#endif
 
     VULKAN_DestroyBuffer(rendererData, &textureData->stagingBuffer);
     if (textureData->mainFramebuffer != VK_NULL_HANDLE) {
@@ -2967,7 +2963,6 @@ static bool VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, VkImag
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool VULKAN_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
                                    const SDL_Rect *rect,
                                    const Uint8 *Yplane, int Ypitch,
@@ -2978,7 +2973,6 @@ static bool VULKAN_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture
                                     const Uint8 *Yplane, int Ypitch,
                                     const Uint8 *Uplane, int Upitch,
                                     const Uint8 *Vplane, int Vpitch);
-#endif
 
 static bool VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                                const SDL_Rect *rect, const void *srcPixels,
@@ -2991,7 +2985,6 @@ static bool VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
         return SDL_SetError("Texture is not currently available");
     }
 
-#ifdef SDL_HAVE_YUV
     Uint32 numPlanes = VULKAN_VkFormatGetNumPlanes(textureData->mainImage.format);
     if (numPlanes == 2) {
         // NV12/NV21 data
@@ -3025,14 +3018,12 @@ static bool VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             }
         }
     }
-#endif
     if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainImage.imageLayout)) {
         return false;
     }
     return true;
 }
 
-#ifdef SDL_HAVE_YUV
 static bool VULKAN_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
                                   const SDL_Rect *rect,
                                   const Uint8 *Yplane, int Ypitch,
@@ -3095,7 +3086,6 @@ static bool VULKAN_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
     }
     return true;
 }
-#endif
 
 static bool VULKAN_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
                              const SDL_Rect *rect, void **pixels, int *pitch)
@@ -4652,10 +4642,8 @@ static bool VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SD
     renderer->DestroyPalette = VULKAN_DestroyPalette;
     renderer->CreateTexture = VULKAN_CreateTexture;
     renderer->UpdateTexture = VULKAN_UpdateTexture;
-#ifdef SDL_HAVE_YUV
     renderer->UpdateTextureYUV = VULKAN_UpdateTextureYUV;
     renderer->UpdateTextureNV = VULKAN_UpdateTextureNV;
-#endif
     renderer->LockTexture = VULKAN_LockTexture;
     renderer->UnlockTexture = VULKAN_UnlockTexture;
     renderer->SetRenderTarget = VULKAN_SetRenderTarget;
@@ -4720,7 +4708,6 @@ static bool VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SD
 
     SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_INDEX8);
 
-#ifdef SDL_HAVE_YUV
     if (rendererData->supportsKHRSamplerYCbCrConversion) {
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12);
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_IYUV);
@@ -4731,7 +4718,6 @@ static bool VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SD
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_I0FL);
         SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_I4FL);
     }
-#endif
 
     return true;
 }

+ 3 - 7
src/video/SDL_yuv.c

@@ -26,7 +26,6 @@
 #include "yuv2rgb/yuv_rgb.h"
 
 
-#ifdef SDL_HAVE_YUV
 static bool IsPlanar1x1Format(SDL_PixelFormat format)
 {
     return format == SDL_PIXELFORMAT_I444 || format == SDL_PIXELFORMAT_I4FL;
@@ -46,7 +45,6 @@ static bool IsPacked4Format(Uint32 format)
 {
     return format == SDL_PIXELFORMAT_YUY2 || format == SDL_PIXELFORMAT_UYVY || format == SDL_PIXELFORMAT_YVYU;
 }
-#endif
 
 /*
  * Calculate YUV size and pitch. Check for overflow.
@@ -54,7 +52,6 @@ static bool IsPacked4Format(Uint32 format)
  */
 bool SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, size_t *pitch)
 {
-#ifdef SDL_HAVE_YUV
     int sz_plane = 0, sz_plane_chroma = 0, sz_plane_packed = 0;
 
     if (IsPlanar1x1Format(format)) {
@@ -100,7 +97,7 @@ bool SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, si
             }
             sz_plane_chroma = (int)s3;
         }
-    } else {
+    } else if (IsPacked4Format(format)) {
         /* sz_plane_packed == ((w + 1) / 2) * h; */
         size_t s1, s2;
         if (!SDL_size_add_check_overflow(w, 1, &s1)) {
@@ -111,6 +108,8 @@ bool SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, si
             return SDL_SetError("width * height would overflow");
         }
         sz_plane_packed = (int) s2;
+    } else {
+        return SDL_Unsupported();
     }
 
     switch (format) {
@@ -189,9 +188,6 @@ bool SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, si
     }
 
     return true;
-#else
-    return SDL_Unsupported();
-#endif
 }
 
 #ifdef SDL_HAVE_YUV