glamor: Ask the server to always allocate our private.
This avoids a lot of screwing around to attach our privates later. It means that non-glamor pixmaps now gain 120 bytes of glamor privates on 64-bit (which has quite a bit of fixable bloat), and glamor pixmaps take one less pointer of storage (not counting malloc overhead). Note that privates start out zero-filled, which matches the callocs we were doing when making our own privates, and in the case of an fb pixmap that has a priv where it didn't before, the type ends up being GLAMOR_MEMORY as we would want. v2: Clarify that the GLAMOR_MEMORY enum must be 0 (as it was previosuly), so that the new pixmap private behavior is as expected. Suggested by keithp. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1) Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
d278c30e68
commit
a2a2f6e34b
|
@ -80,12 +80,7 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
|
|||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
pixmap_priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
&glamor_pixmap_private_key);
|
||||
if (pixmap_priv == NULL) {
|
||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv->type = type;
|
||||
glamor_init_pixmap_private_small(pixmap, pixmap_priv);
|
||||
}
|
||||
|
@ -171,13 +166,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
else
|
||||
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
||||
|
||||
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
||||
|
||||
if (!pixmap_priv) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
}
|
||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
format = gl_iformat_for_pixmap(pixmap);
|
||||
|
||||
|
@ -223,7 +212,7 @@ glamor_destroy_textured_pixmap(PixmapPtr pixmap)
|
|||
#if GLAMOR_HAS_GBM
|
||||
glamor_egl_destroy_pixmap_image(pixmap);
|
||||
#endif
|
||||
glamor_set_pixmap_private(pixmap, NULL);
|
||||
glamor_pixmap_destroy_fbo(pixmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +444,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
glamor_set_screen_private(screen, glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP,
|
||||
sizeof(struct glamor_pixmap_private))) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
|
@ -705,27 +695,6 @@ glamor_release_screen_priv(ScreenPtr screen)
|
|||
glamor_set_screen_private(screen, NULL);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
||||
{
|
||||
glamor_pixmap_private *old_priv;
|
||||
|
||||
old_priv = dixGetPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
|
||||
|
||||
if (priv) {
|
||||
assert(old_priv == NULL);
|
||||
}
|
||||
else {
|
||||
if (old_priv == NULL)
|
||||
return;
|
||||
glamor_pixmap_destroy_fbo(glamor_get_screen_private(pixmap->drawable.pScreen),
|
||||
old_priv);
|
||||
free(old_priv);
|
||||
}
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key, priv);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_close_screen(ScreenPtr screen)
|
||||
{
|
||||
|
@ -759,7 +728,7 @@ glamor_close_screen(ScreenPtr screen)
|
|||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_set_pixmap_private(screen_pixmap, NULL);
|
||||
glamor_pixmap_destroy_fbo(screen_pixmap);
|
||||
|
||||
glamor_release_screen_priv(screen);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ struct glamor_context;
|
|||
* @TEXTURE_ONLY: pixmap is in an internal texture.
|
||||
*/
|
||||
typedef enum glamor_pixmap_type {
|
||||
GLAMOR_MEMORY,
|
||||
GLAMOR_MEMORY = 0, /* Newly calloc()ed pixmaps are memory. */
|
||||
GLAMOR_TEXTURE_DRM,
|
||||
GLAMOR_DRM_ONLY,
|
||||
GLAMOR_TEXTURE_ONLY,
|
||||
|
|
|
@ -471,9 +471,11 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
|||
}
|
||||
|
||||
void
|
||||
glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv,
|
||||
glamor_pixmap_private *priv)
|
||||
glamor_pixmap_destroy_fbo(PixmapPtr pixmap)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
if (glamor_pixmap_priv_is_large(priv)) {
|
||||
|
|
|
@ -405,22 +405,12 @@ extern DevPrivateKeyRec glamor_pixmap_private_key;
|
|||
static inline glamor_pixmap_private *
|
||||
glamor_get_pixmap_private(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
|
||||
if (pixmap == NULL)
|
||||
return NULL;
|
||||
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
|
||||
if (!priv) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
&glamor_pixmap_private_key);
|
||||
}
|
||||
return priv;
|
||||
return dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
|
||||
}
|
||||
|
||||
void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv);
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap has no image object
|
||||
*/
|
||||
|
@ -590,8 +580,7 @@ glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w,
|
|||
int h, GLenum format, int flag);
|
||||
void glamor_destroy_fbo(glamor_screen_private *glamor_priv,
|
||||
glamor_pixmap_fbo *fbo);
|
||||
void glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv,
|
||||
glamor_pixmap_private *priv);
|
||||
void glamor_pixmap_destroy_fbo(PixmapPtr pixmap);
|
||||
void glamor_init_pixmap_fbo(ScreenPtr screen);
|
||||
void glamor_fini_pixmap_fbo(ScreenPtr screen);
|
||||
Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
|
||||
|
|
Loading…
Reference in New Issue
Block a user