glamor: Add one option to force create a cpu memory pixmap.

Some special case we want to get a cpu memory pixmap. For example
to gather a large cpu memory pixmap's block to a small pixmap.

Add pixmap's priviate data's deallocation when destroy a pixmap.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2011-06-30 16:01:57 +08:00
parent 8890b38857
commit 33c6c78ae9
2 changed files with 11 additions and 8 deletions

View File

@ -116,11 +116,12 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
GLuint tex;
int type = GLAMOR_PIXMAP_TEXTURE;
glamor_pixmap_private *pixmap_priv;
if (w > 32767 || h > 32767)
return NullPixmap;
if (!glamor_check_fbo_width_height(w,h) || !glamor_check_fbo_depth(depth)) {
if (!glamor_check_fbo_width_height(w,h)
|| !glamor_check_fbo_depth(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;
@ -129,9 +130,9 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
(((w * pixmap->drawable.bitsPerPixel +
7) / 8) + 3) & ~3,
NULL);
glamor_fallback("choose cpu memory for pixmap %p ,"
" %d x %d depth %d\n", pixmap, w, h, depth);
if (usage != GLAMOR_CREATE_PIXMAP_CPU)
glamor_fallback("choose cpu memory for pixmap %p ,"
" %d x %d depth %d\n", pixmap, w, h, depth);
} else
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
@ -217,6 +218,7 @@ glamor_destroy_pixmap(PixmapPtr pixmap)
glDeleteTextures(1, &pixmap_priv->tex);
if (pixmap_priv->pbo)
glDeleteBuffersARB(1, &pixmap_priv->pbo);
dixFreePrivates(pixmap->devPrivates, PRIVATE_PIXMAP);
}
return fbDestroyPixmap(pixmap);

View File

@ -50,9 +50,9 @@
#include "glamor_debug.h"
#define glamor_check_fbo_width_height(_w_, _h_) (_w_ > 0 && _h_ > 0 \
&& _w_ < MAX_WIDTH \
&& _h_ < MAX_HEIGHT)
#define glamor_check_fbo_width_height(_w_, _h_) ((_w_) > 0 && (_h_) > 0 \
&& (_w_) < MAX_WIDTH \
&& (_h_) < MAX_HEIGHT)
#define glamor_check_fbo_depth(_depth_) ( \
_depth_ == 8 \
@ -149,6 +149,7 @@ enum shader_in {
SHADER_IN_COUNT,
};
#define GLAMOR_CREATE_PIXMAP_CPU 0x100
typedef struct glamor_screen_private {
CloseScreenProcPtr saved_close_screen;
CreateGCProcPtr saved_create_gc;