summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-12-22 10:50:21 -0800
committerEric Anholt <[email protected]>2011-12-23 22:02:09 -0800
commit43e0d775973446e84621fdb56af85f0027ed579c (patch)
tree58e14151ea591f95739472568290029cb19bed2a /src
parentbf2a93db4dfaae0d03a2d6e08c907f6c1c0071ca (diff)
i965/gen7: Make primitives_written counting work.
The code was relying on gs.prog_data's copy of the number-of-verts-per-prim, which segfaulted on gen7 since it doesn't make a GS program. We can easily calculate that value right here. v2: Fix svbi_0_starting_index regression. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 93f27d72cf5..621195d0229 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -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.
@@ -398,14 +422,11 @@ 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;