iris: Fix overzealous query object batch flushing.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 26 Jun 2019 04:14:11 +0000 (21:14 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 26 Jun 2019 16:49:01 +0000 (09:49 -0700)
In the past, each query object had their own BO.  Checking if the batch
referenced that BO was an easy way to check if commands were still
queued to compute the query value.  If so, we needed to flush.

More recently (c24a574e6c), we started using an u_upload_mgr for query
objects, placing multiple queries in the same BO.  One side-effect is
that iris_batch_references is a no longer a reasonable way to check if
commands are still queued for our query.  Ours might be done, but a
later query that happens to be in the same BO might be queued.  We don't
want to flush in that case.

Instead, check if the current batch's signalling syncpt is the one we
referenced when ending the query.  We know the syncpt can't have been
reused because our query is holding a reference, so a simple pointer
comparison should suffice.

Removes all batch flushing caused by query objects in Shadow of Mordor.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
src/gallium/drivers/iris/iris_query.c

index 1a230b3..f10f915 100644 (file)
@@ -864,7 +864,6 @@ iris_get_query_result(struct pipe_context *ctx,
    struct iris_query *q = (void *) query;
    struct iris_screen *screen = (void *) ctx->screen;
    const struct gen_device_info *devinfo = &screen->devinfo;
-   struct iris_bo *bo = iris_resource_bo(q->query_state_ref.res);
 
    if (unlikely(screen->no_hw)) {
       result->u64 = 0;
@@ -872,8 +871,9 @@ iris_get_query_result(struct pipe_context *ctx,
    }
 
    if (!q->ready) {
-      if (iris_batch_references(&ice->batches[q->batch_idx], bo))
-         iris_batch_flush(&ice->batches[q->batch_idx]);
+      struct iris_batch *batch = &ice->batches[q->batch_idx];
+      if (q->syncpt == iris_batch_get_signal_syncpt(batch))
+         iris_batch_flush(batch);
 
       while (!READ_ONCE(q->map->snapshots_landed)) {
          if (wait)
@@ -919,7 +919,7 @@ iris_get_query_result_resource(struct pipe_context *ctx,
        * now so that progress happens.  Either way, copy the snapshots
        * landed field to the destination resource.
        */
-      if (iris_batch_references(batch, bo))
+      if (q->syncpt == iris_batch_get_signal_syncpt(batch))
          iris_batch_flush(batch);
 
       ice->vtbl.copy_mem_mem(batch, iris_resource_bo(p_res), offset,