On 22 December 2011 16:54, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">eric@anholt.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The code was relying on gs.prog_data's copy of the<br>
number-of-verts-per-prim, which segfaulted on gen7 since it doesn't<br>
make a GS program. We can easily calculate that value right here.<br>
---<br>
src/mesa/drivers/dri/i965/brw_draw.c | 33 +++++++++++++++++++++++++++------<br>
1 files changed, 27 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c<br>
index 082bb9a..c116d39 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_draw.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_draw.c<br>
@@ -379,6 +379,30 @@ static void brw_postdraw_set_buffers_need_resolve(struct brw_context *brw)<br>
}<br>
}<br>
<br>
+static int<br>
+verts_per_prim(GLenum mode)<br>
+{<br>
+ switch (mode) {<br>
+ case GL_POINTS:<br>
+ return 1;<br>
+ case GL_LINE_STRIP:<br>
+ case GL_LINE_LOOP:<br>
+ case GL_LINES:<br>
+ return 2;<br>
+ case GL_TRIANGLE_STRIP:<br>
+ case GL_TRIANGLE_FAN:<br>
+ case GL_POLYGON:<br>
+ case GL_TRIANGLES:<br>
+ case GL_QUADS:<br>
+ case GL_QUAD_STRIP:<br>
+ return 3;<br>
+ default:<br>
+ _mesa_problem(NULL,<br>
+ "unknown prim type in transform feedback primitive count");<br>
+ return 0;<br>
+ }<br>
+}<br>
+<br>
/**<br>
* Update internal counters based on the the drawing operation described in<br>
* prim.<br>
@@ -397,14 +421,11 @@ brw_update_primitive_count(struct brw_context *brw,<br>
* able to reload SVBI 0 with the correct value in case we have to start<br>
* a new batch buffer.<br>
*/<br>
- unsigned svbi_postincrement_value =<br>
- brw->gs.prog_data->svbi_postincrement_value;<br>
+ unsigned verts = verts_per_prim(prim->mode);<br>
uint32_t space_avail =<br>
- (brw->sol.svbi_0_max_index - brw->sol.svbi_0_starting_index)<br>
- / svbi_postincrement_value;<br>
+ (brw->sol.svbi_0_max_index - brw->sol.svbi_0_starting_index) / verts;<br>
uint32_t primitives_written = MIN2 (space_avail, count);<br>
- brw->sol.svbi_0_starting_index +=<br>
- svbi_postincrement_value * primitives_written;<br>
+ brw->sol.svbi_0_starting_index += verts;<br></blockquote><div><br>This should be "brw->sol.svbi_0_starting_index += verts * primitives_written".<br><br>With that change, this is<br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div></div>