util: Code generate functions to pack and unpack a single pixel.
[mesa.git] / src / gallium / drivers / softpipe / sp_query.c
index b0d8e01426d185087b2d28b61bbe9b2eb74f51d2..4ef5d9f7b1db3e3172bd272d72b5ce4e5647722d 100644 (file)
 
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
 #include "util/u_memory.h"
 #include "sp_context.h"
 #include "sp_query.h"
+#include "sp_state.h"
 
 struct softpipe_query {
    uint64_t start;
@@ -70,6 +70,8 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
    struct softpipe_query *sq = softpipe_query(q);
    
    sq->start = softpipe->occlusion_count;
+   softpipe->active_query_count++;
+   softpipe->dirty |= SP_NEW_QUERY;
 }
 
 
@@ -79,7 +81,9 @@ 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);
 
+   softpipe->active_query_count--;
    sq->end = softpipe->occlusion_count;
+   softpipe->dirty |= SP_NEW_QUERY;
 }
 
 
@@ -95,6 +99,32 @@ softpipe_get_query_result(struct pipe_context *pipe,
 }
 
 
+/**
+ * Called by rendering function to check rendering is conditional.
+ * \return TRUE if we should render, FALSE if we should skip rendering
+ */
+boolean
+softpipe_check_render_cond(struct softpipe_context *sp)
+{
+   struct pipe_context *pipe = &sp->pipe;
+   boolean b, wait;
+   uint64_t result;
+
+   if (!sp->render_cond_query) {
+      return TRUE;  /* no query predicate, draw normally */
+   }
+
+   wait = (sp->render_cond_mode == PIPE_RENDER_COND_WAIT ||
+           sp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
+
+   b = pipe->get_query_result(pipe, sp->render_cond_query, wait, &result);
+   if (b)
+      return result > 0;
+   else
+      return TRUE;
+}
+
+
 void softpipe_init_query_funcs(struct softpipe_context *softpipe )
 {
    softpipe->pipe.create_query = softpipe_create_query;