mesa: add/update comments in _mesa_copy_buffer_subdata()
[mesa.git] / src / mesa / drivers / dri / i965 / brw_draw.c
index 774a5ca46eeacd0120d57f95d35949fef4347b7e..621195d02292e0bc2d0c43bf9360ea4965bd072f 100644 (file)
@@ -379,6 +379,30 @@ static void brw_postdraw_set_buffers_need_resolve(struct brw_context *brw)
    }
 }
 
+static int
+verts_per_prim(GLenum mode)
+{
+   switch (mode) {
+   case GL_POINTS:
+      return 1;
+   case GL_LINE_STRIP:
+   case GL_LINE_LOOP:
+   case GL_LINES:
+      return 2;
+   case GL_TRIANGLE_STRIP:
+   case GL_TRIANGLE_FAN:
+   case GL_POLYGON:
+   case GL_TRIANGLES:
+   case GL_QUADS:
+   case GL_QUAD_STRIP:
+      return 3;
+   default:
+      _mesa_problem(NULL,
+                   "unknown prim type in transform feedback primitive count");
+      return 0;
+   }
+}
+
 /**
  * Update internal counters based on the the drawing operation described in
  * prim.
@@ -388,7 +412,9 @@ brw_update_primitive_count(struct brw_context *brw,
                            const struct _mesa_prim *prim)
 {
    uint32_t count = count_tessellated_primitives(prim);
-   if (brw->intel.ctx.TransformFeedback.CurrentObject->Active) {
+   brw->sol.primitives_generated += count;
+   if (brw->intel.ctx.TransformFeedback.CurrentObject->Active &&
+       !brw->intel.ctx.TransformFeedback.CurrentObject->Paused) {
       /* Update brw->sol.svbi_0_max_index to reflect the amount by which the
        * hardware is going to increment SVBI 0 when this drawing operation
        * occurs.  This is necessary because the kernel does not (yet) save and
@@ -396,14 +422,14 @@ brw_update_primitive_count(struct brw_context *brw,
        * able to reload SVBI 0 with the correct value in case we have to start
        * a new batch buffer.
        */
-      unsigned svbi_postincrement_value =
-         brw->gs.prog_data->svbi_postincrement_value;
+      unsigned verts = verts_per_prim(prim->mode);
       uint32_t space_avail =
-         (brw->sol.svbi_0_max_index - brw->sol.svbi_0_starting_index)
-         / svbi_postincrement_value;
+         (brw->sol.svbi_0_max_index - brw->sol.svbi_0_starting_index) / verts;
       uint32_t primitives_written = MIN2 (space_avail, count);
-      brw->sol.svbi_0_starting_index +=
-         svbi_postincrement_value * primitives_written;
+      brw->sol.svbi_0_starting_index += verts * primitives_written;
+
+      /* And update the TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query. */
+      brw->sol.primitives_written += primitives_written;
    }
 }