Skip to content

EGL: EGL_BAD_CONFIG in eglSwapBuffers_renderdoc_hooked #3623

Closed
@n-morales

Description

@n-morales

Description of Bug

Output of qrenderdoc --version:

QRenderDoc v1.37 (cd94206b0fd995bfb3e5ed95c1e68d4f5d38ea7e)
Packaged for Arch - https://archlinux.org/packages/renderdoc

When running RenderDoc with a program using EGL with OpenGL I am getting the following EGL error in the callback provided to eglDebugMessageControlKHR:

error: EGL_BAD_CONFIG
command: eglGetConfigAttrib
message: "EGL_BAD_CONFIG error: In internal function: Additional INFO may be available\n".

Running this through gdb I get this abbreviated stack trace:

#18 0x00007ffff6b995bb in EGLHook::RefreshWindowParameters (this=this@entry=0x7ffff7ecbf20 <eglhook>, data=...) at /usr/src/debug/renderdoc/renderdoc/renderdoc/driver/gl/egl_hooks.cpp:131
#19 0x00007ffff6b967b3 in eglSwapBuffers_renderdoc_hooked (dpy=0x555555a4b880, surface=<optimized out>) at /usr/src/debug/renderdoc/renderdoc/renderdoc/driver/gl/egl_hooks.cpp:557

Indeed, the value of data.egl_cfg is NULL.

It looks like the following code is at fault:

GLWindowingData data;
data.egl_dpy = dpy;
data.egl_wnd = surface;
data.egl_ctx = EGL.GetCurrentContext();
eglhook.RefreshWindowParameters(data);

It does not set data.egl_cfg and leaves it at its NULL default value. I searched for other uses of RefreshWindowParameters and looks like this is the only place where the value is unset, it's set in:

// we could query this out technically but it's easier to keep a map
data.egl_cfg = eglhook.configs[ctx];

I wonder if the problem was introduced by 89befed as the swap buffers injection didn't check the samples before and didn't need context. This is pretty surprising because I'm sure this must have come up as the commit is 3 years old, unless no one is using eglDebugMessageControlKHR or checking for EGL errors after swapBuffers. I feel like maybe I'm missing something?

Steps to reproduce

Attaching a capture is not exactly useful as there is nothing in renderdoc that checks for an egl error after swapping. However with this patch:

diff --git a/renderdoc/driver/gl/egl_hooks.cpp b/renderdoc/driver/gl/egl_hooks.cpp
index ef735d878..81837db99 100644
--- a/renderdoc/driver/gl/egl_hooks.cpp
+++ b/renderdoc/driver/gl/egl_hooks.cpp
@@ -129,6 +129,8 @@ public:
 
       int multiSamples;
       EGL.GetConfigAttrib(display, config, EGL_SAMPLES, &multiSamples);
+      if (EGL.GetError() != EGL_SUCCESS)
+        std::abort();
       if(multiSamples != 1 && multiSamples != 2 && multiSamples != 4 && multiSamples != 8)
       {
         multiSamples = 1;

You can run a trivial EGL program (that calls swapbuffers) and aborts, i.e. LD_PRELOAD=build/lib/librenderdoc.so eglgears_x11

Environment

  • RenderDoc version: 1.37 (arch repos) and 1.38 (built from source)
  • Operating System: Arch Linux
  • Graphics API: OpenGL/EGL

NVIDIA GeForce RTX 2070
Driver Version: 575.57.08

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA crash, misbehaviour, or other problemUnresolvedWaiting for a fix or implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions