diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_query.c | 10 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.c | 145 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 11 |
4 files changed, 53 insertions, 116 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c index 76d0231fd1c..ff0e207a54b 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.c +++ b/src/gallium/drivers/llvmpipe/lp_query.c @@ -123,6 +123,16 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); struct llvmpipe_query *pq = llvmpipe_query(q); + /* Check if the query is already in the scene. If so, we need to + * flush the scene now. Real apps shouldn't re-use a query in a + * frame of rendering. + */ + if (pq->fence && !lp_fence_issued(pq->fence)) { + llvmpipe_finish(pipe, __FUNCTION__); + } + + + memset(pq->count, 0, sizeof(pq->count)); lp_setup_begin_query(llvmpipe->setup, pq); llvmpipe->active_query_count++; diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index c022153b438..694b007eb8b 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -327,8 +327,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task, * This is a bin command which is stored in all bins. */ void -lp_rast_store_linear_color( struct lp_rasterizer_task *task, - const union lp_rast_cmd_arg arg) +lp_rast_store_linear_color( struct lp_rasterizer_task *task ) { struct lp_rasterizer *rast = task->rast; struct lp_scene *scene = rast->curr_scene; @@ -490,6 +489,38 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task, /** + * Begin a new occlusion query. + * This is a bin command put in all bins. + * Called per thread. + */ +void +lp_rast_begin_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; +} + + +/** + * End the current occlusion query. + * This is a bin command put in all bins. + * Called per thread. + */ +void +lp_rast_end_query(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) +{ + task->query->count[task->thread_index] += task->vis_counter; + task->query = NULL; +} + + + +/** * Set top row and left column of the tile's pixels to white. For debugging. */ static void @@ -567,10 +598,7 @@ lp_rast_tile_end(struct lp_rasterizer_task *task) (void) outline_subtiles; #endif - { - union lp_rast_cmd_arg dummy = {0}; - lp_rast_store_linear_color(task, dummy); - } + lp_rast_store_linear_color(task); if (task->query) { union lp_rast_cmd_arg dummy = {0}; @@ -584,64 +612,6 @@ lp_rast_tile_end(struct lp_rasterizer_task *task) -/** - * Signal on a fence. This is called during bin execution/rasterization. - * Called per thread. - */ -void -lp_rast_fence(struct lp_rasterizer_task *task, - const union lp_rast_cmd_arg arg) -{ - struct lp_fence *fence = arg.fence; - lp_fence_signal(fence); -} - - -/** - * Begin a new occlusion query. - * This is a bin command put in all bins. - * Called per thread. - */ -void -lp_rast_begin_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; - 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; -} - - -/** - * End the current occlusion query. - * This is a bin command put in all bins. - * Called per thread. - */ -void -lp_rast_end_query(struct lp_rasterizer_task *task, - const union lp_rast_cmd_arg arg) -{ - task->query->count[task->thread_index] += task->vis_counter; - task->query = NULL; -} - /** @@ -672,50 +642,6 @@ rasterize_bin(struct lp_rasterizer_task *task, } -#define RAST(x) { lp_rast_##x, #x } - -static struct { - lp_rast_cmd cmd; - const char *name; -} cmd_names[] = -{ - RAST(clear_color), - RAST(clear_zstencil), - RAST(triangle_1), - RAST(triangle_2), - RAST(triangle_3), - RAST(triangle_4), - RAST(triangle_5), - RAST(triangle_6), - RAST(triangle_7), - RAST(shade_tile), - RAST(shade_tile_opaque), - RAST(store_linear_color), - RAST(fence), - RAST(begin_query), - RAST(restart_query), - RAST(end_query), -}; - -static void -debug_bin( const struct cmd_bin *bin ) -{ - const struct cmd_block *head = bin->commands.head; - int i, j; - - for (i = 0; i < head->count; i++) { - debug_printf("%d: ", i); - for (j = 0; j < Elements(cmd_names); j++) { - if (head->cmd[i] == cmd_names[j].cmd) { - debug_printf("%s\n", cmd_names[j].name); - break; - } - } - if (j == Elements(cmd_names)) - debug_printf("...other\n"); - } - -} /* An empty bin is one that just loads the contents of the tile and * stores them again unchanged. This typically happens when bins have @@ -727,7 +653,6 @@ debug_bin( const struct cmd_bin *bin ) static boolean is_empty_bin( const struct cmd_bin *bin ) { - if (0) debug_bin(bin); return bin->commands.head == NULL; } @@ -766,7 +691,7 @@ rasterize_scene(struct lp_rasterizer_task *task, #endif if (scene->fence) { - lp_rast_fence(task, lp_rast_arg_fence(scene->fence)); + lp_fence_signal(scene->fence); } } diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index f43e714a922..4697054e8d4 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -259,8 +259,7 @@ void lp_rast_shade_tile_opaque( struct lp_rasterizer_task *, void lp_rast_fence( struct lp_rasterizer_task *, const union lp_rast_cmd_arg ); -void lp_rast_store_linear_color( struct lp_rasterizer_task *, - const union lp_rast_cmd_arg ); +void lp_rast_store_linear_color( struct lp_rasterizer_task *); void lp_rast_begin_query(struct lp_rasterizer_task *, diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 476d23fcee5..4cb6166badd 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -155,10 +155,13 @@ begin_binning( struct lp_setup_context *setup ) struct lp_scene *scene = lp_setup_get_current_scene(setup); boolean need_zsload = FALSE; - /* Always create a fence when threads are active: + assert(scene); + assert(scene->fence == NULL); + + /* Always create a fence: */ - if (setup->num_threads) - scene->fence = lp_fence_create(setup->num_threads); + scene->fence = lp_fence_create(MAX2(1, setup->num_threads)); + if (setup->fb.zsbuf && ((setup->clear.flags & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) && @@ -193,7 +196,7 @@ begin_binning( struct lp_setup_context *setup ) if (setup->active_query) { ok = lp_scene_bin_everywhere( scene, - lp_rast_restart_query, + lp_rast_begin_query, lp_rast_arg_query(setup->active_query) ); assert(ok); } |