[Mesa-dev] [PATCH 07/13] egl: Handle dri configs with floating point pixel data
Kevin Strasser
kevin.strasser at intel.com
Mon Jan 28 18:42:50 UTC 2019
In the case that __DRI_ATTRIB_FLOAT_BIT is set in the dri config, set
EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT in the egl config. Add a field to each
platform driver visual to indicate if it has components that are in floating
point form.
Signed-off-by: Kevin Strasser <kevin.strasser at intel.com>
---
src/egl/drivers/dri2/egl_dri2.c | 3 +++
src/egl/drivers/dri2/platform_drm.c | 18 ++++++++++++++++--
src/egl/drivers/dri2/platform_wayland.c | 16 +++++++++++++++-
src/gbm/backends/dri/gbm_dri.c | 12 ++++++++++++
src/gbm/backends/dri/gbm_driint.h | 1 +
5 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2906d97..d1c9f9c 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -236,6 +236,9 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
switch (attrib) {
case __DRI_ATTRIB_RENDER_TYPE:
+ if (value & __DRI_ATTRIB_FLOAT_BIT)
+ _eglSetConfigKey(&base, EGL_COLOR_COMPONENT_TYPE_EXT,
+ EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT);
if (value & __DRI_ATTRIB_RGBA_BIT)
value = EGL_RGB_BUFFER;
else if (value & __DRI_ATTRIB_LUMINANCE_BIT)
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index fc28bc6..9297729 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -97,6 +97,8 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
{
const struct gbm_dri_visual *visual = NULL;
int red, green, blue, alpha;
+ unsigned int render_type;
+ bool is_float;
int i;
/* Check that the EGLConfig being used to render to the surface is
@@ -109,6 +111,10 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_BLUE_SHIFT, &blue);
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_ALPHA_SHIFT, &alpha);
+ dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_RENDER_TYPE,
+ &render_type);
+ is_float = (render_type & __DRI_ATTRIB_FLOAT_BIT) ? true : false;
+
for (i = 0; i < dri2_dpy->gbm_dri->num_visuals; i++) {
visual = &dri2_dpy->gbm_dri->visual_table[i];
if (visual->gbm_format == surface->format)
@@ -121,7 +127,8 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
if (red != visual->rgba_shifts.red ||
green != visual->rgba_shifts.green ||
blue != visual->rgba_shifts.blue ||
- (alpha > -1 && alpha != visual->rgba_shifts.alpha)) {
+ (alpha > -1 && alpha != visual->rgba_shifts.alpha) ||
+ is_float != visual->is_float) {
return false;
}
@@ -629,19 +636,26 @@ drm_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
for (unsigned i = 0; dri2_dpy->driver_configs[i]; i++) {
const __DRIconfig *config = dri2_dpy->driver_configs[i];
int red, green, blue, alpha;
+ unsigned int render_type;
+ bool is_float;
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_RED_SHIFT, &red);
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_GREEN_SHIFT, &green);
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_BLUE_SHIFT, &blue);
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_ALPHA_SHIFT, &alpha);
+ dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
+ __DRI_ATTRIB_RENDER_TYPE, &render_type);
+ is_float = (render_type & __DRI_ATTRIB_FLOAT_BIT) ? true : false;
+
for (unsigned j = 0; j < num_visuals; j++) {
struct dri2_egl_config *dri2_conf;
if (visuals[j].rgba_shifts.red != red ||
visuals[j].rgba_shifts.green != green ||
visuals[j].rgba_shifts.blue != blue ||
- visuals[j].rgba_shifts.alpha != alpha)
+ visuals[j].rgba_shifts.alpha != alpha ||
+ visuals[j].is_float != is_float)
continue;
const EGLint attr_list[] = {
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index c185552..4b5f9b7 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -61,48 +61,56 @@ static const struct dri2_wl_visual {
int dri_image_format;
int bpp;
int rgba_shifts[4];
+ bool is_float;
} dri2_wl_visuals[] = {
{
"XRGB2101010",
WL_DRM_FORMAT_XRGB2101010, WL_SHM_FORMAT_XRGB2101010,
__DRI_IMAGE_FORMAT_XRGB2101010, 32,
{ 20, 10, 0, -1 },
+ false
},
{
"ARGB2101010",
WL_DRM_FORMAT_ARGB2101010, WL_SHM_FORMAT_ARGB2101010,
__DRI_IMAGE_FORMAT_ARGB2101010, 32,
{ 20, 10, 0, 30 },
+ false
},
{
"XBGR2101010",
WL_DRM_FORMAT_XBGR2101010, WL_SHM_FORMAT_XBGR2101010,
__DRI_IMAGE_FORMAT_XBGR2101010, 32,
{ 0, 10, 20, -1 },
+ false
},
{
"ABGR2101010",
WL_DRM_FORMAT_ABGR2101010, WL_SHM_FORMAT_ABGR2101010,
__DRI_IMAGE_FORMAT_ABGR2101010, 32,
{ 0, 10, 20, 30 },
+ false
},
{
"XRGB8888",
WL_DRM_FORMAT_XRGB8888, WL_SHM_FORMAT_XRGB8888,
__DRI_IMAGE_FORMAT_XRGB8888, 32,
{ 16, 8, 0, -1 },
+ false
},
{
"ARGB8888",
WL_DRM_FORMAT_ARGB8888, WL_SHM_FORMAT_ARGB8888,
__DRI_IMAGE_FORMAT_ARGB8888, 32,
{ 16, 8, 0, 24 },
+ false
},
{
"RGB565",
WL_DRM_FORMAT_RGB565, WL_SHM_FORMAT_RGB565,
__DRI_IMAGE_FORMAT_RGB565, 16,
{ 11, 5, 0, -1 },
+ false
},
};
@@ -111,6 +119,8 @@ dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy,
const __DRIconfig *config)
{
int red, green, blue, alpha;
+ unsigned int render_type;
+ bool is_float;
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_RED_SHIFT,
&red);
@@ -121,6 +131,9 @@ dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy,
dri2_get_rgba_shift(dri2_dpy->core, config, __DRI_ATTRIB_ALPHA_SHIFT,
&alpha);
+ dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_RENDER_TYPE,
+ &render_type);
+ is_float = (render_type & __DRI_ATTRIB_FLOAT_BIT) ? true : false;
for (unsigned int i = 0; i < ARRAY_SIZE(dri2_wl_visuals); i++) {
const struct dri2_wl_visual *wl_visual = &dri2_wl_visuals[i];
@@ -128,7 +141,8 @@ dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy,
if (red == wl_visual->rgba_shifts[0] &&
green == wl_visual->rgba_shifts[1] &&
blue == wl_visual->rgba_shifts[2] &&
- alpha == wl_visual->rgba_shifts[3]) {
+ alpha == wl_visual->rgba_shifts[3] &&
+ is_float == wl_visual->is_float) {
return i;
}
}
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 4552884..f80e4c7 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -487,50 +487,62 @@ static const struct gbm_dri_visual gbm_dri_visuals_table[] = {
{
GBM_FORMAT_R8, __DRI_IMAGE_FORMAT_R8,
{ 0, -1, -1, -1 },
+ false,
},
{
GBM_FORMAT_GR88, __DRI_IMAGE_FORMAT_GR88,
{ 0, 8, -1, -1 },
+ false,
},
{
GBM_FORMAT_ARGB1555, __DRI_IMAGE_FORMAT_ARGB1555,
{ 10, 5, 0, 11 },
+ false,
},
{
GBM_FORMAT_RGB565, __DRI_IMAGE_FORMAT_RGB565,
{ 11, 5, 0, -1 },
+ false,
},
{
GBM_FORMAT_XRGB8888, __DRI_IMAGE_FORMAT_XRGB8888,
{ 16, 8, 0, -1 },
+ false,
},
{
GBM_FORMAT_ARGB8888, __DRI_IMAGE_FORMAT_ARGB8888,
{ 16, 8, 0, 24 },
+ false,
},
{
GBM_FORMAT_XBGR8888, __DRI_IMAGE_FORMAT_XBGR8888,
{ 0, 8, 16, -1 },
+ false,
},
{
GBM_FORMAT_ABGR8888, __DRI_IMAGE_FORMAT_ABGR8888,
{ 0, 8, 16, 24 },
+ false,
},
{
GBM_FORMAT_XRGB2101010, __DRI_IMAGE_FORMAT_XRGB2101010,
{ 20, 10, 0, -1 },
+ false,
},
{
GBM_FORMAT_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010,
{ 20, 10, 0, 30 },
+ false,
},
{
GBM_FORMAT_XBGR2101010, __DRI_IMAGE_FORMAT_XBGR2101010,
{ 0, 10, 20, -1 },
+ false,
},
{
GBM_FORMAT_ABGR2101010, __DRI_IMAGE_FORMAT_ABGR2101010,
{ 0, 10, 20, 30 },
+ false,
},
};
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index 84c8a66..ce07595 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -49,6 +49,7 @@ struct gbm_dri_visual {
int blue;
int alpha;
} rgba_shifts;
+ bool is_float;
};
struct gbm_dri_device {
--
2.7.4
More information about the mesa-dev
mailing list