glamor: Add 30bit RGB color format support

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>

[ Michel Dänzer: Adapt to glamor changes since 1.19 ]

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Hawking Zhang 2018-01-25 18:03:57 +01:00 committed by Adam Jackson
parent fc8b7d05e7
commit 9a416a478c
4 changed files with 16 additions and 3 deletions

View File

@ -376,14 +376,17 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
glamor_egl = glamor_egl_get_screen_private(scrn); glamor_egl = glamor_egl_get_screen_private(scrn);
if (bpp != 32 || !(depth == 24 || depth == 32) || width == 0 || height == 0) if (bpp != 32 || !(depth == 24 || depth == 32 || depth == 30) || width == 0 || height == 0)
return FALSE; return FALSE;
import_data.fd = fd; import_data.fd = fd;
import_data.width = width; import_data.width = width;
import_data.height = height; import_data.height = height;
import_data.stride = stride; import_data.stride = stride;
import_data.format = GBM_FORMAT_ARGB8888; if (depth == 30)
import_data.format = GBM_FORMAT_ARGB2101010;
else
import_data.format = GBM_FORMAT_ARGB8888;
bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, &import_data, 0); bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, &import_data, 0);
if (!bo) if (!bo)
return FALSE; return FALSE;

View File

@ -123,7 +123,10 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
int w, int h, GLenum format) int w, int h, GLenum format)
{ {
unsigned int tex; unsigned int tex;
GLenum iformat = format;
if (format == GL_RGB10_A2)
format = GL_RGBA;
glamor_make_current(glamor_priv); glamor_make_current(glamor_priv);
glGenTextures(1, &tex); glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex); glBindTexture(GL_TEXTURE_2D, tex);
@ -132,7 +135,7 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
if (format == glamor_priv->one_channel_format && format == GL_RED) if (format == glamor_priv->one_channel_format && format == GL_RED)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
glamor_priv->suppress_gl_out_of_memory_logging = true; glamor_priv->suppress_gl_out_of_memory_logging = true;
glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0,
format, GL_UNSIGNED_BYTE, NULL); format, GL_UNSIGNED_BYTE, NULL);
glamor_priv->suppress_gl_out_of_memory_logging = false; glamor_priv->suppress_gl_out_of_memory_logging = false;

View File

@ -33,6 +33,10 @@ glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
*format = GL_BGRA; *format = GL_BGRA;
*type = GL_UNSIGNED_INT_8_8_8_8_REV; *type = GL_UNSIGNED_INT_8_8_8_8_REV;
break; break;
case 30:
*format = GL_BGRA;
*type = GL_UNSIGNED_INT_2_10_10_10_REV;
break;
case 16: case 16:
*format = GL_RGB; *format = GL_RGB;
*type = GL_UNSIGNED_SHORT_5_6_5; *type = GL_UNSIGNED_SHORT_5_6_5;

View File

@ -619,6 +619,9 @@ gl_iformat_for_pixmap(PixmapPtr pixmap)
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) { ((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) {
return glamor_priv->one_channel_format; return glamor_priv->one_channel_format;
} else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
(pixmap)->drawable.depth == 30) {
return GL_RGB10_A2;
} else { } else {
return GL_RGBA; return GL_RGBA;
} }