From 5bc85d67880a3bc8f67a9a451eca41f99a47de92 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 16 Sep 2022 06:15:45 -0700 Subject: [PATCH] Only advertise the SDL_PIXELFORMAT_EXTERNAL_OES format if we can build the shader for it --- src/render/opengles2/SDL_render_gles2.c | 6 ++++-- src/render/opengles2/SDL_shaders_gles2.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 306b518b8..76062629f 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -578,7 +578,7 @@ static int GLES2_CacheShaders(GLES2_RenderData * data) data->texcoord_precision_hint = GLES2_GetTexCoordPrecisionEnumFromHint(); - for (shader = 0; shader < GLES2_SHADER_COUNT; ++shader) { + for (shader = 0; shader < GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES; ++shader) { GLenum shader_type; if (shader == GLES2_SHADER_VERTEX_DEFAULT) { @@ -2209,7 +2209,9 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21; #endif #ifdef GL_TEXTURE_EXTERNAL_OES - renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_EXTERNAL_OES; + if (GLES2_CacheShader(data, GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES, GL_FRAGMENT_SHADER)) { + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_EXTERNAL_OES; + } #endif /* Set up parameters for rendering */ diff --git a/src/render/opengles2/SDL_shaders_gles2.h b/src/render/opengles2/SDL_shaders_gles2.h index 5a688cc5c..20cd6b07d 100644 --- a/src/render/opengles2/SDL_shaders_gles2.h +++ b/src/render/opengles2/SDL_shaders_gles2.h @@ -56,6 +56,7 @@ typedef enum GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601, GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709, #endif + /* Shaders beyond this point are optional and not cached at render creation */ GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES, GLES2_SHADER_COUNT } GLES2_ShaderType;