Commit 33c6c78a authored by Zhigang Gong's avatar Zhigang Gong
Browse files

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: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 8890b388
......@@ -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);
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment