Classfy glamor pixmap to different types.
During the integration with intel driver, we introduce two new type of pixmap, one is TEXTURE_DRM, the other is DRM_ONLY. TEXTURE_DRM means we create a texture bind to the DRM buffer successfully. And then the texture and the external BO is consistent. DRM_ONLY means that we failed to create a texture from the external DRM BO. We need to handle those different types carefully, so we have to track them in the data structure. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
36d424feae
commit
e3d16c9ebd
|
@ -60,6 +60,25 @@ glamor_get_drawable_pixmap(DrawablePtr drawable)
|
|||
return (PixmapPtr) drawable;
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL) {
|
||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key, pixmap_priv);
|
||||
pixmap_priv->container = pixmap;
|
||||
pixmap_priv->glamor_priv = glamor_priv;
|
||||
}
|
||||
pixmap_priv->type = type;
|
||||
}
|
||||
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
||||
{
|
||||
|
@ -114,9 +133,6 @@ glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h,
|
|||
glamor_priv->screen_fbo = pixmap_priv->fb;
|
||||
}
|
||||
|
||||
#define GLAMOR_PIXMAP_MEMORY 0
|
||||
#define GLAMOR_PIXMAP_TEXTURE 1
|
||||
|
||||
PixmapPtr
|
||||
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
unsigned int usage)
|
||||
|
@ -124,7 +140,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
PixmapPtr pixmap;
|
||||
GLenum format;
|
||||
GLuint tex;
|
||||
int type = GLAMOR_PIXMAP_TEXTURE;
|
||||
glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
|
@ -137,7 +153,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
|| usage == GLAMOR_CREATE_PIXMAP_CPU) {
|
||||
/* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo.
|
||||
If we exceed such limitation, we have to use framebuffer. */
|
||||
type = GLAMOR_PIXMAP_MEMORY;
|
||||
type = GLAMOR_MEMORY;
|
||||
pixmap = fbCreatePixmap(screen, w, h, depth, usage);
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
||||
(((w *
|
||||
|
@ -159,9 +175,9 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
pixmap_priv->container = pixmap;
|
||||
pixmap_priv->glamor_priv = glamor_priv;
|
||||
|
||||
if (w == 0 || h == 0 || type == GLAMOR_PIXMAP_MEMORY) {
|
||||
pixmap_priv->type = type;
|
||||
if (w == 0 || h == 0 || type == GLAMOR_MEMORY)
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
switch (depth) {
|
||||
#if 0
|
||||
|
@ -188,6 +204,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glamor_set_pixmap_texture(pixmap, w, h, tex);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,20 @@
|
|||
| GLAMOR_USE_SCREEN \
|
||||
| GLAMOR_USE_PICTURE_SCREEN)
|
||||
|
||||
/*
|
||||
* glamor_pixmap_type : glamor pixmap's type.
|
||||
* @MEMORY: pixmap is in memory.
|
||||
* @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer.
|
||||
* @DRM_ONLY: pixmap is in a external DRM buffer.
|
||||
* @TEXTURE_ONLY: pixmap is in an internal texture.
|
||||
*/
|
||||
typedef enum glamor_pixmap_type {
|
||||
GLAMOR_MEMORY,
|
||||
GLAMOR_TEXTURE_DRM,
|
||||
GLAMOR_DRM_ONLY,
|
||||
GLAMOR_TEXTURE_ONLY
|
||||
} glamor_pixmap_type_t;
|
||||
|
||||
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
||||
|
||||
extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
|
||||
|
@ -58,9 +72,11 @@ extern _X_EXPORT void glamor_set_screen_pixmap_texture(ScreenPtr screen,
|
|||
int w, int h,
|
||||
unsigned int tex);
|
||||
extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
||||
void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h,
|
||||
unsigned int tex);
|
||||
|
||||
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h,
|
||||
unsigned int tex);
|
||||
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
#include <xorg-server.h>
|
||||
#define GLAMOR_FOR_XORG
|
||||
#include "xorg-server.h"
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
@ -54,15 +55,13 @@
|
|||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#define GLAMOR_FOR_XORG
|
||||
|
||||
#include <glamor.h>
|
||||
#include "glamor_gl_dispatch.h"
|
||||
|
||||
#define GLAMOR_VERSION_MAJOR 0
|
||||
#define GLAMOR_VERSION_MINOR 1
|
||||
#define GLAMOR_VERSION_PATCH 0
|
||||
|
||||
#include "glamor.h"
|
||||
#include "glamor_gl_dispatch.h"
|
||||
|
||||
static const char glamor_name[] = "glamor";
|
||||
|
||||
static DevPrivateKeyRec glamor_egl_pixmap_private_key_index;
|
||||
|
@ -127,7 +126,7 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
|||
attribs[1] = width;
|
||||
attribs[3] = height;
|
||||
attribs[5] = stride;
|
||||
if (depth != 32)
|
||||
if (depth != 32 && depth != 24)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
|
@ -226,6 +225,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Couldn't flink pixmap handle\n");
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -236,12 +236,15 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
name,
|
||||
pixmap->drawable.depth);
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_pixmap_texture(pixmap, pixmap->drawable.width,
|
||||
pixmap->drawable.height, texture);
|
||||
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
return TRUE;
|
||||
|
|
|
@ -233,6 +233,7 @@ typedef union _glamor_pending_op {
|
|||
|
||||
|
||||
typedef struct glamor_pixmap_private {
|
||||
glamor_pixmap_type_t type;
|
||||
unsigned char gl_fbo:1;
|
||||
unsigned char gl_tex:1;
|
||||
unsigned char pbo_valid:1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user