glamor: add support for GL_RG

Allow to upload the CbCr plane of an NV12 image into a GL texture.

Signed-off-by: Julien Isorce <jisorce@oblong.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Julien Isorce 2018-09-06 15:38:14 -07:00 committed by Adam Jackson
parent f98ff253c7
commit 44f5885686
5 changed files with 18 additions and 3 deletions

View File

@ -204,6 +204,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
pixmap_priv = glamor_get_pixmap_private(pixmap);
pixmap_priv->is_cbcr = (usage == GLAMOR_CREATE_FORMAT_CBCR);
format = gl_iformat_for_pixmap(pixmap);
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;

View File

@ -126,6 +126,7 @@ extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
#define GLAMOR_CREATE_FBO_NO_FBO 0x103
#define GLAMOR_CREATE_NO_LARGE 0x105
#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
#define GLAMOR_CREATE_FORMAT_CBCR 0x107
/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
*

View File

@ -378,6 +378,8 @@ typedef struct glamor_pixmap_private {
* names.
*/
glamor_pixmap_fbo **fbo_array;
Bool is_cbcr;
} glamor_pixmap_private;
extern DevPrivateKeyRec glamor_pixmap_private_key;
@ -899,7 +901,7 @@ int glamor_xv_put_image(glamor_port_private *port_priv,
Bool sync,
RegionPtr clipBoxes);
void glamor_xv_core_init(ScreenPtr screen);
void glamor_xv_render(glamor_port_private *port_priv);
void glamor_xv_render(glamor_port_private *port_priv, int id);
#include "glamor_utils.h"

View File

@ -27,6 +27,7 @@
void
glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
{
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
switch (pixmap->drawable.depth) {
case 24:
case 32:
@ -38,8 +39,13 @@ glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
*type = GL_UNSIGNED_INT_2_10_10_10_REV;
break;
case 16:
*format = GL_RGB;
*type = GL_UNSIGNED_SHORT_5_6_5;
if (priv->is_cbcr) {
*format = priv->fbo->format;
*type = GL_UNSIGNED_BYTE;
} else {
*format = GL_RGB;
*type = GL_UNSIGNED_SHORT_5_6_5;
}
break;
case 15:
*format = GL_BGRA;

View File

@ -613,10 +613,14 @@ gl_iformat_for_pixmap(PixmapPtr pixmap)
{
glamor_screen_private *glamor_priv =
glamor_get_screen_private((pixmap)->drawable.pScreen);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) {
return glamor_priv->one_channel_format;
} else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
(pixmap)->drawable.depth == 16 && pixmap_priv->is_cbcr) {
return GL_RG;
} else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
(pixmap)->drawable.depth == 30) {
return GL_RGB10_A2;