[Mesa-dev] [PATCH 7/9] i965: Use snoop bo for accessing query results on !llc
Kenneth Graunke
kenneth at whitecape.org
Wed Jun 14 23:13:14 UTC 2017
On Friday, June 9, 2017 6:01:38 AM PDT Chris Wilson wrote:
> Ony non-llc architectures where we are primarily reading back the
> results of the GPU queries, then we can improve performance by using a
> cacheable mapping of the results. Unfortunately, enabling snooping makes
> the writes from the GPU slower, which may adversely affect pipelined
> query operations (where the results are used directly by the GPU and not
> CPU).
We're essentially writing two DWords, and reading two DWords - so we aren't
primarily reading. However, with your next patch, where we want to be able
to asynchronously poll the status via CheckQuery()...we'll be reading a
bunch more. It might make sense to mention this polling in the commit
message.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> Cc: Matt Turner <mattst88 at gmail.com>
> ---
> src/mesa/drivers/dri/i965/brw_bufmgr.c | 21 +++++++++++++++++++++
> src/mesa/drivers/dri/i965/brw_bufmgr.h | 2 ++
> src/mesa/drivers/dri/i965/gen6_queryobj.c | 2 ++
> 3 files changed, 25 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> index 9028b538c6..824bc55fb2 100644
> --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
> +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> @@ -626,6 +626,27 @@ brw_bo_unreference(struct brw_bo *bo)
> }
> }
>
> +static bool __brw_bo_set_caching(struct brw_bo *bo, int caching)
static bool
__brw_bo_set_caching(struct brw_bo *bo, int caching)
> +{
> + struct drm_i915_gem_caching arg = {
> + .handle = bo->gem_handle,
> + .caching = caching
> + };
> + return drmIoctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) == 0;
> +}
> +
> +void brw_bo_set_cache_coherent(struct brw_bo *bo)
void
brw_bo_set_cache_coherent(struct brw_bo *bo)
With those three changes,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> +{
> + if (bo->cache_coherent)
> + return;
> +
> + if (!__brw_bo_set_caching(bo, I915_CACHING_CACHED))
> + return;
> +
> + bo->reusable = false;
> + bo->cache_coherent = true;
> +}
> +
> static void
> set_domain(struct brw_context *brw, const char *action,
> struct brw_bo *bo, uint32_t read_domains, uint32_t write_domain)
> diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h
> index 214b75bf1a..188d6c5ee0 100644
> --- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
> +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
> @@ -188,6 +188,8 @@ void brw_bo_unreference(struct brw_bo *bo);
> #define MAP_INTERNAL_MASK (0xff << 24)
> #define MAP_RAW (0x01 << 24)
>
> +void brw_bo_set_cache_coherent(struct brw_bo *bo);
> +
> /**
> * Maps the buffer into userspace.
> *
> diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c
> index 18af608166..5c95a4bae9 100644
> --- a/src/mesa/drivers/dri/i965/gen6_queryobj.c
> +++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c
> @@ -316,6 +316,8 @@ static int gen6_alloc_query(struct brw_context *brw,
> brw_bo_unreference(query->bo);
>
> query->bo = brw_bo_alloc(brw->bufmgr, "query results", 4096, 4096);
> + brw_bo_set_cache_coherent(query->bo);
> +
> query->results = brw_bo_map(brw, query->bo,
> MAP_READ | MAP_COHERENT | MAP_ASYNC);
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170614/9a4e925f/attachment.sig>
More information about the mesa-dev
mailing list