summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2021-10-26 11:46:37 -0400
committerPovilas Kanapickas <povilas@radix.lt>2022-01-01 14:46:19 +0200
commit001feb6692b77254db6a4906a82fa1bdadfd7b85 (patch)
treeb129b032090914e0c3cfefd312e8d3eada6c392c
parent66890ca569291a53ea9cdc6ec19070173e522260 (diff)
glx/dri: Filter out fbconfigs that don't have a supported pixmap format
For depth 30 in particular it's not uncommon for the DDX to not have a configured pixmap format. Since the client expects to back both GLXPixmaps and GLXPbuffers with X Pixmaps, trying to use an x2rgb10 fbconfig would fail along various paths to CreatePixmap. Filter these fbconfigs out so the client can't ask for something that we know won't work. (cherry picked from commit f6c070a1ac05801c52ae60efb7dc4b3142653b7d)
-rw-r--r--glx/glxdricommon.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 2e00bab03..35a539629 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -115,6 +115,16 @@ render_type_is_pbuffer_only(unsigned renderType)
| __DRI_ATTRIB_FLOAT_BIT));
}
+static int
+server_has_depth(int depth)
+{
+ int i;
+ for (i = 0; i < screenInfo.numPixmapFormats; i++)
+ if (screenInfo.formats[i].depth == depth)
+ return 1;
+ return 0;
+}
+
static __GLXconfig *
createModeFromConfig(const __DRIcoreExtension * core,
const __DRIconfig * driConfig,
@@ -178,6 +188,16 @@ createModeFromConfig(const __DRIcoreExtension * core,
if (!render_type_is_pbuffer_only(renderType))
drawableType |= GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+ /* Make sure we don't advertise things the server isn't configured for */
+ if ((drawableType & (GLX_PBUFFER_BIT | GLX_PIXMAP_BIT)) &&
+ !server_has_depth(config->config.rgbBits)) {
+ drawableType &= ~(GLX_PBUFFER_BIT | GLX_PIXMAP_BIT);
+ if (!drawableType) {
+ free(config);
+ return NULL;
+ }
+ }
+
config->config.next = NULL;
config->config.visualType = visualType;
config->config.renderType = renderType;