summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/failover/fo_context.c4
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c21
-rw-r--r--src/mesa/pipe/p_context.h9
-rw-r--r--src/mesa/pipe/p_defines.h8
-rw-r--r--src/mesa/pipe/p_state.h10
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c35
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h7
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_occlusion.c10
8 files changed, 83 insertions, 21 deletions
diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c
index b88f1b466cb..c58fc9cedcd 100644
--- a/src/mesa/pipe/failover/fo_context.c
+++ b/src/mesa/pipe/failover/fo_context.c
@@ -129,8 +129,8 @@ struct pipe_context *failover_create( struct pipe_context *hw,
* at this point - if the hardware doesn't support it, don't
* advertise it to the application.
*/
- failover->pipe.reset_occlusion_counter = hw->reset_occlusion_counter;
- failover->pipe.get_occlusion_counter = hw->get_occlusion_counter;
+ failover->pipe.begin_query = hw->begin_query;
+ failover->pipe.end_query = hw->end_query;
failover_init_state_functions( failover );
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index f4121419f79..6e48b3bd03b 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -149,6 +149,22 @@ 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,
struct pipe_buffer_handle *indexBuffer,
unsigned indexSize,
@@ -257,8 +273,9 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->pipe.supported_formats = i915_supported_formats;
i915->pipe.max_texture_size = i915_max_texture_size;
i915->pipe.clear = i915_clear;
- i915->pipe.reset_occlusion_counter = NULL; /* no support */
- i915->pipe.get_occlusion_counter = NULL;
+
+ 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 27a1128365e..dafbef410eb 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -75,11 +75,12 @@ struct pipe_context {
void (*clear)(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue);
- /** occlusion counting (XXX this may be temporary - we should probably
- * have generic query objects with begin/end methods)
+ /**
+ * Query objects
*/
- void (*reset_occlusion_counter)(struct pipe_context *pipe);
- unsigned (*get_occlusion_counter)(struct pipe_context *pipe);
+ 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);
/*
* State functions
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index c1164c5c08b..b3ee8905769 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -299,4 +299,12 @@
#define PIPE_PRIM_POLYGON 9
+/**
+ * Query object types
+ */
+#define PIPE_QUERY_OCCLUSION_COUNTER 0
+#define PIPE_QUERY_PRIMITIVES_GENERATED 1
+#define PIPE_QUERY_PRIMITIVES_EMITTED 2
+#define PIPE_QUERY_TYPES 3
+
#endif
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index ccd40d39e66..b994d17ea9e 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -381,4 +381,14 @@ struct pipe_feedback_buffer {
};
+/**
+ * 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/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 26453d97852..92357808e29 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 2a6b932523a..13d1143c890 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 6b094a5befb..4f178f0557e 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);