From 316b4ddcf770e453b888ff7fbf96cb0aec1ce106 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michel=20D=C3=A4nzer?= Date: Fri, 2 Oct 2009 18:13:26 +0200 Subject: [PATCH] st/xorg: Use PIPE_TRANSFER_MAP_DIRECTLY flag in EXA PrepareAccess hook. Propagate NULL return value. This also allows removing the DRM_MODE_FEATURE_DIRTYFB specific pixmap management hacks. --- src/gallium/state_trackers/xorg/xorg_exa.c | 93 ++++++++-------------- 1 file changed, 34 insertions(+), 59 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index b54e31a7019..f7949bafaae 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -202,7 +202,7 @@ ExaPrepareAccess(PixmapPtr pPix, int index) if (!priv->tex) return FALSE; - if (priv->map_count++ == 0) + if (priv->map_count == 0) { if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) & PIPE_REFERENCED_FOR_WRITE) @@ -210,14 +210,21 @@ ExaPrepareAccess(PixmapPtr pPix, int index) priv->map_transfer = exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, +#ifdef EXA_MIXED_PIXMAPS + PIPE_TRANSFER_MAP_DIRECTLY | +#endif PIPE_TRANSFER_READ_WRITE, 0, 0, priv->tex->width[0], priv->tex->height[0]); + if (!priv->map_transfer) + return FALSE; pPix->devPrivate.ptr = exa->scrn->transfer_map(exa->scrn, priv->map_transfer); pPix->devKind = priv->map_transfer->stride; } + priv->map_count++; + return TRUE; } @@ -670,65 +677,33 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, priv->tex->height[0] != height || priv->tex_flags != priv->flags)) { struct pipe_texture *texture = NULL; - -#ifdef DRM_MODE_FEATURE_DIRTYFB - if (priv->flags) -#endif - { - struct pipe_texture template; - - memset(&template, 0, sizeof(template)); - template.target = PIPE_TEXTURE_2D; - exa_get_pipe_format(depth, &template.format, &bitsPerPixel); - pf_get_block(template.format, &template.block); - template.width[0] = width; - template.height[0] = height; - template.depth[0] = 1; - template.last_level = 0; - template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | priv->flags; - priv->tex_flags = priv->flags; - texture = exa->scrn->texture_create(exa->scrn, &template); - - if (priv->tex) { - struct pipe_surface *dst_surf; - struct pipe_surface *src_surf; - - dst_surf = exa->scrn->get_tex_surface( - exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); - src_surf = exa_gpu_surface(exa, priv); - exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, - 0, 0, min(width, texture->width[0]), - min(height, texture->height[0])); - exa->scrn->tex_surface_destroy(dst_surf); - exa->scrn->tex_surface_destroy(src_surf); - } else if (pPixmap->devPrivate.ptr) { - struct pipe_transfer *transfer; - - if (priv->map_count != 0) - FatalError("doing ExaModifyPixmapHeader on mapped buffer\n"); - - transfer = - exa->scrn->get_tex_transfer(exa->scrn, texture, 0, 0, 0, - PIPE_TRANSFER_WRITE, - 0, 0, width, height); - util_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer), - &texture->block, transfer->stride, 0, 0, - width, height, pPixmap->devPrivate.ptr, - pPixmap->devKind, 0, 0); - exa->scrn->transfer_unmap(exa->scrn, transfer); - exa->scrn->tex_transfer_destroy(transfer); - - xfree(pPixmap->devPrivate.ptr); - pPixmap->devPrivate.ptr = NULL; - } - } -#ifdef DRM_MODE_FEATURE_DIRTYFB - else { - xfree(pPixmap->devPrivate.ptr); - pPixmap->devPrivate.ptr = xalloc(pPixmap->drawable.height * - pPixmap->devKind); + struct pipe_texture template; + + memset(&template, 0, sizeof(template)); + template.target = PIPE_TEXTURE_2D; + exa_get_pipe_format(depth, &template.format, &bitsPerPixel); + pf_get_block(template.format, &template.block); + template.width[0] = width; + template.height[0] = height; + template.depth[0] = 1; + template.last_level = 0; + template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | priv->flags; + priv->tex_flags = priv->flags; + texture = exa->scrn->texture_create(exa->scrn, &template); + + if (priv->tex) { + struct pipe_surface *dst_surf; + struct pipe_surface *src_surf; + + dst_surf = exa->scrn->get_tex_surface( + exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); + src_surf = exa_gpu_surface(exa, priv); + exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, + 0, 0, min(width, texture->width[0]), + min(height, texture->height[0])); + exa->scrn->tex_surface_destroy(dst_surf); + exa->scrn->tex_surface_destroy(src_surf); } -#endif pipe_texture_reference(&priv->tex, texture); /* the texture we create has one reference */ -- 2.30.2