i965: fix transform feedback with primitive restart
authorJordan Justen <jordan.l.justen@intel.com>
Thu, 28 Jun 2012 17:32:09 +0000 (10:32 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Mon, 2 Jul 2012 18:42:48 +0000 (11:42 -0700)
When querying GL_PRIMITIVES_GENERATED, if primitive restart
is also used, then take the software primitive restart
path so GL_PRIMITIVES_GENERATED is returned correctly.

GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN is also updated
since it will also affected by the same issue.

As noted in brw_primitive_restart.c, with further work we
should be able to move this situation back to a hardware
handled path.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_primitive_restart.c
src/mesa/drivers/dri/i965/brw_queryobj.c

index 2c9f5adc771f6da330e892c500d983b1a63627aa..8d519e762b652006570258397ea14f3bd5f7806c 100644 (file)
@@ -1038,6 +1038,8 @@ struct brw_context
       uint32_t offset_0_batch_start;
       uint32_t primitives_generated;
       uint32_t primitives_written;
+      bool counting_primitives_generated;
+      bool counting_primitives_written;
    } sol;
 
    uint32_t render_target_format[MESA_FORMAT_COUNT];
index 962ff18fede9f14faa9c2906efdcb71cbc836d1b..02deba4fbb60c5b100b59a0ba26443395093d927 100644 (file)
@@ -69,6 +69,18 @@ can_cut_index_handle_prims(struct gl_context *ctx,
                            GLuint nr_prims,
                            const struct _mesa_index_buffer *ib)
 {
+   struct brw_context *brw = brw_context(ctx);
+
+   if (brw->sol.counting_primitives_generated ||
+       brw->sol.counting_primitives_written) {
+      /* Counting primitives generated in hardware is not currently
+       * supported, so take the software path. We need to investigate
+       * the *_PRIMITIVES_COUNT registers to allow this to be handled
+       * entirely in hardware.
+       */
+      return false;
+   }
+
    if (!can_cut_index_handle_restart_index(ctx, ib)) {
       /* The primitive restart index can't be handled, so take
        * the software path
index 72b83f457086792c520c97e2121cb31710d3133e..240fe32bdc5b5fcf93bda07e4e09df3741ae59c3 100644 (file)
@@ -171,6 +171,7 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q)
        * it a software counter.  So just reset the counter.
        */
       brw->sol.primitives_generated = 0;
+      brw->sol.counting_primitives_generated = true;
       break;
 
    case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
@@ -178,6 +179,7 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q)
        * it a software counter.  So just reset the counter.
        */
       brw->sol.primitives_written = 0;
+      brw->sol.counting_primitives_written = true;
       break;
 
    default:
@@ -249,6 +251,7 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q)
        * the query object.
        */
       query->Base.Result = brw->sol.primitives_generated;
+      brw->sol.counting_primitives_generated = false;
 
       /* And set brw->query.obj to NULL so that this query won't try to wait
        * for any rendering to complete.
@@ -262,6 +265,7 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q)
        * the query object.
        */
       query->Base.Result = brw->sol.primitives_written;
+      brw->sol.counting_primitives_written = false;
 
       /* And set brw->query.obj to NULL so that this query won't try to wait
        * for any rendering to complete.