summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_rast.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-06-25 23:27:04 +0200
committerRoland Scheidegger <[email protected]>2013-06-26 23:17:53 +0200
commit08203428800554215657f1ebf19d74328103800e (patch)
tree2ffcdf6192673c70944a0087a114dc7877f49b82 /src/gallium/drivers/llvmpipe/lp_rast.c
parent3dbba95b72262344b82fba018b7c2c1208754cd2 (diff)
llvmpipe: rework query logic
Previously lp_rast_begin_query commands were always inserted into each bin, and re-issued if the scene was restarted, while lp_rast_end_query commands were executed for each still active query at the end of tile rasterization. Also, the ps_invocations and vis_counter were set to zero when the respective command was encountered. This however cannot work for multiple queries of the same type (note that occlusion counter and occlusion predicate while different type were also affected). So, change the logic to always set the ps_invocations and vis_counter to zero at the start of tile rasterization, and then use "start" and "end" per-thread query values when encountering the begin/end query commands instead, which should work for multiple queries of the same type. This also means queries do not have to be reissued in a new scene, however they still need to be finished at end of tile rasterization, so a list of queries still active at the end of a scene needs to be maintained. Also while here don't bin the queries which don't do anything in rasterization. (This change does not actually handle multiple queries of the same type yet, as the list of active queries is just a simple fixed array and setup can still only have one query active per type.) Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_rast.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c56
1 files changed, 18 insertions, 38 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 62a82e30788..871cc50fb4c 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -61,7 +61,6 @@ static void
lp_rast_begin( struct lp_rasterizer *rast,
struct lp_scene *scene )
{
-
rast->curr_scene = scene;
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
@@ -100,6 +99,9 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
task->height = TILE_SIZE + y * TILE_SIZE > task->scene->fb.height ?
task->scene->fb.height - y * TILE_SIZE : TILE_SIZE;
+ task->thread_data.vis_counter = 0;
+ task->ps_invocations = 0;
+
/* reset pointers to color and depth tile(s) */
memset(task->color_tiles, 0, sizeof(task->color_tiles));
task->depth_tile = NULL;
@@ -455,10 +457,10 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
* allocated 4x4 blocks hence need to filter them out here.
*/
if ((x % TILE_SIZE) < task->width && (y % TILE_SIZE) < task->height) {
- if (task->query[PIPE_QUERY_PIPELINE_STATISTICS]) {
- /* not very accurate would need a popcount on the mask */
- task->ps_invocations++;
- }
+ /* not very accurate would need a popcount on the mask */
+ /* always count this not worth bothering? */
+ task->ps_invocations++;
+
/* run shader on 4x4 block */
BEGIN_JIT_CALL(state, task);
variant->jit_function[RAST_EDGE_TEST](&state->jit_context,
@@ -490,28 +492,18 @@ lp_rast_begin_query(struct lp_rasterizer_task *task,
{
struct llvmpipe_query *pq = arg.query_obj;
- assert(task->query[pq->type] == NULL);
-
switch (pq->type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
case PIPE_QUERY_OCCLUSION_PREDICATE:
- task->thread_data.vis_counter = 0;
+ pq->start[task->thread_index] = task->thread_data.vis_counter;
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
- task->ps_invocations = 0;
- break;
- case PIPE_QUERY_PRIMITIVES_GENERATED:
- case PIPE_QUERY_PRIMITIVES_EMITTED:
- case PIPE_QUERY_SO_STATISTICS:
- case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
- case PIPE_QUERY_TIMESTAMP_DISJOINT:
+ pq->start[task->thread_index] = task->ps_invocations;
break;
default:
assert(0);
break;
}
-
- task->query[pq->type] = pq;
}
@@ -525,36 +517,26 @@ lp_rast_end_query(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
{
struct llvmpipe_query *pq = arg.query_obj;
- assert(task->query[pq->type] == pq ||
- pq->type == PIPE_QUERY_TIMESTAMP ||
- pq->type == PIPE_QUERY_GPU_FINISHED);
switch (pq->type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
case PIPE_QUERY_OCCLUSION_PREDICATE:
- pq->count[task->thread_index] += task->thread_data.vis_counter;
+ pq->end[task->thread_index] +=
+ task->thread_data.vis_counter - pq->start[task->thread_index];
+ pq->start[task->thread_index] = 0;
break;
case PIPE_QUERY_TIMESTAMP:
- pq->count[task->thread_index] = os_time_get_nano();
+ pq->end[task->thread_index] = os_time_get_nano();
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
- pq->count[task->thread_index] += task->ps_invocations;
- break;
- case PIPE_QUERY_PRIMITIVES_GENERATED:
- case PIPE_QUERY_PRIMITIVES_EMITTED:
- case PIPE_QUERY_SO_STATISTICS:
- case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
- case PIPE_QUERY_TIMESTAMP_DISJOINT:
- case PIPE_QUERY_GPU_FINISHED:
+ pq->end[task->thread_index] +=
+ task->ps_invocations - pq->start[task->thread_index];
+ pq->start[task->thread_index] = 0;
break;
default:
assert(0);
break;
}
-
- if (task->query[pq->type] == pq) {
- task->query[pq->type] = NULL;
- }
}
@@ -575,10 +557,8 @@ lp_rast_tile_end(struct lp_rasterizer_task *task)
{
unsigned i;
- for (i = 0; i < PIPE_QUERY_TYPES; ++i) {
- if (task->query[i]) {
- lp_rast_end_query(task, lp_rast_arg_query(task->query[i]));
- }
+ for (i = 0; i < task->scene->num_active_queries; ++i) {
+ lp_rast_end_query(task, lp_rast_arg_query(task->scene->active_queries[i]));
}
/* debug */