[Mesa-dev] [PATCH 2/2] pb_bufmgr_cache: add is_buffer_busy hook and use it instead of non-blocking map

Marek Olšák maraeo at gmail.com
Sun Feb 13 23:45:29 PST 2011


On Mon, Feb 14, 2011 at 8:12 AM, Marek Olšák <maraeo at gmail.com> wrote:

> This is cleaner and implementing the hook is optional.
> ---
>  src/gallium/auxiliary/pipebuffer/pb_bufmgr.h       |    4 ++++
>  src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c |   11 +++--------
>  2 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
> b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
> index 2ef0216..960068c 100644
> --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
> +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
> @@ -82,6 +82,10 @@ struct pb_manager
>     */
>    void
>    (*flush)( struct pb_manager *mgr );
> +
> +   boolean
> +   (*is_buffer_busy)( struct pb_manager *mgr,
> +                      struct pb_buffer *buf );
>  };
>
>
> diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
> b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
> index a6eb403..f0dee07 100644
> --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
> +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
> @@ -227,8 +227,6 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
>                           pb_size size,
>                           const struct pb_desc *desc)
>  {
> -   void *map;
> -
>    if(buf->base.base.size < size)
>       return 0;
>
> @@ -242,13 +240,10 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer
> *buf,
>    if(!pb_check_usage(desc->usage, buf->base.base.usage))
>       return 0;
>
> -   map = pb_map(buf->buffer, PB_USAGE_DONTBLOCK, NULL);
> -   if (!map) {
> -      return -1;
> -   }
> +   if (buf->mgr->base.is_buffer_busy)
> +      if (buf->mgr->base.is_buffer_busy(&buf->mgr->base, buf->buffer))
> +         return -1;
>

Oops, this is wrong. I will locally replace any occurences of
"buf->mgr->base(.)" with "buf->mgr->provider(->)", which is how it was meant
to be, but the idea remains the same. Please review.

Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110214/df1ce8d4/attachment.html>


More information about the mesa-dev mailing list