glamor_create_fbo: Concentrate the fbo size/depth checking.
Concentrate checking the size/depth when creating fbo. Simply the pixmap creation and the uploading fbo/texture preparing. Also slightly change the uploading fbo's preparation. If don't need fbo, then a fbo only has valid texture should be enough to return. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
1bfe595711
commit
a1de528c56
|
@ -139,19 +139,17 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
if (w > 32767 || h > 32767)
|
||||
return NullPixmap;
|
||||
|
||||
if (!glamor_check_fbo_size(glamor_priv, 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. */
|
||||
if (usage == GLAMOR_CREATE_PIXMAP_CPU || (w == 0 && h == 0))
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
} else
|
||||
else
|
||||
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
||||
|
||||
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
||||
|
||||
if (!pixmap_priv)
|
||||
if (!pixmap_priv) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
}
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key,
|
||||
|
@ -161,9 +159,6 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
pixmap_priv->glamor_priv = glamor_priv;
|
||||
pixmap_priv->type = type;
|
||||
|
||||
if (w == 0 || h == 0)
|
||||
return pixmap;
|
||||
|
||||
fbo = glamor_create_fbo(glamor_priv, w, h, depth, usage);
|
||||
|
||||
if (fbo == NULL) {
|
||||
|
|
|
@ -341,6 +341,10 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
|
|||
GLint tex;
|
||||
int cache_flag;
|
||||
|
||||
if (!glamor_check_fbo_size(glamor_priv, w, h)
|
||||
|| !glamor_check_fbo_depth(depth))
|
||||
return NULL;
|
||||
|
||||
if (flag == GLAMOR_CREATE_FBO_NO_FBO)
|
||||
goto new_fbo;
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
|||
static int
|
||||
glamor_pixmap_upload_prepare(PixmapPtr pixmap, int no_alpha, int no_revert)
|
||||
{
|
||||
int flag = 0;
|
||||
int flag;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
GLenum format;
|
||||
|
@ -445,28 +445,29 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, int no_alpha, int no_revert)
|
|||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
||||
if (!glamor_check_fbo_size
|
||||
(glamor_priv, pixmap->drawable.width, pixmap->drawable.height)
|
||||
|| !glamor_check_fbo_depth(pixmap->drawable.depth)) {
|
||||
glamor_fallback
|
||||
("upload failed reason: bad size or depth %d x %d @depth %d \n",
|
||||
pixmap->drawable.width, pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
return -1;
|
||||
}
|
||||
if (!(no_alpha || !no_revert || !glamor_priv->yInverted)) {
|
||||
|
||||
if (!(no_alpha || !no_revert || !glamor_priv->yInverted))
|
||||
if (pixmap_priv && pixmap_priv->fbo)
|
||||
return 0;
|
||||
flag = GLAMOR_CREATE_FBO_NO_FBO;
|
||||
} else {
|
||||
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return 0;
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return 0;
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth,
|
||||
flag);
|
||||
if (fbo == NULL)
|
||||
if (fbo == NULL) {
|
||||
glamor_fallback
|
||||
("upload failed, depth %d x %d @depth %d \n",
|
||||
pixmap->drawable.width, pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
return -1;
|
||||
}
|
||||
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user