From 9941a4bb8360a9bad97a7cf6bacc3c818022e99f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 24 Jan 2021 12:05:18 +1100 Subject: [PATCH] [client] egl: runtime detect support for `glEGLImageTargetTexture2DOES` --- client/renderers/EGL/CMakeLists.txt | 1 + client/renderers/EGL/egl.c | 36 ++++++++++++++++++----------- client/renderers/EGL/texture.c | 3 ++- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/client/renderers/EGL/CMakeLists.txt b/client/renderers/EGL/CMakeLists.txt index bc32619a..3a3c443b 100644 --- a/client/renderers/EGL/CMakeLists.txt +++ b/client/renderers/EGL/CMakeLists.txt @@ -33,6 +33,7 @@ make_object( add_library(renderer_EGL STATIC egl.c + dynprocs.c debug.c shader.c texture.c diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index 543acfc3..d5d30549 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -37,6 +37,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include "app.h" +#include "dynprocs.h" #include "model.h" #include "shader.h" #include "desktop.h" @@ -629,6 +630,8 @@ bool egl_render_startup(void * opaque, SDL_Window * window) const char *client_exts = eglQueryString(this->display, EGL_EXTENSIONS); const char *vendor = (const char *)glGetString(GL_VENDOR); + egl_DynProcsInit(); + DEBUG_INFO("EGL : %d.%d", maj, min); DEBUG_INFO("Vendor : %s", vendor); DEBUG_INFO("Renderer : %s", glGetString(GL_RENDERER)); @@ -636,20 +639,27 @@ bool egl_render_startup(void * opaque, SDL_Window * window) DEBUG_INFO("EGL APIs : %s", eglQueryString(this->display, EGL_CLIENT_APIS)); DEBUG_INFO("Extensions: %s", client_exts); - if (strstr(client_exts, "EGL_EXT_image_dma_buf_import") != NULL) + if (g_dynprocs.glEGLImageTargetTexture2DOES) { - /* - * As of version 455.45.01 NVidia started advertising support for this - * feature, however even on the latest version 460.27.04 this is still - * broken and does not work, until this is fixed and we have way to detect - * this early just disable dma for all NVIDIA devices. - * - * ref: https://forums.developer.nvidia.com/t/egl-ext-image-dma-buf-import-broken-egl-bad-alloc-with-tons-of-free-ram/165552 - */ - if (strstr(vendor, "NVIDIA") != NULL) - DEBUG_WARN("NVIDIA driver detected, ignoring broken DMA support"); - else - this->dmaSupport = true; + if (strstr(client_exts, "EGL_EXT_image_dma_buf_import") != NULL) + { + /* + * As of version 455.45.01 NVidia started advertising support for this + * feature, however even on the latest version 460.27.04 this is still + * broken and does not work, until this is fixed and we have way to detect + * this early just disable dma for all NVIDIA devices. + * + * ref: https://forums.developer.nvidia.com/t/egl-ext-image-dma-buf-import-broken-egl-bad-alloc-with-tons-of-free-ram/165552 + */ + if (strstr(vendor, "NVIDIA") != NULL) + DEBUG_WARN("NVIDIA driver detected, ignoring broken DMA support"); + else + this->dmaSupport = true; + } + } + else + { + DEBUG_INFO("glEGLImageTargetTexture2DOES unavilable, DMA support disabled"); } eglSwapInterval(this->display, this->opt.vsync ? 1 : 0); diff --git a/client/renderers/EGL/texture.c b/client/renderers/EGL/texture.c index 17df4cdd..64ce5adb 100644 --- a/client/renderers/EGL/texture.c +++ b/client/renderers/EGL/texture.c @@ -21,6 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "common/debug.h" #include "common/framebuffer.h" #include "debug.h" +#include "dynprocs.h" #include "utils.h" #include @@ -392,7 +393,7 @@ bool egl_texture_update_from_dma(EGL_Texture * texture, const FrameBuffer * fram /* bind the texture and initiate the transfer */ glBindTexture(GL_TEXTURE_2D, texture->tex); - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + g_dynprocs.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); /* wait for completion */ framebuffer_wait(frame, texture->height * texture->stride);