aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_query.c
diff options
context:
space:
mode:
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