diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-09-11 16:01:17 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-09-11 16:01:17 -0600 |
commit | 09fbb3837b6aa5dfc6c94f41ab5443820177c569 (patch) | |
tree | 760ff57ac6a5fc503c41e9eb783fb82cb5a428e6 /src/mesa/pipe/softpipe | |
parent | 5620d66e362acff99dbc748feec1da1e0f997288 (diff) |
Implement query object interface.
This replaces the temporary occlusion counter functions we had before.
Added new ctx->Driver.WaitQuery() function which should block until the result is ready.
Sketch out some code for vertex transformation feedback counters.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 35 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.h | 7 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad_occlusion.c | 10 |
3 files changed, 39 insertions, 13 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 26453d9785..92357808e2 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -195,19 +195,37 @@ static void softpipe_destroy( struct pipe_context *pipe ) } -static void softpipe_reset_occlusion_counter(struct pipe_context *pipe) +static void +softpipe_begin_query(struct pipe_context *pipe, struct pipe_query_object *q) { struct softpipe_context *softpipe = softpipe_context( pipe ); - softpipe->occlusion_counter = 0; + assert(q->type < PIPE_QUERY_TYPES); + assert(!softpipe->queries[q->type]); + softpipe->queries[q->type] = q; } -/* XXX pipe param should be const */ -static unsigned softpipe_get_occlusion_counter(struct pipe_context *pipe) + +static void +softpipe_end_query(struct pipe_context *pipe, struct pipe_query_object *q) { struct softpipe_context *softpipe = softpipe_context( pipe ); - return softpipe->occlusion_counter; + assert(q->type < PIPE_QUERY_TYPES); + assert(softpipe->queries[q->type]); + q->ready = 1; /* software rendering is synchronous */ + softpipe->queries[q->type] = NULL; +} + + +static void +softpipe_wait_query(struct pipe_context *pipe, struct pipe_query_object *q) +{ + /* Should never get here since we indicated that the result was + * ready in softpipe_end_query(). + */ + assert(0); } + static const char *softpipe_get_name( struct pipe_context *pipe ) { return "softpipe"; @@ -260,8 +278,11 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.clear = softpipe_clear; softpipe->pipe.flush = softpipe_flush; - softpipe->pipe.reset_occlusion_counter = softpipe_reset_occlusion_counter; - softpipe->pipe.get_occlusion_counter = softpipe_get_occlusion_counter; + + softpipe->pipe.begin_query = softpipe_begin_query; + softpipe->pipe.end_query = softpipe_end_query; + softpipe->pipe.wait_query = softpipe_wait_query; + softpipe->pipe.get_name = softpipe_get_name; softpipe->pipe.get_vendor = softpipe_get_vendor; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 2a6b932523..13d1143c89 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -94,6 +94,11 @@ struct softpipe_context { unsigned dirty; /* + * Active queries + */ + struct pipe_query_object *queries[PIPE_QUERY_TYPES]; + + /* * Mapped vertex buffers */ ubyte *mapped_vbuffer[PIPE_ATTRIB_MAX]; @@ -120,8 +125,6 @@ struct softpipe_context { /** Derived from scissor and surface bounds: */ struct pipe_scissor_state cliprect; - unsigned occlusion_counter; - unsigned line_stipple_counter; /** Software quad rendering pipeline */ diff --git a/src/mesa/pipe/softpipe/sp_quad_occlusion.c b/src/mesa/pipe/softpipe/sp_quad_occlusion.c index 6b094a5bef..4f178f0557 100644 --- a/src/mesa/pipe/softpipe/sp_quad_occlusion.c +++ b/src/mesa/pipe/softpipe/sp_quad_occlusion.c @@ -44,11 +44,13 @@ static void occlusion_count_quad(struct quad_stage *qs, struct quad_header *quad) { struct softpipe_context *softpipe = qs->softpipe; + struct pipe_query_object *occ + = softpipe->queries[PIPE_QUERY_OCCLUSION_COUNTER]; - softpipe->occlusion_counter += (quad->mask ) & 1; - softpipe->occlusion_counter += (quad->mask >> 1) & 1; - softpipe->occlusion_counter += (quad->mask >> 2) & 1; - softpipe->occlusion_counter += (quad->mask >> 3) & 1; + occ->count += (quad->mask ) & 1; + occ->count += (quad->mask >> 1) & 1; + occ->count += (quad->mask >> 2) & 1; + occ->count += (quad->mask >> 3) & 1; if (quad->mask) qs->next->run(qs->next, quad); |