r600g: cosmetic changes in query code
authorMarek Olšák <maraeo@gmail.com>
Tue, 8 Nov 2011 22:09:33 +0000 (23:09 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 8 Nov 2011 23:18:53 +0000 (00:18 +0100)
Mainly updating comments and removing one use of a magic number.

src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_hw_context.c

index c38ea1b2a9ada0f92030ff4c03fa3e857eafb778..715501d91d3d5fe3b9110173b76cebf07b036b78 100644 (file)
@@ -163,9 +163,6 @@ struct r600_range {
        struct r600_block       **blocks;
 };
 
-/*
- * query
- */
 struct r600_query {
        u64                                     result;
        /* The kind of query */
@@ -174,7 +171,8 @@ struct r600_query {
        unsigned                                results_start;
        /* Offset of the next free result after current query data */
        unsigned                                results_end;
-       /* Size of the result */
+       /* Size of the result in memory for both begin_query and end_query,
+        * this can be one or two numbers, or it could even be a size of a structure. */
        unsigned                                result_size;
        /* The buffer where query results are stored. It's used as a ring,
         * data blocks for current query are stored sequentially from
index 6e3080ddc5156abbfdb0317cdf8863130bf4426d..c04af902752bc4a11f5a10ed72a3dbbe2b05ad56 100644 (file)
@@ -1622,13 +1622,12 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
 {
        unsigned required_space, new_results_end;
 
-       /* query request needs 6/8 dwords for begin + 6/8 dwords for end */
        switch (query->type) {
        case PIPE_QUERY_OCCLUSION_COUNTER:
-               required_space = 12;
+               required_space = 12; /* 6 for begin, 6 for end */
                break;
        case PIPE_QUERY_TIME_ELAPSED:
-               required_space = 16;
+               required_space = 16; /* 8 for begin, 8 for end */
                break;
        default:
                assert(0);
@@ -1705,7 +1704,7 @@ void r600_query_end(struct r600_context *ctx, struct r600_query *query)
        case PIPE_QUERY_TIME_ELAPSED:
                ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE_EOP, 4, 0);
                ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5);
-               ctx->pm4[ctx->pm4_cdwords++] = query->results_end + 8;
+               ctx->pm4[ctx->pm4_cdwords++] = query->results_end + query->result_size/2;
                ctx->pm4[ctx->pm4_cdwords++] = (3 << 29);
                ctx->pm4[ctx->pm4_cdwords++] = 0;
                ctx->pm4[ctx->pm4_cdwords++] = 0;
@@ -1774,10 +1773,10 @@ struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned
 
        switch (query_type) {
        case PIPE_QUERY_OCCLUSION_COUNTER:
-               query->result_size = 4 * 4 * ctx->max_db;
+               query->result_size = 16 * ctx->max_db;
                break;
        case PIPE_QUERY_TIME_ELAPSED:
-               query->result_size = 4 * 4;
+               query->result_size = 16;
                break;
        default:
                assert(0);