Commit 09b6956dcc4f5d9ca06765fd34d11639bcf96988

Cameron Cawley 2022-08-16T15:08:10

opengl: Support NV12 textures on GPUs with only 2 texture units

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index 202e17d..a3f5767 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -1919,6 +1919,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
     if (data->shaders && data->num_texture_units >= 3) {
         renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
         renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
+    }
+
+    /* We support NV12 textures using 2 textures and a shader */
+    if (data->shaders && data->num_texture_units >= 2) {
         renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12;
         renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
     }