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:
parent
f98ff253c7
commit
44f5885686
|
@ -204,6 +204,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
|
pixmap_priv->is_cbcr = (usage == GLAMOR_CREATE_FORMAT_CBCR);
|
||||||
|
|
||||||
format = gl_iformat_for_pixmap(pixmap);
|
format = gl_iformat_for_pixmap(pixmap);
|
||||||
|
|
||||||
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
|
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
|
||||||
|
|
|
@ -126,6 +126,7 @@ extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
|
||||||
#define GLAMOR_CREATE_FBO_NO_FBO 0x103
|
#define GLAMOR_CREATE_FBO_NO_FBO 0x103
|
||||||
#define GLAMOR_CREATE_NO_LARGE 0x105
|
#define GLAMOR_CREATE_NO_LARGE 0x105
|
||||||
#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
|
#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
|
||||||
|
#define GLAMOR_CREATE_FORMAT_CBCR 0x107
|
||||||
|
|
||||||
/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
|
/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
|
||||||
*
|
*
|
||||||
|
|
|
@ -378,6 +378,8 @@ typedef struct glamor_pixmap_private {
|
||||||
* names.
|
* names.
|
||||||
*/
|
*/
|
||||||
glamor_pixmap_fbo **fbo_array;
|
glamor_pixmap_fbo **fbo_array;
|
||||||
|
|
||||||
|
Bool is_cbcr;
|
||||||
} glamor_pixmap_private;
|
} glamor_pixmap_private;
|
||||||
|
|
||||||
extern DevPrivateKeyRec glamor_pixmap_private_key;
|
extern DevPrivateKeyRec glamor_pixmap_private_key;
|
||||||
|
@ -899,7 +901,7 @@ int glamor_xv_put_image(glamor_port_private *port_priv,
|
||||||
Bool sync,
|
Bool sync,
|
||||||
RegionPtr clipBoxes);
|
RegionPtr clipBoxes);
|
||||||
void glamor_xv_core_init(ScreenPtr screen);
|
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"
|
#include "glamor_utils.h"
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
void
|
void
|
||||||
glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
|
glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
|
||||||
{
|
{
|
||||||
|
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||||
switch (pixmap->drawable.depth) {
|
switch (pixmap->drawable.depth) {
|
||||||
case 24:
|
case 24:
|
||||||
case 32:
|
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;
|
*type = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
if (priv->is_cbcr) {
|
||||||
|
*format = priv->fbo->format;
|
||||||
|
*type = GL_UNSIGNED_BYTE;
|
||||||
|
} else {
|
||||||
*format = GL_RGB;
|
*format = GL_RGB;
|
||||||
*type = GL_UNSIGNED_SHORT_5_6_5;
|
*type = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
*format = GL_BGRA;
|
*format = GL_BGRA;
|
||||||
|
|
|
@ -613,10 +613,14 @@ gl_iformat_for_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
glamor_screen_private *glamor_priv =
|
glamor_screen_private *glamor_priv =
|
||||||
glamor_get_screen_private((pixmap)->drawable.pScreen);
|
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 &&
|
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 == 16 && pixmap_priv->is_cbcr) {
|
||||||
|
return GL_RG;
|
||||||
} else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
|
} else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
|
||||||
(pixmap)->drawable.depth == 30) {
|
(pixmap)->drawable.depth == 30) {
|
||||||
return GL_RGB10_A2;
|
return GL_RGB10_A2;
|
||||||
|
|
Loading…
Reference in New Issue