diff options
author | Keith Whitwell <[email protected]> | 2007-12-11 17:10:26 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2007-12-11 17:10:48 +0000 |
commit | 13699463a33c1adf44005125c488e886e074a05b (patch) | |
tree | cb9e0b85f96fd931f87d3b1fc813723013d2a2b7 /src/mesa/pipe | |
parent | b247ab036327d66b8b9b1aff2dbcf4520ed0284f (diff) |
Rework gallium and mesa queries a little.
Add a 'CheckQuery()' driver callback to mesa to check query completion.
Make pipe_query an opaque type.
Rework softpipe queries, support overlapping occlusion queries.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.c | 17 | ||||
-rw-r--r-- | src/mesa/pipe/p_context.h | 20 | ||||
-rw-r--r-- | src/mesa/pipe/p_state.h | 10 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/Makefile | 1 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 36 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.h | 6 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad_occlusion.c | 16 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_query.c | 107 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_query.h | 39 |
9 files changed, 179 insertions, 73 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index d2bbeea16ab..a08cf5087ee 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -170,21 +170,6 @@ static void i915_destroy( struct pipe_context *pipe ) -static void -i915_begin_query(struct pipe_context *pipe, struct pipe_query_object *q) -{ - /* should never be called */ - assert(0); -} - - -static void -i915_end_query(struct pipe_context *pipe, struct pipe_query_object *q) -{ - /* should never be called */ - assert(0); -} - static boolean i915_draw_elements( struct pipe_context *pipe, @@ -298,8 +283,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys, i915->pipe.clear = i915_clear; - i915->pipe.begin_query = i915_begin_query; - i915->pipe.end_query = i915_end_query; i915->pipe.draw_arrays = i915_draw_arrays; i915->pipe.draw_elements = i915_draw_elements; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 83b4ab07fbf..92ca7dd8e3c 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -29,9 +29,13 @@ #define PIPE_CONTEXT_H #include "p_state.h" +#include <stdint.h> struct pipe_state_cache; +/* Opaque driver handles: + */ +struct pipe_query; /** * Gallium rendering context. Basically: @@ -81,9 +85,19 @@ struct pipe_context { /** * Query objects */ - void (*begin_query)(struct pipe_context *pipe, struct pipe_query_object *q); - void (*end_query)(struct pipe_context *pipe, struct pipe_query_object *q); - void (*wait_query)(struct pipe_context *pipe, struct pipe_query_object *q); + struct pipe_query *(*create_query)( struct pipe_context *pipe, + unsigned query_type ); + + void (*destroy_query)(struct pipe_context *pipe, + struct pipe_query *q); + + void (*begin_query)(struct pipe_context *pipe, struct pipe_query *q); + void (*end_query)(struct pipe_context *pipe, struct pipe_query *q); + + boolean (*get_query_result)(struct pipe_context *pipe, + struct pipe_query *q, + boolean wait, + uint64_t *result); /* * State functions diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index a571071ea99..109913b040c 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -317,14 +317,4 @@ struct pipe_vertex_element -/** - * Hardware queries (occlusion, transform feedback, timing, etc) - */ -struct pipe_query_object { - uint type:3; /**< PIPE_QUERY_x */ - uint ready:1; /**< is result ready? */ - uint64 count; -}; - - #endif diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile index 5e6886a37e1..31438a882e6 100644 --- a/src/mesa/pipe/softpipe/Makefile +++ b/src/mesa/pipe/softpipe/Makefile @@ -7,6 +7,7 @@ LIBNAME = softpipe DRIVER_SOURCES = \ sp_clear.c \ sp_flush.c \ + sp_query.c \ sp_context.c \ sp_draw_arrays.c \ sp_prim_setup.c \ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 7d243aaabb5..107c8f8597a 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -42,6 +42,7 @@ #include "sp_tile_cache.h" #include "sp_texture.h" #include "sp_winsys.h" +#include "sp_query.h" @@ -150,37 +151,6 @@ static void softpipe_destroy( 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 ); - assert(q->type < PIPE_QUERY_TYPES); - assert(!softpipe->queries[q->type]); - softpipe->queries[q->type] = q; -} - - -static void -softpipe_end_query(struct pipe_context *pipe, struct pipe_query_object *q) -{ - struct softpipe_context *softpipe = softpipe_context( pipe ); - 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"; @@ -320,9 +290,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.clear = softpipe_clear; softpipe->pipe.flush = softpipe_flush; - softpipe->pipe.begin_query = softpipe_begin_query; - softpipe->pipe.end_query = softpipe_end_query; - softpipe->pipe.wait_query = softpipe_wait_query; + softpipe_init_query_funcs( softpipe ); /* textures */ softpipe->pipe.texture_create = softpipe_texture_create; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index afdd0ec88ef..2c038de5f7b 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -93,10 +93,10 @@ struct softpipe_context { struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; unsigned dirty; - /* - * Active queries + /* Counter for occlusion queries. Note this supports overlapping + * queries. */ - struct pipe_query_object *queries[PIPE_QUERY_TYPES]; + uint64_t occlusion_count; /* * Mapped vertex buffers diff --git a/src/mesa/pipe/softpipe/sp_quad_occlusion.c b/src/mesa/pipe/softpipe/sp_quad_occlusion.c index d65fdbdab72..54254df1f11 100644 --- a/src/mesa/pipe/softpipe/sp_quad_occlusion.c +++ b/src/mesa/pipe/softpipe/sp_quad_occlusion.c @@ -39,18 +39,22 @@ #include "sp_surface.h" #include "sp_quad.h" +static unsigned count_bits( unsigned val ) +{ + unsigned i; + + for (i = 0; val ; val >>= 1) + i += (val & 1); + + return i; +} 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]; - occ->count += (quad->mask ) & 1; - occ->count += (quad->mask >> 1) & 1; - occ->count += (quad->mask >> 2) & 1; - occ->count += (quad->mask >> 3) & 1; + softpipe->occlusion_count += count_bits(quad->mask); qs->next->run(qs->next, quad); } diff --git a/src/mesa/pipe/softpipe/sp_query.c b/src/mesa/pipe/softpipe/sp_query.c new file mode 100644 index 00000000000..bf753dad98f --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_query.c @@ -0,0 +1,107 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Author: + * Keith Whitwell <[email protected]> + */ + +#include "pipe/draw/draw_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_inlines.h" +#include "pipe/p_util.h" +#include "sp_context.h" +#include "sp_query.h" + +struct softpipe_query { + uint64_t start; + uint64_t end; +}; + + +static struct softpipe_query *softpipe_query( struct pipe_query *p ) +{ + return (struct softpipe_query *)p; +} + +static struct pipe_query * +softpipe_create_query(struct pipe_context *pipe, + unsigned type) +{ + assert(type == PIPE_QUERY_OCCLUSION_COUNTER); + return (struct pipe_query *)CALLOC_STRUCT( softpipe_query ); +} + + +static void +softpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q) +{ + FREE(q); +} + + +static void +softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) +{ + struct softpipe_context *softpipe = softpipe_context( pipe ); + struct softpipe_query *sq = softpipe_query(q); + + sq->start = softpipe->occlusion_count; +} + + +static void +softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) +{ + struct softpipe_context *softpipe = softpipe_context( pipe ); + struct softpipe_query *sq = softpipe_query(q); + + sq->end = softpipe->occlusion_count; +} + + +static boolean +softpipe_get_query_result(struct pipe_context *pipe, + struct pipe_query *q, + boolean wait, + uint64_t *result ) +{ + struct softpipe_query *sq = softpipe_query(q); + *result = sq->end - sq->start; + return TRUE; +} + + +void softpipe_init_query_funcs(struct softpipe_context *softpipe ) +{ + softpipe->pipe.create_query = softpipe_create_query; + softpipe->pipe.destroy_query = softpipe_destroy_query; + softpipe->pipe.begin_query = softpipe_begin_query; + softpipe->pipe.end_query = softpipe_end_query; + softpipe->pipe.get_query_result = softpipe_get_query_result; +} + + diff --git a/src/mesa/pipe/softpipe/sp_query.h b/src/mesa/pipe/softpipe/sp_query.h new file mode 100644 index 00000000000..05060a45759 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_query.h @@ -0,0 +1,39 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Author: + * Keith Whitwell + */ + +#ifndef SP_QUERY_H +#define SP_QUERY_H + +struct softpipe_context; +extern void softpipe_init_query_funcs(struct softpipe_context * ); + + +#endif /* SP_QUERY_H */ |