aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2020-02-16 11:13:43 +0100
committerMathias Fröhlich <[email protected]>2020-02-26 06:53:50 +0100
commitf280c00ba6cd3b0d3a01ae2fc3085de89ec867ec (patch)
tree4e637a5490258ed06cf3698bc5829054b86e6a5d
parentd32c458de76c9e0cc08c9ee1a7de23c3fca69298 (diff)
egl: Factor out dri2_add_pbuffer_configs_for_visuals {device,surfaceless}.
v2: dri2_add_configs_for_visuals -> dri2_add_pbuffer_configs_for_visuals Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3790> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3790>
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c41
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h3
-rw-r--r--src/egl/drivers/dri2/platform_device.c46
-rw-r--r--src/egl/drivers/dri2/platform_surfaceless.c48
4 files changed, 46 insertions, 92 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e1e8faaa798..0e065acd763 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -85,41 +85,49 @@
#define NUM_ATTRIBS 12
static const struct dri2_pbuffer_visual {
+ const char *format_name;
unsigned int dri_image_format;
int rgba_shifts[4];
unsigned int rgba_sizes[4];
} dri2_pbuffer_visuals[] = {
{
+ "ABGR16F",
__DRI_IMAGE_FORMAT_ABGR16161616F,
{ 0, 16, 32, 48 },
{ 16, 16, 16, 16 }
},
{
+ "XBGR16F",
__DRI_IMAGE_FORMAT_XBGR16161616F,
{ 0, 16, 32, -1 },
{ 16, 16, 16, 0 }
},
{
+ "A2RGB10",
__DRI_IMAGE_FORMAT_ARGB2101010,
{ 20, 10, 0, 30 },
{ 10, 10, 10, 2 }
},
{
+ "X2RGB10",
__DRI_IMAGE_FORMAT_XRGB2101010,
{ 20, 10, 0, -1 },
{ 10, 10, 10, 0 }
},
{
+ "ARGB8888",
__DRI_IMAGE_FORMAT_ARGB8888,
{ 16, 8, 0, 24 },
{ 8, 8, 8, 8 }
},
{
+ "RGB888",
__DRI_IMAGE_FORMAT_XRGB8888,
{ 16, 8, 0, -1 },
{ 8, 8, 8, 0 }
},
{
+ "RGB565",
__DRI_IMAGE_FORMAT_RGB565,
{ 11, 5, 0, -1 },
{ 5, 6, 5, 0 }
@@ -634,6 +642,39 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
return conf;
}
+EGLBoolean
+dri2_add_pbuffer_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ unsigned int format_count[ARRAY_SIZE(dri2_pbuffer_visuals)] = { 0 };
+ unsigned int config_count = 0;
+
+ for (unsigned i = 0; dri2_dpy->driver_configs[i] != NULL; i++) {
+ for (unsigned j = 0; j < ARRAY_SIZE(dri2_pbuffer_visuals); j++) {
+ struct dri2_egl_config *dri2_conf;
+
+ dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
+ config_count + 1, EGL_PBUFFER_BIT, NULL,
+ dri2_pbuffer_visuals[j].rgba_shifts, dri2_pbuffer_visuals[j].rgba_sizes);
+
+ if (dri2_conf) {
+ if (dri2_conf->base.ConfigID == config_count + 1)
+ config_count++;
+ format_count[j]++;
+ }
+ }
+ }
+
+ for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) {
+ if (!format_count[i]) {
+ _eglLog(_EGL_DEBUG, "No DRI config supports native format %s",
+ dri2_pbuffer_visuals[i].format_name);
+ }
+ }
+
+ return (config_count != 0);
+}
+
__DRIimage *
dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
{
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 96cf04d89e9..7c4a6dd642a 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -426,6 +426,9 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
EGLint surface_type, const EGLint *attr_list,
const int *rgba_shifts, const unsigned int *rgba_sizes);
+EGLBoolean
+dri2_add_pbuffer_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp);
+
_EGLImage *
dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
_EGLContext *ctx, EGLenum target,
diff --git a/src/egl/drivers/dri2/platform_device.c b/src/egl/drivers/dri2/platform_device.c
index 873236cc23e..7380a6d75c4 100644
--- a/src/egl/drivers/dri2/platform_device.c
+++ b/src/egl/drivers/dri2/platform_device.c
@@ -182,50 +182,6 @@ dri2_device_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
attrib_list);
}
-static EGLBoolean
-device_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
-{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- static const struct {
- const char *format_name;
- int rgba_shifts[4];
- unsigned int rgba_sizes[4];
- } visuals[] = {
- { "A2RGB10", { 20, 10, 0, 30 }, { 10, 10, 10, 2 } },
- { "X2RGB10", { 20, 10, 0, -1 }, { 10, 10, 10, 0 } },
- { "ARGB8888", { 16, 8, 0, 24 }, { 8, 8, 8, 8 } },
- { "RGB888", { 16, 8, 0, -1 }, { 8, 8, 8, 0 } },
- { "RGB565", { 11, 5, 0, -1 }, { 5, 6, 5, 0 } },
- };
- unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
- unsigned int config_count = 0;
-
- for (unsigned i = 0; dri2_dpy->driver_configs[i] != NULL; i++) {
- for (unsigned j = 0; j < ARRAY_SIZE(visuals); j++) {
- struct dri2_egl_config *dri2_conf;
-
- dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
- config_count + 1, EGL_PBUFFER_BIT, NULL,
- visuals[j].rgba_shifts, visuals[j].rgba_sizes);
-
- if (dri2_conf) {
- if (dri2_conf->base.ConfigID == config_count + 1)
- config_count++;
- format_count[j]++;
- }
- }
- }
-
- for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) {
- if (!format_count[i]) {
- _eglLog(_EGL_DEBUG, "No DRI config supports native format %s",
- visuals[i].format_name);
- }
- }
-
- return (config_count != 0);
-}
-
static const struct dri2_egl_display_vtbl dri2_device_display_vtbl = {
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_device_create_pbuffer_surface,
@@ -395,7 +351,7 @@ dri2_initialize_device(_EGLDriver *drv, _EGLDisplay *disp)
dri2_setup_screen(disp);
- if (!device_add_configs_for_visuals(drv, disp)) {
+ if (!dri2_add_pbuffer_configs_for_visuals(drv, disp)) {
err = "DRI2: failed to add configs";
goto cleanup;
}
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index 212b5c14343..8d37e8e9f4f 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -176,52 +176,6 @@ dri2_surfaceless_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
attrib_list);
}
-static EGLBoolean
-surfaceless_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
-{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- static const struct {
- const char *format_name;
- int rgba_shifts[4];
- unsigned int rgba_sizes[4];
- } visuals[] = {
- { "ABGR16F", { 0, 16, 32, 48 }, { 16, 16, 16, 16 } },
- { "XBGR16F", { 0, 16, 32, -1 }, { 16, 16, 16, 0 } },
- { "A2RGB10", { 20, 10, 0, 30 }, { 10, 10, 10, 2 } },
- { "X2RGB10", { 20, 10, 0, -1 }, { 10, 10, 10, 0 } },
- { "ARGB8888", { 16, 8, 0, 24 }, { 8, 8, 8, 8 } },
- { "RGB888", { 16, 8, 0, -1 }, { 8, 8, 8, 0 } },
- { "RGB565", { 11, 5, 0, -1 }, { 5, 6, 5, 0 } },
- };
- unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
- unsigned int config_count = 0;
-
- for (unsigned i = 0; dri2_dpy->driver_configs[i] != NULL; i++) {
- for (unsigned j = 0; j < ARRAY_SIZE(visuals); j++) {
- struct dri2_egl_config *dri2_conf;
-
- dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
- config_count + 1, EGL_PBUFFER_BIT, NULL,
- visuals[j].rgba_shifts, visuals[j].rgba_sizes);
-
- if (dri2_conf) {
- if (dri2_conf->base.ConfigID == config_count + 1)
- config_count++;
- format_count[j]++;
- }
- }
- }
-
- for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) {
- if (!format_count[i]) {
- _eglLog(_EGL_DEBUG, "No DRI config supports native format %s",
- visuals[i].format_name);
- }
- }
-
- return (config_count != 0);
-}
-
static const struct dri2_egl_display_vtbl dri2_surfaceless_display_vtbl = {
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_surfaceless_create_pbuffer_surface,
@@ -414,7 +368,7 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
#endif
dri2_set_WL_bind_wayland_display(drv, disp);
- if (!surfaceless_add_configs_for_visuals(drv, disp)) {
+ if (!dri2_add_pbuffer_configs_for_visuals(drv, disp)) {
err = "DRI2: failed to add configs";
goto cleanup;
}