[Mesa-dev] [PATCH 1/2] r600g, radeonsi: query the buffer domain from the kernel for DRI2 buffers

Christian König deathsimple at vodafone.de
Wed Feb 5 09:35:29 CET 2014


Am 05.02.2014 00:01, schrieb Marek Olšák:
> From: Marek Olšák <marek.olsak at amd.com>
>
> Better then guessing it.
>
> Yeah we have had this query for a long time...

Sounds reasonable to me.

Both patches are: Reviewed-by: Christian König <christian.koenig at amd.com>

> ---
>   src/gallium/drivers/radeon/r600_texture.c     |  2 +-
>   src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 23 +++++++++++++++++++++++
>   src/gallium/winsys/radeon/drm/radeon_winsys.h |  5 +++++
>   3 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index 878b26f..aa4e8ea 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -627,7 +627,7 @@ r600_texture_create_object(struct pipe_screen *screen,
>   	} else {
>   		resource->buf = buf;
>   		resource->cs_buf = rscreen->ws->buffer_get_cs_handle(buf);
> -		resource->domains = RADEON_DOMAIN_GTT | RADEON_DOMAIN_VRAM;
> +		resource->domains = rscreen->ws->buffer_get_current_domain(buf);
>   	}
>   
>   	if (rtex->cmask.size) {
> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
> index 2ac060b..7c59f26 100644
> --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
> @@ -201,6 +201,28 @@ static boolean radeon_bo_is_busy(struct pb_buffer *_buf,
>       }
>   }
>   
> +static enum radeon_bo_domain radeon_bo_get_current_domain(struct pb_buffer *_buf)
> +{
> +    struct radeon_bo *bo = get_radeon_bo(_buf);
> +    struct drm_radeon_gem_busy args;
> +
> +    memset(&args, 0, sizeof(args));
> +    args.handle = bo->handle;
> +
> +    drmCommandWriteRead(bo->rws->fd, DRM_RADEON_GEM_BUSY,
> +                        &args, sizeof(args));
> +
> +    /* Zero domains the driver doesn't understand. */
> +    args.domain &= ~(RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT);
> +
> +    /* If no domain is set, we must set something... */
> +    if (!args.domain)
> +        args.domain = RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT;
> +
> +    /* GEM domains and winsys domains are defined the same. */
> +    return args.domain;
> +}
> +
>   static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, uint64_t alignment)
>   {
>       struct radeon_bo_va_hole *hole, *n;
> @@ -1089,4 +1111,5 @@ void radeon_bomgr_init_functions(struct radeon_drm_winsys *ws)
>       ws->base.buffer_from_handle = radeon_winsys_bo_from_handle;
>       ws->base.buffer_get_handle = radeon_winsys_bo_get_handle;
>       ws->base.buffer_get_virtual_address = radeon_winsys_bo_va;
> +    ws->base.buffer_get_current_domain = radeon_bo_get_current_domain;
>   }
> diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
> index 55f60d3..fb942c0 100644
> --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
> +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
> @@ -376,6 +376,11 @@ struct radeon_winsys {
>        */
>       uint64_t (*buffer_get_virtual_address)(struct radeon_winsys_cs_handle *buf);
>   
> +    /**
> +     * Query the current placement of the buffer from the memory manager.
> +     */
> +    enum radeon_bo_domain (*buffer_get_current_domain)(struct pb_buffer *buf);
> +
>       /**************************************************************************
>        * Command submission.
>        *



More information about the mesa-dev mailing list