[Mesa-dev] [PATCH 1/3] mesa: add xbgr support adjacent to xrgb
Ilia Mirkin
imirkin at alum.mit.edu
Sun Feb 4 19:09:06 UTC 2018
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
One might have split this up into multiple patches, but it's just very
repetitive and similar code.
include/GL/internal/dri_interface.h | 2 ++
src/gallium/state_trackers/dri/dri2.c | 36 +++++++++++++++++++++++++++
src/gallium/state_trackers/dri/dri_drawable.c | 3 +++
src/gallium/state_trackers/dri/dri_screen.c | 17 ++++++++++++-
src/gallium/state_trackers/vdpau/device.c | 2 +-
src/loader/loader_dri3_helper.c | 4 +++
src/mesa/drivers/dri/common/utils.c | 10 ++++++++
src/mesa/main/framebuffer.c | 4 ++-
src/mesa/state_tracker/st_cb_fbo.c | 2 ++
9 files changed, 77 insertions(+), 3 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 34a5c9fb01a..dfee806885b 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1227,6 +1227,8 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FORMAT_R16 0x100d
#define __DRI_IMAGE_FORMAT_GR1616 0x100e
#define __DRI_IMAGE_FORMAT_YUYV 0x100f
+#define __DRI_IMAGE_FORMAT_XBGR2101010 0x1010
+#define __DRI_IMAGE_FORMAT_ABGR2101010 0x1011
#define __DRI_IMAGE_USE_SHARE 0x0001
#define __DRI_IMAGE_USE_SCANOUT 0x0002
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 415002d2cd0..2a3a2a805b4 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -57,6 +57,8 @@
static const int fourcc_formats[] = {
__DRI_IMAGE_FOURCC_ARGB2101010,
__DRI_IMAGE_FOURCC_XRGB2101010,
+ __DRI_IMAGE_FOURCC_ABGR2101010,
+ __DRI_IMAGE_FOURCC_XBGR2101010,
__DRI_IMAGE_FOURCC_ARGB8888,
__DRI_IMAGE_FOURCC_ABGR8888,
__DRI_IMAGE_FOURCC_SARGB8888,
@@ -115,6 +117,14 @@ static int convert_fourcc(int format, int *dri_components_p)
format = __DRI_IMAGE_FORMAT_XRGB2101010;
dri_components = __DRI_IMAGE_COMPONENTS_RGB;
break;
+ case __DRI_IMAGE_FOURCC_ABGR2101010:
+ format = __DRI_IMAGE_FORMAT_ABGR2101010;
+ dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
+ break;
+ case __DRI_IMAGE_FOURCC_XBGR2101010:
+ format = __DRI_IMAGE_FORMAT_XBGR2101010;
+ dri_components = __DRI_IMAGE_COMPONENTS_RGB;
+ break;
case __DRI_IMAGE_FOURCC_R8:
format = __DRI_IMAGE_FORMAT_R8;
dri_components = __DRI_IMAGE_COMPONENTS_R;
@@ -186,6 +196,12 @@ static int convert_to_fourcc(int format)
case __DRI_IMAGE_FORMAT_XRGB2101010:
format = __DRI_IMAGE_FOURCC_XRGB2101010;
break;
+ case __DRI_IMAGE_FORMAT_ABGR2101010:
+ format = __DRI_IMAGE_FOURCC_ABGR2101010;
+ break;
+ case __DRI_IMAGE_FORMAT_XBGR2101010:
+ format = __DRI_IMAGE_FOURCC_XBGR2101010;
+ break;
case __DRI_IMAGE_FORMAT_R8:
format = __DRI_IMAGE_FOURCC_R8;
break;
@@ -224,6 +240,12 @@ static enum pipe_format dri2_format_to_pipe_format (int format)
case __DRI_IMAGE_FORMAT_ARGB2101010:
pf = PIPE_FORMAT_B10G10R10A2_UNORM;
break;
+ case __DRI_IMAGE_FORMAT_XBGR2101010:
+ pf = PIPE_FORMAT_R10G10B10X2_UNORM;
+ break;
+ case __DRI_IMAGE_FORMAT_ABGR2101010:
+ pf = PIPE_FORMAT_R10G10B10A2_UNORM;
+ break;
case __DRI_IMAGE_FORMAT_R8:
pf = PIPE_FORMAT_R8_UNORM;
break;
@@ -288,6 +310,12 @@ static enum pipe_format fourcc_to_pipe_format(int fourcc)
case __DRI_IMAGE_FOURCC_XRGB2101010:
pf = PIPE_FORMAT_B10G10R10X2_UNORM;
break;
+ case __DRI_IMAGE_FOURCC_ABGR2101010:
+ pf = PIPE_FORMAT_R10G10B10A2_UNORM;
+ break;
+ case __DRI_IMAGE_FOURCC_XBGR2101010:
+ pf = PIPE_FORMAT_R10G10B10X2_UNORM;
+ break;
case __DRI_IMAGE_FOURCC_NV12:
pf = PIPE_FORMAT_NV12;
@@ -406,10 +434,12 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
*/
switch(format) {
case PIPE_FORMAT_B10G10R10A2_UNORM:
+ case PIPE_FORMAT_R10G10B10A2_UNORM:
case PIPE_FORMAT_BGRA8888_UNORM:
case PIPE_FORMAT_RGBA8888_UNORM:
depth = 32;
break;
+ case PIPE_FORMAT_R10G10B10X2_UNORM:
case PIPE_FORMAT_B10G10R10X2_UNORM:
depth = 30;
break;
@@ -502,6 +532,12 @@ dri_image_drawable_get_buffers(struct dri_drawable *drawable,
case PIPE_FORMAT_B10G10R10A2_UNORM:
image_format = __DRI_IMAGE_FORMAT_ARGB2101010;
break;
+ case PIPE_FORMAT_R10G10B10X2_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_XBGR2101010;
+ break;
+ case PIPE_FORMAT_R10G10B10A2_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_ABGR2101010;
+ break;
default:
image_format = __DRI_IMAGE_FORMAT_NONE;
break;
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index a5999be574a..e5a7537e473 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -263,6 +263,9 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
case PIPE_FORMAT_B10G10R10A2_UNORM:
internal_format = PIPE_FORMAT_B10G10R10X2_UNORM;
break;
+ case PIPE_FORMAT_R10G10B10A2_UNORM:
+ internal_format = PIPE_FORMAT_R10G10B10X2_UNORM;
+ break;
case PIPE_FORMAT_BGRA8888_UNORM:
internal_format = PIPE_FORMAT_BGRX8888_UNORM;
break;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index adce2ff36db..bd0925b9055 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -110,6 +110,8 @@ dri_fill_in_modes(struct dri_screen *screen)
static const mesa_format mesa_formats[] = {
MESA_FORMAT_B10G10R10A2_UNORM,
MESA_FORMAT_B10G10R10X2_UNORM,
+ MESA_FORMAT_R10G10B10A2_UNORM,
+ MESA_FORMAT_R10G10B10X2_UNORM,
MESA_FORMAT_B8G8R8A8_UNORM,
MESA_FORMAT_B8G8R8X8_UNORM,
MESA_FORMAT_B8G8R8A8_SRGB,
@@ -140,6 +142,8 @@ dri_fill_in_modes(struct dri_screen *screen)
static const enum pipe_format pipe_formats[] = {
PIPE_FORMAT_B10G10R10A2_UNORM,
PIPE_FORMAT_B10G10R10X2_UNORM,
+ PIPE_FORMAT_R10G10B10A2_UNORM,
+ PIPE_FORMAT_R10G10B10X2_UNORM,
PIPE_FORMAT_BGRA8888_UNORM,
PIPE_FORMAT_BGRX8888_UNORM,
PIPE_FORMAT_BGRA8888_SRGB,
@@ -238,7 +242,9 @@ dri_fill_in_modes(struct dri_screen *screen)
if (!allow_rgb10 &&
(mesa_formats[format] == MESA_FORMAT_B10G10R10A2_UNORM ||
- mesa_formats[format] == MESA_FORMAT_B10G10R10X2_UNORM))
+ mesa_formats[format] == MESA_FORMAT_B10G10R10X2_UNORM ||
+ mesa_formats[format] == MESA_FORMAT_R10G10B10A2_UNORM ||
+ mesa_formats[format] == MESA_FORMAT_R10G10B10X2_UNORM))
continue;
if (!p_screen->is_format_supported(p_screen, pipe_formats[format],
@@ -310,6 +316,15 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
}
break;
+ case 0x000003FF:
+ if (mode->alphaMask) {
+ assert(mode->alphaMask == 0xC0000000);
+ stvis->color_format = PIPE_FORMAT_R10G10B10A2_UNORM;
+ } else {
+ stvis->color_format = PIPE_FORMAT_R10G10B10X2_UNORM;
+ }
+ break;
+
case 0x00FF0000:
if (mode->alphaMask) {
assert(mode->alphaMask == 0xFF000000);
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index c3f156f0bb4..1bc5baa54cd 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -63,7 +63,7 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
pipe_reference_init(&dev->reference, 1);
- dev->vscreen = vl_dri3_screen_create(display, screen);
+ dev->vscreen = NULL; //vl_dri3_screen_create(display, screen);
if (!dev->vscreen)
dev->vscreen = vl_dri2_screen_create(display, screen);
if (!dev->vscreen) {
diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index fbda3d635c7..eb0404d31f4 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -993,6 +993,8 @@ dri3_cpp_for_format(uint32_t format) {
case __DRI_IMAGE_FORMAT_XBGR8888:
case __DRI_IMAGE_FORMAT_XRGB2101010:
case __DRI_IMAGE_FORMAT_ARGB2101010:
+ case __DRI_IMAGE_FORMAT_XBGR2101010:
+ case __DRI_IMAGE_FORMAT_ABGR2101010:
case __DRI_IMAGE_FORMAT_SARGB8:
return 4;
case __DRI_IMAGE_FORMAT_NONE:
@@ -1020,6 +1022,8 @@ image_format_to_fourcc(int format)
case __DRI_IMAGE_FORMAT_XBGR8888: return __DRI_IMAGE_FOURCC_XBGR8888;
case __DRI_IMAGE_FORMAT_XRGB2101010: return __DRI_IMAGE_FOURCC_XRGB2101010;
case __DRI_IMAGE_FORMAT_ARGB2101010: return __DRI_IMAGE_FOURCC_ARGB2101010;
+ case __DRI_IMAGE_FORMAT_XBGR2101010: return __DRI_IMAGE_FOURCC_XBGR2101010;
+ case __DRI_IMAGE_FORMAT_ABGR2101010: return __DRI_IMAGE_FOURCC_ABGR2101010;
}
return 0;
}
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c
index e944754a424..1cffd3ad08e 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -177,6 +177,10 @@ driCreateConfigs(mesa_format format,
{ 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 },
/* MESA_FORMAT_R8G8B8X8_UNORM */
{ 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 },
+ /* MESA_FORMAT_R10G10B10X2_UNORM */
+ { 0x000003FF, 0x000FFC00, 0x3FF00000, 0x00000000 },
+ /* MESA_FORMAT_R10G10B10A2_UNORM */
+ { 0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000 },
};
const uint32_t * masks;
@@ -215,6 +219,12 @@ driCreateConfigs(mesa_format format,
case MESA_FORMAT_B10G10R10A2_UNORM:
masks = masks_table[4];
break;
+ case MESA_FORMAT_R10G10B10X2_UNORM:
+ masks = masks_table[7];
+ break;
+ case MESA_FORMAT_R10G10B10A2_UNORM:
+ masks = masks_table[8];
+ break;
default:
fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n",
__func__, __LINE__,
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index e103f313e45..249e775f8cb 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -890,7 +890,9 @@ _mesa_get_color_read_type(struct gl_context *ctx,
return GL_UNSIGNED_SHORT_5_6_5;
if (format == MESA_FORMAT_B10G10R10A2_UNORM ||
- format == MESA_FORMAT_B10G10R10X2_UNORM)
+ format == MESA_FORMAT_B10G10R10X2_UNORM ||
+ format == MESA_FORMAT_R10G10B10A2_UNORM ||
+ format == MESA_FORMAT_R10G10B10X2_UNORM)
return GL_UNSIGNED_INT_2_10_10_10_REV;
switch (data_type) {
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 3a5c03c3354..3dec16b7f5c 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -287,8 +287,10 @@ st_new_renderbuffer_fb(enum pipe_format format, unsigned samples, boolean sw)
switch (format) {
case PIPE_FORMAT_B10G10R10A2_UNORM:
+ case PIPE_FORMAT_R10G10B10A2_UNORM:
strb->Base.InternalFormat = GL_RGB10_A2;
break;
+ case PIPE_FORMAT_R10G10B10X2_UNORM:
case PIPE_FORMAT_B10G10R10X2_UNORM:
strb->Base.InternalFormat = GL_RGB10;
break;
--
2.13.6
More information about the mesa-dev
mailing list