From 202739c5bea56630f35f35fc5ac91b2784f7b09f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 24 Jan 2021 13:17:11 +1100 Subject: [PATCH] [client] egl: better debug output for EGL errors --- client/renderers/EGL/CMakeLists.txt | 2 +- client/renderers/EGL/debug.c | 58 -------------------- client/renderers/EGL/egl.c | 6 +- client/renderers/EGL/egldebug.c | 45 +++++++++++++++ client/renderers/EGL/{debug.h => egldebug.h} | 14 +++-- client/renderers/EGL/texture.c | 9 +-- 6 files changed, 62 insertions(+), 72 deletions(-) delete mode 100644 client/renderers/EGL/debug.c create mode 100644 client/renderers/EGL/egldebug.c rename client/renderers/EGL/{debug.h => egldebug.h} (66%) diff --git a/client/renderers/EGL/CMakeLists.txt b/client/renderers/EGL/CMakeLists.txt index 3a3c443b..6f75911e 100644 --- a/client/renderers/EGL/CMakeLists.txt +++ b/client/renderers/EGL/CMakeLists.txt @@ -34,7 +34,7 @@ make_object( add_library(renderer_EGL STATIC egl.c dynprocs.c - debug.c + egldebug.c shader.c texture.c model.c diff --git a/client/renderers/EGL/debug.c b/client/renderers/EGL/debug.c deleted file mode 100644 index 5128fa20..00000000 --- a/client/renderers/EGL/debug.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -Looking Glass - KVM FrameRelay (KVMFR) Client -Copyright (C) 2017-2019 Geoffrey McRae -https://looking-glass.hostfission.com - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include - -void egl_debug_printf(char * format, ...) -{ - va_list args; - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); - - GLenum error = glGetError(); - switch(error) - { - case GL_NO_ERROR: - fprintf(stderr, " (GL_NO_ERROR)\n"); - break; - - case GL_INVALID_ENUM: - fprintf(stderr, " (GL_INVALID_ENUM)\n"); - break; - - case GL_INVALID_VALUE: - fprintf(stderr, " (GL_INVALID_VALUE)\n"); - break; - - case GL_INVALID_OPERATION: - fprintf(stderr, " (GL_INVALID_OPERATION)\n"); - break; - - case GL_INVALID_FRAMEBUFFER_OPERATION: - fprintf(stderr, " (GL_INVALID_FRAMEBUFFER_OPERATION)\n"); - break; - - case GL_OUT_OF_MEMORY: - fprintf(stderr, " (GL_OUT_OF_MEMORY)\n"); - break; - } -} \ No newline at end of file diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index 8aa41a9f..4fc28904 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -651,9 +651,9 @@ bool egl_render_startup(void * opaque, SDL_Window * window) * * 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 +// if (strstr(vendor, "NVIDIA") != NULL) +// DEBUG_WARN("NVIDIA driver detected, ignoring broken DMA support"); + // else this->dmaSupport = true; } } diff --git a/client/renderers/EGL/egldebug.c b/client/renderers/EGL/egldebug.c new file mode 100644 index 00000000..061f5933 --- /dev/null +++ b/client/renderers/EGL/egldebug.c @@ -0,0 +1,45 @@ +/* +Looking Glass - KVM FrameRelay (KVMFR) Client +Copyright (C) 2017-2021 Geoffrey McRae +https://looking-glass.hostfission.com + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "egldebug.h" +#include +#include + +const char * egl_getErrorStr(void) +{ + switch (eglGetError()) + { + case EGL_SUCCESS : return "EGL_SUCCESS"; + case EGL_NOT_INITIALIZED : return "EGL_NOT_INITIALIZED"; + case EGL_BAD_ACCESS : return "EGL_BAD_ACCESS"; + case EGL_BAD_ALLOC : return "EGL_BAD_ALLOC"; + case EGL_BAD_ATTRIBUTE : return "EGL_BAD_ATTRIBUTE"; + case EGL_BAD_CONTEXT : return "EGL_BAD_CONTEXT"; + case EGL_BAD_CONFIG : return "EGL_BAD_CONFIG"; + case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE"; + case EGL_BAD_DISPLAY : return "EGL_BAD_DISPLAY"; + case EGL_BAD_SURFACE : return "EGL_BAD_SURFACE"; + case EGL_BAD_MATCH : return "EGL_BAD_MATCH"; + case EGL_BAD_PARAMETER : return "EGL_BAD_PARAMETER"; + case EGL_BAD_NATIVE_PIXMAP : return "EGL_BAD_NATIVE_PIXMAP"; + case EGL_BAD_NATIVE_WINDOW : return "EGL_BAD_NATIVE_WINDOW"; + case EGL_CONTEXT_LOST : return "EGL_CONTEXT_LOST"; + default : return "UNKNOWN"; + } +} diff --git a/client/renderers/EGL/debug.h b/client/renderers/EGL/egldebug.h similarity index 66% rename from client/renderers/EGL/debug.h rename to client/renderers/EGL/egldebug.h index 47cf3106..22e8b693 100644 --- a/client/renderers/EGL/debug.h +++ b/client/renderers/EGL/egldebug.h @@ -1,6 +1,6 @@ /* Looking Glass - KVM FrameRelay (KVMFR) Client -Copyright (C) 2017-2019 Geoffrey McRae +Copyright (C) 2017-2021 Geoffrey McRae https://looking-glass.hostfission.com This program is free software; you can redistribute it and/or modify it under @@ -17,11 +17,13 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#pragma once -#include +#include "common/debug.h" -#define EGL_DEBUG_PRINT(type, fmt, ...) do {egl_debug_printf(type " %20s:%-4u | %-30s | " fmt, STRIPPATH(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__);} while (0) -#define EGL_ERROR(fmt, ...) EGL_DEBUG_PRINT("[E]", fmt, ##__VA_ARGS__) +const char * egl_getErrorStr(void); -void egl_debug_printf(char * format, ...); \ No newline at end of file +#define DEBUG_EGL_WARN(fmt, ...) \ + DEBUG_WARN(fmt " (%s)", ##__VA_ARGS__, egl_getErrorStr()) + +#define DEBUG_EGL_ERROR(fmt, ...) \ + DEBUG_ERROR(fmt " (%s)", ##__VA_ARGS__, egl_getErrorStr()) diff --git a/client/renderers/EGL/texture.c b/client/renderers/EGL/texture.c index 64ce5adb..513fa28b 100644 --- a/client/renderers/EGL/texture.c +++ b/client/renderers/EGL/texture.c @@ -20,9 +20,9 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "texture.h" #include "common/debug.h" #include "common/framebuffer.h" -#include "debug.h" #include "dynprocs.h" #include "utils.h" +#include "egldebug.h" #include #include @@ -142,7 +142,8 @@ static bool egl_texture_map(EGL_Texture * texture, uint8_t i) if (!texture->buf[i].map) { - EGL_ERROR("glMapBufferRange failed for %d of %lu bytes", i, texture->pboBufferSize); + DEBUG_EGL_ERROR("glMapBufferRange failed for %d of %lu bytes", i, + texture->pboBufferSize); return false; } @@ -387,7 +388,7 @@ bool egl_texture_update_from_dma(EGL_Texture * texture, const FrameBuffer * fram if (image == EGL_NO_IMAGE) { - DEBUG_ERROR("failed to create ELGImage for DMA transfer"); + DEBUG_EGL_ERROR("Failed to create ELGImage for DMA transfer"); return false; } @@ -481,7 +482,7 @@ enum EGL_TexStatus egl_texture_bind(EGL_Texture * texture) case GL_INVALID_VALUE: glDeleteSync(texture->buf[b].sync); texture->buf[b].sync = 0; - EGL_ERROR("glClientWaitSync failed"); + DEBUG_EGL_ERROR("glClientWaitSync failed"); return EGL_TEX_STATUS_ERROR; } }