summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_query.c
diff options
context:
space:
mode:
authorJames Benton <[email protected]>2012-12-03 07:00:37 +0000
committerJosé Fonseca <[email protected]>2012-12-03 17:21:57 +0000
commit16f0d70ffe6d42d22b9e6b927b297e75a199aa78 (patch)
tree743ca3f973a5389fd8ecb49c3181b2ae2b26dfd3 /src/gallium/drivers/llvmpipe/lp_query.c
parent041966801ec87e3bf32913e43d6882eca9434695 (diff)
llvmpipe: Implement PIPE_QUERY_TIMESTAMP and PIPE_QUERY_TIME_ELAPSED.
This required an update for the query storage in llvmpipe, there can now be an active query per query type, so an occlusion query can run at the same time as a time elapsed query. Based on PIPE_QUERY_TIME_ELAPSED patch from Dave Airlie. v2: fix up piglits for timers (also from Dave Airlie) a) if we don't render anything the result is 0, so just return the current time b) add missing screen get_timestamp callback. Signed-off-by: Dave Airlie <[email protected]> Signed-off-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_query.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_query.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
index 20c0a1e0bcb..e3021972566 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.c
+++ b/src/gallium/drivers/llvmpipe/lp_query.c
@@ -33,6 +33,7 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
+#include "os/os_time.h"
#include "lp_context.h"
#include "lp_flush.h"
#include "lp_fence.h"
@@ -51,10 +52,14 @@ llvmpipe_create_query(struct pipe_context *pipe,
{
struct llvmpipe_query *pq;
- assert(type == PIPE_QUERY_OCCLUSION_COUNTER);
+ assert(type < PIPE_QUERY_TYPES);
pq = CALLOC_STRUCT( llvmpipe_query );
+ if (pq) {
+ pq->type = type;
+ }
+
return (struct pipe_query *) pq;
}
@@ -100,7 +105,7 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
if (!lp_fence_signalled(pq->fence)) {
if (!lp_fence_issued(pq->fence))
llvmpipe_flush(pipe, NULL, __FUNCTION__);
-
+
if (!wait)
return FALSE;
@@ -110,8 +115,32 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
/* Sum the results from each of the threads:
*/
*result = 0;
- for (i = 0; i < LP_MAX_THREADS; i++) {
- *result += pq->count[i];
+
+ switch (pq->type) {
+ case PIPE_QUERY_OCCLUSION_COUNTER:
+ for (i = 0; i < LP_MAX_THREADS; i++) {
+ *result += pq->count[i];
+ }
+ break;
+ case PIPE_QUERY_TIME_ELAPSED:
+ for (i = 0; i < LP_MAX_THREADS; i++) {
+ if (pq->count[i] > *result) {
+ *result = pq->count[i];
+ }
+ }
+ break;
+ case PIPE_QUERY_TIMESTAMP:
+ for (i = 0; i < LP_MAX_THREADS; i++) {
+ if (pq->count[i] > *result) {
+ *result = pq->count[i];
+ }
+ if (*result == 0)
+ *result = os_time_get_nano();
+ }
+ break;
+ default:
+ assert(0);
+ break;
}
return TRUE;
@@ -136,8 +165,10 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
memset(pq->count, 0, sizeof(pq->count));
lp_setup_begin_query(llvmpipe->setup, pq);
- llvmpipe->active_query_count++;
- llvmpipe->dirty |= LP_NEW_QUERY;
+ if (pq->type == PIPE_QUERY_OCCLUSION_COUNTER) {
+ llvmpipe->active_occlusion_query = TRUE;
+ llvmpipe->dirty |= LP_NEW_OCCLUSION_QUERY;
+ }
}
@@ -149,9 +180,11 @@ llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
lp_setup_end_query(llvmpipe->setup, pq);
- assert(llvmpipe->active_query_count);
- llvmpipe->active_query_count--;
- llvmpipe->dirty |= LP_NEW_QUERY;
+ if (pq->type == PIPE_QUERY_OCCLUSION_COUNTER) {
+ assert(llvmpipe->active_occlusion_query);
+ llvmpipe->active_occlusion_query = FALSE;
+ llvmpipe->dirty |= LP_NEW_OCCLUSION_QUERY;
+ }
}
boolean