xserver: Branch 'master' - 3 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jan 21 09:26:58 UTC 2025
glamor/glamor_egl.c | 57 ++++++++++++++++++++++++-------------------
glamor/glamor_glx_provider.c | 21 +++++++++++++--
2 files changed, 50 insertions(+), 28 deletions(-)
New commits:
commit 5397854877c1b17f21c16e43365e1c2e353dc8ba
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Thu Jan 16 10:08:15 2025 +0100
glamor: reject configs using unsupported rgbBits size
The supported color depths is a hardcoded list for now, so we
need to honor the value exposed there otherwise we'll get
inconsistencies between what glXGetFBConfigs and XListDepths
report to applications.
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1764>
diff --git a/glamor/glamor_glx_provider.c b/glamor/glamor_glx_provider.c
index 77ccc3c8b..c27141c7c 100644
--- a/glamor/glamor_glx_provider.c
+++ b/glamor/glamor_glx_provider.c
@@ -140,12 +140,14 @@ egl_create_glx_drawable(ClientPtr client, __GLXscreen *screen,
* - drawable type masks is suspicious
*/
static struct egl_config *
-translate_eglconfig(struct egl_screen *screen, EGLConfig hc,
+translate_eglconfig(ScreenPtr pScreen, struct egl_screen *screen, EGLConfig hc,
struct egl_config *chain, Bool direct_color,
Bool double_buffer, Bool duplicate_for_composite,
Bool srgb_only)
{
EGLint value;
+ bool valid_depth;
+ int i;
struct egl_config *c = calloc(1, sizeof *c);
if (!c)
@@ -218,6 +220,19 @@ translate_eglconfig(struct egl_screen *screen, EGLConfig hc,
}
#undef GET
+ /* Only expose this config if rgbBits matches a supported
+ * depth value.
+ */
+ valid_depth = false;
+ for (i = 0; i < pScreen->numDepths && !valid_depth; i++) {
+ if (pScreen->allowedDepths[i].depth == c->base.rgbBits)
+ valid_depth = true;
+ }
+ if (!valid_depth) {
+ free(c);
+ return chain;
+ }
+
/* derived state: config caveats */
eglGetConfigAttrib(screen->display, hc, EGL_CONFIG_CAVEAT, &value);
if (value == EGL_NONE)
@@ -340,13 +355,13 @@ egl_mirror_configs(ScreenPtr pScreen, struct egl_screen *screen)
for (j = 0; j < 3; j++) /* direct_color */
for (k = 0; k < 2; k++) /* double_buffer */ {
if (can_srgb)
- c = translate_eglconfig(screen, host_configs[i], c,
+ c = translate_eglconfig(pScreen, screen, host_configs[i], c,
/* direct_color */ j == 1,
/* double_buffer */ k > 0,
/* duplicate_for_composite */ j == 0,
/* srgb_only */ true);
- c = translate_eglconfig(screen, host_configs[i], c,
+ c = translate_eglconfig(pScreen, screen, host_configs[i], c,
/* direct_color */ j == 1,
/* double_buffer */ k > 0,
/* duplicate_for_composite */ j == 0,
commit 83b13387ab8b28cbdfeb44f05e019a656214d722
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Wed Jan 15 18:34:27 2025 +0100
glamor: use gbm_format_for_depth instead of open-coding it
This way glamor_back_pixmap_from_fd deals with the same depth
values as glamor_pixmap_from_fds.
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1764>
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 56ac6b532..bb5e4d658 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -561,17 +561,14 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
glamor_egl = glamor_egl_get_screen_private(scrn);
- if (bpp != 32 || !(depth == 24 || depth == 32 || depth == 30) || width == 0 || height == 0)
+ if (!gbm_format_for_depth(depth, &import_data.format) ||
+ width == 0 || height == 0)
return FALSE;
import_data.fd = fd;
import_data.width = width;
import_data.height = height;
import_data.stride = stride;
- if (depth == 30)
- import_data.format = GBM_FORMAT_ARGB2101010;
- else
- import_data.format = GBM_FORMAT_ARGB8888;
bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, &import_data, 0);
if (!bo)
return FALSE;
commit 87afcc7699f1d143ca91b6ed9bdbfafbbe0d77f7
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Wed Jan 15 18:32:46 2025 +0100
glamor: return the result of gbm_format_for_depth
This way the caller knows if the conversion failed.
While at it, check for width/height at the same time.
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1764>
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 5e0cbb035..56ac6b532 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -520,6 +520,31 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
return fd;
}
+static bool
+gbm_format_for_depth(CARD8 depth, uint32_t *format)
+{
+ switch (depth) {
+ case 15:
+ *format = GBM_FORMAT_ARGB1555;
+ return true;
+ case 16:
+ *format = GBM_FORMAT_RGB565;
+ return true;
+ case 24:
+ *format = GBM_FORMAT_XRGB8888;
+ return true;
+ case 30:
+ *format = GBM_FORMAT_ARGB2101010;
+ return true;
+ case 32:
+ *format = GBM_FORMAT_ARGB8888;
+ return true;
+ default:
+ ErrorF("unexpected depth: %d\n", depth);
+ return false;
+ }
+}
+
Bool
glamor_back_pixmap_from_fd(PixmapPtr pixmap,
int fd,
@@ -558,25 +583,6 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
return ret;
}
-static uint32_t
-gbm_format_for_depth(CARD8 depth)
-{
- switch (depth) {
- case 15:
- return GBM_FORMAT_ARGB1555;
- case 16:
- return GBM_FORMAT_RGB565;
- case 24:
- return GBM_FORMAT_XRGB8888;
- case 30:
- return GBM_FORMAT_ARGB2101010;
- default:
- ErrorF("unexpected depth: %d\n", depth);
- case 32:
- return GBM_FORMAT_ARGB8888;
- }
-}
-
PixmapPtr
glamor_pixmap_from_fds(ScreenPtr screen,
CARD8 num_fds, const int *fds,
@@ -599,6 +605,10 @@ glamor_pixmap_from_fds(ScreenPtr screen,
struct gbm_import_fd_modifier_data import_data = { 0 };
struct gbm_bo *bo;
+ if (!gbm_format_for_depth(depth, &import_data.format) ||
+ width == 0 || height == 0)
+ goto error;
+
import_data.width = width;
import_data.height = height;
import_data.num_fds = num_fds;
@@ -608,7 +618,6 @@ glamor_pixmap_from_fds(ScreenPtr screen,
import_data.strides[i] = strides[i];
import_data.offsets[i] = offsets[i];
}
- import_data.format = gbm_format_for_depth(depth);
bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD_MODIFIER, &import_data, 0);
if (bo) {
screen->ModifyPixmapHeader(pixmap, width, height, 0, 0, strides[0], NULL);
@@ -624,6 +633,7 @@ glamor_pixmap_from_fds(ScreenPtr screen,
}
}
+error:
if (ret == FALSE) {
screen->DestroyPixmap(pixmap);
return NULL;
More information about the xorg-commit
mailing list