r600g: the type of OCCLUSION_PREDICATE result should be boolean
authorMarek Olšák <maraeo@gmail.com>
Thu, 10 Nov 2011 22:38:31 +0000 (23:38 +0100)
committerMarek Olšák <maraeo@gmail.com>
Thu, 10 Nov 2011 23:03:52 +0000 (00:03 +0100)
src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_hw_context.c
src/gallium/drivers/r600/r600_query.c

index 28c1ee15ce3b1db80427e301866d6faaa2f1b07b..f04bcae1e51c19d5e5fa9e9f852302dedeab1ae5 100644 (file)
@@ -164,7 +164,10 @@ struct r600_range {
 };
 
 struct r600_query {
-       u64                                     result;
+       union {
+               uint64_t                        u64;
+               boolean                         b;
+       } result;
        /* The kind of query */
        unsigned                                type;
        /* Offset of the first result for current query */
index 867c6a00952a7cedc3dd760a5eb8ede2c0817901..c51016738bd24bd1ffdd8aa8c84ce16784d61cc7 100644 (file)
@@ -1617,21 +1617,21 @@ static boolean r600_query_result(struct r600_context *ctx, struct r600_query *qu
        switch (query->type) {
        case PIPE_QUERY_OCCLUSION_COUNTER:
                while (results_base != query->results_end) {
-                       query->result +=
+                       query->result.u64 +=
                                r600_query_read_result(map + results_base, 0, 2, true);
                        results_base = (results_base + 16) % query->buffer->b.b.b.width0;
                }
                break;
        case PIPE_QUERY_OCCLUSION_PREDICATE:
                while (results_base != query->results_end) {
-                       query->result = query->result ||
-                               r600_query_read_result(map + results_base, 0, 2, true);
+                       query->result.b = query->result.b ||
+                               r600_query_read_result(map + results_base, 0, 2, true) != 0;
                        results_base = (results_base + 16) % query->buffer->b.b.b.width0;
                }
                break;
        case PIPE_QUERY_TIME_ELAPSED:
                while (results_base != query->results_end) {
-                       query->result +=
+                       query->result.u64 +=
                                r600_query_read_result(map + results_base, 0, 2, false);
                        results_base = (results_base + query->result_size) % query->buffer->b.b.b.width0;
                }
@@ -1830,24 +1830,27 @@ boolean r600_context_query_result(struct r600_context *ctx,
                                struct r600_query *query,
                                boolean wait, void *vresult)
 {
-       uint64_t *result = (uint64_t*)vresult;
+       boolean *result_b = (boolean*)vresult;
+       uint64_t *result_u64 = (uint64_t*)vresult;
 
        if (!r600_query_result(ctx, query, wait))
                return FALSE;
 
        switch (query->type) {
        case PIPE_QUERY_OCCLUSION_COUNTER:
+               *result_u64 = query->result.u64;
+               break;
        case PIPE_QUERY_OCCLUSION_PREDICATE:
-               *result = query->result;
+               *result_b = query->result.b;
                break;
        case PIPE_QUERY_TIME_ELAPSED:
-               *result = (1000000 * query->result) / ctx->screen->info.r600_clock_crystal_freq;
+               *result_u64 = (1000000 * query->result.u64) / ctx->screen->info.r600_clock_crystal_freq;
                break;
        default:
                assert(0);
        }
 
-       query->result = 0;
+       memset(&query->result, 0, sizeof(query->result));
        return TRUE;
 }
 
index afdb0382d37fe43c6afb2eb02bb89d68ae2ca887..ec0d91f08748d482bd632676d26ef5a62ef8215a 100644 (file)
@@ -42,7 +42,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_query *rquery = (struct r600_query *)query;
 
-       rquery->result = 0;
+       memset(&rquery->result, 0, sizeof(rquery->result));
        rquery->results_start = rquery->results_end;
        r600_query_begin(&rctx->ctx, (struct r600_query *)query);
        LIST_ADDTAIL(&rquery->list, &rctx->ctx.active_query_list);
@@ -76,7 +76,7 @@ static void r600_render_condition(struct pipe_context *ctx,
        int wait_flag = 0;
 
        /* If we already have nonzero result, render unconditionally */
-       if (query != NULL && rquery->result != 0) {
+       if (query != NULL && rquery->result.u64 != 0) {
                if (rctx->current_render_cond) {
                        r600_render_condition(ctx, NULL, 0);
                }