r600g: fix corner case checks for the queries
authorVadim Girlin <vadimgirlin@gmail.com>
Sat, 16 Jul 2011 00:58:58 +0000 (04:58 +0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 18 Jul 2011 12:53:47 +0000 (08:53 -0400)
src/gallium/winsys/r600/drm/r600_hw_context.c

index 55f1d4cf07e1428aa744c44ac085d32bd5b4bcdb..07bd544d1a0a5178cf2bee04101e42a6edf28bf0 100644 (file)
@@ -1748,9 +1748,7 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
                r600_context_flush(ctx);
        }
 
-       /* if it's new OQ (not resume) */
-       if (query->type == PIPE_QUERY_OCCLUSION_COUNTER &&
-               query->results_start == query->results_end) {
+       if (query->type == PIPE_QUERY_OCCLUSION_COUNTER) {
                /* Count queries emitted without flushes, and flush if more than
                 * half of buffer used, to avoid overwriting results which may be
                 * still in use. */
@@ -1763,7 +1761,7 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
        }
 
        new_results_end = query->results_end + query->result_size;
-       if (new_results_end > query->buffer_size)
+       if (new_results_end >= query->buffer_size)
                new_results_end = 0;
 
        /* collect current results if query buffer is full */
@@ -1862,7 +1860,7 @@ void r600_query_predication(struct r600_context *ctx, struct r600_query *query,
 
                /* find count of the query data blocks */
                count = query->buffer_size + query->results_end - query->results_start;
-               if (count > query->buffer_size) count-=query->buffer_size;
+               if (count >= query->buffer_size) count-=query->buffer_size;
                count /= query->result_size;
 
                if (ctx->pm4_cdwords + 5 * count > ctx->pm4_ndwords)