diff options
author | Zack Rusin <[email protected]> | 2010-06-07 12:14:56 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2010-06-08 06:28:11 -0400 |
commit | be7d8ddf0c0a293ee94db360a44561beb10e62f9 (patch) | |
tree | 1e437b13943146fbe769b45373eedd156e99d12c /src/gallium/drivers/softpipe/sp_query.c | |
parent | 34f7681669987bc804f4603463f2fa3f82bc844f (diff) |
gallium: add basic support for stream output queries
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_query.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_query.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index ae52c22b3ee..43ff5c56afe 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -41,6 +41,7 @@ struct softpipe_query { unsigned type; uint64_t start; uint64_t end; + struct pipe_query_data_so_statistics so; }; @@ -55,7 +56,9 @@ softpipe_create_query(struct pipe_context *pipe, { struct softpipe_query* sq; - assert(type == PIPE_QUERY_OCCLUSION_COUNTER || type == PIPE_QUERY_TIME_ELAPSED); + assert(type == PIPE_QUERY_OCCLUSION_COUNTER || + type == PIPE_QUERY_TIME_ELAPSED || + type == PIPE_QUERY_SO_STATISTICS); sq = CALLOC_STRUCT( softpipe_query ); sq->type = type; @@ -83,6 +86,9 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) case PIPE_QUERY_TIME_ELAPSED: sq->start = 1000*os_time_get(); break; + case PIPE_QUERY_SO_STATISTICS: + sq->so.num_primitives_written = 0; + sq->so.primitives_storage_needed = 0; default: assert(0); break; @@ -106,6 +112,11 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) case PIPE_QUERY_TIME_ELAPSED: sq->end = 1000*os_time_get(); break; + case PIPE_QUERY_SO_STATISTICS: + sq->so.num_primitives_written = + softpipe->so_stats.num_primitives_written; + sq->so.primitives_storage_needed = + softpipe->so_stats.primitives_storage_needed; default: assert(0); break; @@ -122,7 +133,16 @@ softpipe_get_query_result(struct pipe_context *pipe, { struct softpipe_query *sq = softpipe_query(q); uint64_t *result = (uint64_t*)vresult; - *result = sq->end - sq->start; + + switch (sq->type) { + case PIPE_QUERY_SO_STATISTICS: + memcpy(vresult, &sq->so, + sizeof(struct pipe_query_data_so_statistics)); + break; + default: + *result = sq->end - sq->start; + break; + } return TRUE; } |