From 3705bf6ef20a761dbbc91b381bc6c159e94bddf6 Mon Sep 17 00:00:00 2001 From: Oleh Kuznetsov Date: Thu, 19 Dec 2024 16:52:42 +0000 Subject: [PATCH] Support GL canvas without multisample support --- .../com/google/gapid/glcanvas/GlCanvas.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gapic/src/platform/linux/com/google/gapid/glcanvas/GlCanvas.java b/gapic/src/platform/linux/com/google/gapid/glcanvas/GlCanvas.java index 4e4a2f25a..26571bfe6 100644 --- a/gapic/src/platform/linux/com/google/gapid/glcanvas/GlCanvas.java +++ b/gapic/src/platform/linux/com/google/gapid/glcanvas/GlCanvas.java @@ -128,10 +128,6 @@ private static long chooseConfig(GLXCapabilities glxCaps, long display) { set(attr, GLX.GLX_GREEN_SIZE, 8); set(attr, GLX.GLX_BLUE_SIZE, 8); set(attr, GLX.GLX_DEPTH_SIZE, 24); - if (glxCaps.GLX14 || glxCaps.GLX_ARB_multisample) { - set(attr, GLX14.GLX_SAMPLE_BUFFERS, 1); - set(attr, GLX14.GLX_SAMPLES, 4); - } set(attr, X11.None, X11.None); ((Buffer)attr).flip(); // cast is there to work with JDK9. @@ -140,10 +136,23 @@ private static long chooseConfig(GLXCapabilities glxCaps, long display) { LOG.log(SEVERE, "glXChooseFBConfig returned no matching configs"); return -1; } - - long config = configs.get(0); + long selectedConfig = configs.get(0); + if (glxCaps.GLX14 || glxCaps.GLX_ARB_multisample) { + int sampleBuffers[] = new int[1]; + int samples[] = new int[1]; + for(int i = 0; i < configs.limit(); ++i) { + long config = configs.get(i); + GLX13.glXGetFBConfigAttrib(display, config, GLX14.GLX_SAMPLE_BUFFERS, sampleBuffers); + GLX13.glXGetFBConfigAttrib(display, config, GLX14.GLX_SAMPLES, samples); + if(sampleBuffers[0] > 0 && samples[0] == 4) { + // Found config with 4 samples supported + selectedConfig = config; + break; + } + } + } X11.XFree(configs); - return config; + return selectedConfig; } }