OSDN Git Service

i965/query: Cache whether the batch references the query BO.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 11 Dec 2014 10:26:39 +0000 (02:26 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 16 Dec 2014 23:39:54 +0000 (15:39 -0800)
commit3eb6258db7b7590493e473bf654409212061b8b0
treef6a7f7a0891414e9da00d57bd6c7ff2f73f27f7c
parentcb5cfb8361338c4a9e413f287591c1678187bcfc
i965/query: Cache whether the batch references the query BO.

Chris Wilson noted that repeated calls to CheckQuery() would call
drm_intel_bo_references(brw->batch.bo, query->bo) on each invocation,
which is expensive.  Once we've flushed, we know that future batches
won't reference query->bo, so there's no point in asking more than once.

This patch adds a brw_query_object::flushed flag, which is a
conservative estimate of whether the batch has been flushed.

On the first call to CheckQuery() or WaitQuery(), we check if the
batch references query->bo.  If not, it must have been flushed for
some reason (such as being full).  We record that it was flushed.
If it does reference query->bo, we explicitly flush, and record that
we did so.

Any subsequent checks will simply see that query->flushed is set,
and skip the drm_intel_bo_references() call.

Inspired by a patch from Chris Wilson.

According to Eero, this does not affect the performance of Witcher 2
on Haswell, but approximately halves the userspace CPU usage.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86969
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/gen6_queryobj.c