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:
parent
8890b38857
commit
33c6c78ae9
|
@ -116,11 +116,12 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||||
GLuint tex;
|
GLuint tex;
|
||||||
int type = GLAMOR_PIXMAP_TEXTURE;
|
int type = GLAMOR_PIXMAP_TEXTURE;
|
||||||
glamor_pixmap_private *pixmap_priv;
|
glamor_pixmap_private *pixmap_priv;
|
||||||
|
|
||||||
if (w > 32767 || h > 32767)
|
if (w > 32767 || h > 32767)
|
||||||
return NullPixmap;
|
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.
|
/* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo.
|
||||||
If we exceed such limitation, we have to use framebuffer.*/
|
If we exceed such limitation, we have to use framebuffer.*/
|
||||||
type = GLAMOR_PIXMAP_MEMORY;
|
type = GLAMOR_PIXMAP_MEMORY;
|
||||||
|
@ -129,9 +130,9 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||||
(((w * pixmap->drawable.bitsPerPixel +
|
(((w * pixmap->drawable.bitsPerPixel +
|
||||||
7) / 8) + 3) & ~3,
|
7) / 8) + 3) & ~3,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (usage != GLAMOR_CREATE_PIXMAP_CPU)
|
||||||
glamor_fallback("choose cpu memory for pixmap %p ,"
|
glamor_fallback("choose cpu memory for pixmap %p ,"
|
||||||
" %d x %d depth %d\n", pixmap, w, h, depth);
|
" %d x %d depth %d\n", pixmap, w, h, depth);
|
||||||
} else
|
} else
|
||||||
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
|
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||||
glDeleteTextures(1, &pixmap_priv->tex);
|
glDeleteTextures(1, &pixmap_priv->tex);
|
||||||
if (pixmap_priv->pbo)
|
if (pixmap_priv->pbo)
|
||||||
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
||||||
|
dixFreePrivates(pixmap->devPrivates, PRIVATE_PIXMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fbDestroyPixmap(pixmap);
|
return fbDestroyPixmap(pixmap);
|
||||||
|
|
|
@ -50,9 +50,9 @@
|
||||||
|
|
||||||
#include "glamor_debug.h"
|
#include "glamor_debug.h"
|
||||||
|
|
||||||
#define glamor_check_fbo_width_height(_w_, _h_) (_w_ > 0 && _h_ > 0 \
|
#define glamor_check_fbo_width_height(_w_, _h_) ((_w_) > 0 && (_h_) > 0 \
|
||||||
&& _w_ < MAX_WIDTH \
|
&& (_w_) < MAX_WIDTH \
|
||||||
&& _h_ < MAX_HEIGHT)
|
&& (_h_) < MAX_HEIGHT)
|
||||||
|
|
||||||
#define glamor_check_fbo_depth(_depth_) ( \
|
#define glamor_check_fbo_depth(_depth_) ( \
|
||||||
_depth_ == 8 \
|
_depth_ == 8 \
|
||||||
|
@ -149,6 +149,7 @@ enum shader_in {
|
||||||
SHADER_IN_COUNT,
|
SHADER_IN_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GLAMOR_CREATE_PIXMAP_CPU 0x100
|
||||||
typedef struct glamor_screen_private {
|
typedef struct glamor_screen_private {
|
||||||
CloseScreenProcPtr saved_close_screen;
|
CloseScreenProcPtr saved_close_screen;
|
||||||
CreateGCProcPtr saved_create_gc;
|
CreateGCProcPtr saved_create_gc;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user