mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 11:00:11 +01:00
egl/android: Remove hard-coded color-channel data
We don't need to write out tables of the shift/size of every colour channel, because we already have that as part of the format description if we use pipe_format. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
This commit is contained in:
parent
d8d153d4c2
commit
273e54391a
1 changed files with 21 additions and 15 deletions
|
|
@ -43,6 +43,7 @@
|
|||
#include "util/libsync.h"
|
||||
#include "util/os_file.h"
|
||||
|
||||
#include "main/glconfig.h"
|
||||
#include "egl_dri2.h"
|
||||
#include "eglglobals.h"
|
||||
#include "loader.h"
|
||||
|
|
@ -794,17 +795,16 @@ droid_add_configs_for_visuals(_EGLDisplay *disp)
|
|||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
static const struct {
|
||||
int format;
|
||||
int rgba_shifts[4];
|
||||
unsigned int rgba_sizes[4];
|
||||
int hal_format;
|
||||
enum pipe_format pipe_format;
|
||||
} visuals[] = {
|
||||
{HAL_PIXEL_FORMAT_RGBA_8888, {0, 8, 16, 24}, {8, 8, 8, 8}},
|
||||
{HAL_PIXEL_FORMAT_RGBX_8888, {0, 8, 16, -1}, {8, 8, 8, 0}},
|
||||
{HAL_PIXEL_FORMAT_RGB_565, {11, 5, 0, -1}, {5, 6, 5, 0}},
|
||||
{HAL_PIXEL_FORMAT_RGBA_8888, PIPE_FORMAT_RGBA8888_UNORM},
|
||||
{HAL_PIXEL_FORMAT_RGBX_8888, PIPE_FORMAT_RGBX8888_UNORM},
|
||||
{HAL_PIXEL_FORMAT_RGB_565, PIPE_FORMAT_R5G6B5_UNORM},
|
||||
/* This must be after HAL_PIXEL_FORMAT_RGBA_8888, we only keep BGRA
|
||||
* visual if it turns out RGBA visual is not available.
|
||||
*/
|
||||
{HAL_PIXEL_FORMAT_BGRA_8888, {16, 8, 0, 24}, {8, 8, 8, 8}},
|
||||
{HAL_PIXEL_FORMAT_BGRA_8888, PIPE_FORMAT_BGRA8888_UNORM},
|
||||
};
|
||||
|
||||
unsigned int format_count[ARRAY_SIZE(visuals)] = {0};
|
||||
|
|
@ -832,16 +832,21 @@ droid_add_configs_for_visuals(_EGLDisplay *disp)
|
|||
/* Only enable BGRA configs when RGBA is not available. BGRA configs are
|
||||
* buggy on stock Android.
|
||||
*/
|
||||
if (visuals[i].format == HAL_PIXEL_FORMAT_BGRA_8888 && has_rgba)
|
||||
if (visuals[i].hal_format == HAL_PIXEL_FORMAT_BGRA_8888 && has_rgba)
|
||||
continue;
|
||||
for (int j = 0; dri2_dpy->driver_configs[j]; j++) {
|
||||
const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
|
||||
const struct gl_config *gl_config =
|
||||
(struct gl_config *) dri2_dpy->driver_configs;
|
||||
|
||||
if (gl_config->color_format != visuals[i].pipe_format)
|
||||
continue;
|
||||
|
||||
const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
|
||||
const EGLint config_attrs[] = {
|
||||
EGL_NATIVE_VISUAL_ID,
|
||||
visuals[i].format,
|
||||
visuals[i].hal_format,
|
||||
EGL_NATIVE_VISUAL_TYPE,
|
||||
visuals[i].format,
|
||||
visuals[i].hal_format,
|
||||
EGL_FRAMEBUFFER_TARGET_ANDROID,
|
||||
EGL_TRUE,
|
||||
EGL_RECORDABLE_ANDROID,
|
||||
|
|
@ -850,19 +855,20 @@ droid_add_configs_for_visuals(_EGLDisplay *disp)
|
|||
};
|
||||
|
||||
struct dri2_egl_config *dri2_conf = dri2_add_config(
|
||||
disp, dri2_dpy->driver_configs[j], surface_type,
|
||||
config_attrs, visuals[i].rgba_shifts, visuals[i].rgba_sizes);
|
||||
disp, dri2_dpy->driver_configs[j], surface_type, config_attrs,
|
||||
NULL, NULL);
|
||||
if (dri2_conf)
|
||||
format_count[i]++;
|
||||
}
|
||||
if (visuals[i].format == HAL_PIXEL_FORMAT_RGBA_8888 && format_count[i])
|
||||
|
||||
if (visuals[i].hal_format == HAL_PIXEL_FORMAT_RGBA_8888 && format_count[i])
|
||||
has_rgba = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(format_count); i++) {
|
||||
if (!format_count[i]) {
|
||||
_eglLog(_EGL_DEBUG, "No DRI config supports native format 0x%x",
|
||||
visuals[i].format);
|
||||
visuals[i].hal_format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue