From 18452c1e87f79327fbd5f27478028b481ee72a5d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 27 Aug 2010 17:14:49 +0100 Subject: llvmpipe: rework fences and queries --- src/gallium/drivers/llvmpipe/lp_rast.c | 57 ++++++++++++++++------------------ 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'src/gallium/drivers/llvmpipe/lp_rast.c') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index b1c306bbe94..ce6896d16e4 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -568,6 +568,11 @@ lp_rast_tile_end(struct lp_rasterizer_task *task) lp_rast_store_linear_color(task, dummy); } + if (task->query) { + union lp_rast_cmd_arg dummy = {0}; + lp_rast_end_query(task, dummy); + } + /* debug */ memset(task->color_tiles, 0, sizeof(task->color_tiles)); task->depth_tile = NULL; @@ -597,8 +602,26 @@ void lp_rast_begin_query(struct lp_rasterizer_task *task, const union lp_rast_cmd_arg arg) { - /* Reset the per-task counter */ + struct llvmpipe_query *pq = arg.query_obj; + + assert(task->query == NULL); task->vis_counter = 0; + task->query = pq; + pq->count[task->thread_index] = 0; +} + + +/* Much like begin_query, but don't reset the counter to zero. + */ +void +lp_rast_restart_query(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) +{ + struct llvmpipe_query *pq = arg.query_obj; + + assert(task->query == NULL); + task->vis_counter = 0; + task->query = pq; } @@ -611,35 +634,8 @@ void lp_rast_end_query(struct lp_rasterizer_task *task, const union lp_rast_cmd_arg arg) { - struct llvmpipe_query *pq = arg.query_obj; - - pipe_mutex_lock(pq->mutex); - { - /* Accumulate the visible fragment counter from this tile in - * the query object. - */ - pq->count[task->thread_index] += task->vis_counter; - - /* check if this is the last tile in the scene */ - pq->tile_count++; - if (pq->tile_count == pq->num_tiles) { - uint i; - - /* sum the per-thread counters for the query */ - pq->result = 0; - for (i = 0; i < LP_MAX_THREADS; i++) { - pq->result += pq->count[i]; - } - - /* reset counters (in case this query is re-used in the scene) */ - memset(pq->count, 0, sizeof(pq->count)); - - pq->tile_count = 0; - pq->binned = FALSE; - pq->done = TRUE; - } - } - pipe_mutex_unlock(pq->mutex); + task->query->count[task->thread_index] += task->vis_counter; + task->query = NULL; } @@ -697,6 +693,7 @@ static struct { RAST(store_linear_color), RAST(fence), RAST(begin_query), + RAST(restart_query), RAST(end_query), }; -- cgit v1.2.3