[Mesa-dev] [RFC 2/6] dri: Set bit for float configs
Kevin Strasser
kevin.strasser at intel.com
Fri Jan 4 21:56:28 UTC 2019
Populate __DRI_ATTRIB_FLOAT_BIT, such that we can filter for formats
containing floating point pixel data and egl/glx can satisfy the
requirements for their respective extensions.
Signed-off-by: Kevin Strasser <kevin.strasser at intel.com>
---
src/egl/drivers/dri2/egl_dri2.c | 2 ++
src/egl/drivers/dri2/platform_drm.c | 18 +++++++++++++++---
src/gbm/backends/dri/gbm_dri.c | 12 ++++++++++++
src/gbm/backends/dri/gbm_driint.h | 1 +
src/mesa/drivers/dri/common/utils.c | 5 +++++
5 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d19950d..fb8f1b7 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -202,6 +202,8 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
&value); ++i) {
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 47563d6..ae235e9 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -98,6 +98,7 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
const struct gbm_dri_visual *visual = NULL;
unsigned long long int red, green, blue, alpha;
unsigned int mask_hi = 0, mask_lo, render_type;
+ bool is_float;
int i;
/* Check that the EGLConfig being used to render to the surface is
@@ -129,6 +130,10 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
&mask_lo);
alpha = (unsigned long long int)mask_hi << 32 | mask_lo;
+ 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)
@@ -141,7 +146,8 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
if (red != visual->rgba_masks.red ||
green != visual->rgba_masks.green ||
blue != visual->rgba_masks.blue ||
- (alpha && visual->rgba_masks.alpha && alpha != visual->rgba_masks.alpha)) {
+ (alpha && visual->rgba_masks.alpha && alpha != visual->rgba_masks.alpha) ||
+ is_float != visual->is_float) {
return false;
}
@@ -649,7 +655,8 @@ 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];
unsigned long long int red, green, blue, alpha;
- unsigned int mask_hi = 0, mask_lo;
+ unsigned int mask_hi = 0, mask_lo, render_type;
+ bool is_float;
dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_RED_MASK_HI,
&mask_hi);
@@ -675,13 +682,18 @@ drm_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
&mask_lo);
alpha = (unsigned long long int)mask_hi << 32 | mask_lo;
+ 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_masks.red != red ||
visuals[j].rgba_masks.green != green ||
visuals[j].rgba_masks.blue != blue ||
- visuals[j].rgba_masks.alpha != alpha)
+ visuals[j].rgba_masks.alpha != alpha ||
+ visuals[j].is_float != is_float)
continue;
const EGLint attr_list[] = {
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index abbb0b9..225b0de 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,
{ 0x000000ff, 0x00000000, 0x00000000, 0x00000000 },
+ false,
},
{
GBM_FORMAT_GR88, __DRI_IMAGE_FORMAT_GR88,
{ 0x000000ff, 0x0000ff00, 0x00000000, 0x00000000 },
+ false,
},
{
GBM_FORMAT_ARGB1555, __DRI_IMAGE_FORMAT_ARGB1555,
{ 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 },
+ false,
},
{
GBM_FORMAT_RGB565, __DRI_IMAGE_FORMAT_RGB565,
{ 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 },
+ false,
},
{
GBM_FORMAT_XRGB8888, __DRI_IMAGE_FORMAT_XRGB8888,
{ 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 },
+ false,
},
{
GBM_FORMAT_ARGB8888, __DRI_IMAGE_FORMAT_ARGB8888,
{ 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 },
+ false,
},
{
GBM_FORMAT_XBGR8888, __DRI_IMAGE_FORMAT_XBGR8888,
{ 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 },
+ false,
},
{
GBM_FORMAT_ABGR8888, __DRI_IMAGE_FORMAT_ABGR8888,
{ 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 },
+ false,
},
{
GBM_FORMAT_XRGB2101010, __DRI_IMAGE_FORMAT_XRGB2101010,
{ 0x3ff00000, 0x000ffc00, 0x000003ff, 0x00000000 },
+ false,
},
{
GBM_FORMAT_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010,
{ 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 },
+ false,
},
{
GBM_FORMAT_XBGR2101010, __DRI_IMAGE_FORMAT_XBGR2101010,
{ 0x000003ff, 0x000ffc00, 0x3ff00000, 0x00000000 },
+ false,
},
{
GBM_FORMAT_ABGR2101010, __DRI_IMAGE_FORMAT_ABGR2101010,
{ 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 },
+ false,
},
};
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index 0640198..acf53bd 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 {
uint64_t blue;
uint64_t alpha;
} rgba_masks;
+ bool is_float;
};
struct gbm_dri_device {
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c
index c7e5b84..b52c59f 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -213,6 +213,7 @@ driCreateConfigs(mesa_format format,
int blue_bits;
int alpha_bits;
bool is_srgb;
+ bool is_float;
switch (format) {
case MESA_FORMAT_B5G6R5_UNORM:
@@ -257,6 +258,7 @@ driCreateConfigs(mesa_format format,
blue_bits = _mesa_get_format_bits(format, GL_BLUE_BITS);
alpha_bits = _mesa_get_format_bits(format, GL_ALPHA_BITS);
is_srgb = _mesa_get_format_color_encoding(format) == GL_SRGB;
+ is_float = _mesa_get_format_datatype(format) == GL_FLOAT;
num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * num_msaa_modes;
configs = calloc(num_modes + 1, sizeof *configs);
@@ -286,6 +288,7 @@ driCreateConfigs(mesa_format format,
c++;
memset(modes, 0, sizeof *modes);
+ modes->floatMode = is_float;
modes->redBits = red_bits;
modes->greenBits = green_bits;
modes->blueBits = blue_bits;
@@ -455,6 +458,8 @@ driGetConfigAttribIndex(const __DRIconfig *config,
case __DRI_ATTRIB_RENDER_TYPE:
/* no support for color index mode */
*value = __DRI_ATTRIB_RGBA_BIT;
+ if (config->modes.floatMode)
+ *value |= __DRI_ATTRIB_FLOAT_BIT;
break;
case __DRI_ATTRIB_CONFIG_CAVEAT:
if (config->modes.visualRating == GLX_NON_CONFORMANT_CONFIG)
--
2.7.4
More information about the mesa-dev
mailing list