v3d: set instance id to 0 at start of tile
[mesa.git] / src / gallium / drivers / v3d / v3d_query.c
index 72bb2e43c51a1c04a3d7e50dcf13517aaf7d4434..334713e5cc54f90892bbebcb1712939149b5fe1f 100644 (file)
@@ -72,6 +72,13 @@ v3d_begin_query(struct pipe_context *pctx, struct pipe_query *query)
 
         switch (q->type) {
         case PIPE_QUERY_PRIMITIVES_GENERATED:
+                /* If we are using PRIMITIVE_COUNTS_FEEDBACK to retrieve
+                 * primitive counts from the GPU (which we need when a GS
+                 * is present), then we need to update our counters now
+                 * to discard any primitives generated before this.
+                 */
+                if (v3d->prog.gs)
+                        v3d_update_primitive_counters(v3d);
                 q->start = v3d->prims_generated;
                 break;
         case PIPE_QUERY_PRIMITIVES_EMITTED:
@@ -79,7 +86,7 @@ v3d_begin_query(struct pipe_context *pctx, struct pipe_query *query)
                  * primitive counts to skip primtives recorded before this.
                  */
                 if (v3d->streamout.num_targets > 0)
-                        v3d_tf_update_counters(v3d);
+                        v3d_update_primitive_counters(v3d);
                 q->start = v3d->tf_prims_generated;
                 break;
         case PIPE_QUERY_OCCLUSION_COUNTER:
@@ -107,6 +114,12 @@ v3d_end_query(struct pipe_context *pctx, struct pipe_query *query)
 
         switch (q->type) {
         case PIPE_QUERY_PRIMITIVES_GENERATED:
+                /* If we are using PRIMITIVE_COUNTS_FEEDBACK to retrieve
+                 * primitive counts from the GPU (which we need when a GS
+                 * is present), then we need to update our counters now.
+                 */
+                if (v3d->prog.gs)
+                        v3d_update_primitive_counters(v3d);
                 q->end = v3d->prims_generated;
                 break;
         case PIPE_QUERY_PRIMITIVES_EMITTED:
@@ -115,7 +128,7 @@ v3d_end_query(struct pipe_context *pctx, struct pipe_query *query)
                  * time. Otherwise, we have to do it now.
                  */
                 if (v3d->streamout.num_targets > 0)
-                        v3d_tf_update_counters(v3d);
+                        v3d_update_primitive_counters(v3d);
                 q->end = v3d->tf_prims_generated;
                 break;
         case PIPE_QUERY_OCCLUSION_COUNTER:
@@ -143,10 +156,10 @@ v3d_get_query_result(struct pipe_context *pctx, struct pipe_query *query,
                 v3d_flush_jobs_using_bo(v3d, q->bo);
 
                 if (wait) {
-                        if (!v3d_bo_wait(q->bo, 0, "query"))
+                        if (!v3d_bo_wait(q->bo, ~0ull, "query"))
                                 return false;
                 } else {
-                        if (!v3d_bo_wait(q->bo, ~0ull, "query"))
+                        if (!v3d_bo_wait(q->bo, 0, "query"))
                                 return false;
                 }