On 16 December 2011 11:09, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</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">
<div class="im">On 12/16/2011 10:44 AM, Paul Berry wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 16 December 2011 10:04, Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a><br></div><div class="im">
<mailto:<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.<u></u>com</a>>> wrote:<br>
<br>
On 15 December 2011 15:20, Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a><br></div><div class="im">
<mailto:<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><u></u>> wrote:<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a><br></div>
<mailto:<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><u></u>><div><div class="h5"><br>
---<br>
src/mesa/drivers/dri/i965/brw_<u></u>context.c | 1 +<br>
src/mesa/drivers/dri/i965/brw_<u></u>context.h | 3 ++<br>
src/mesa/drivers/dri/i965/brw_<u></u>gs_emit.c | 10 ++++++++<br>
src/mesa/drivers/dri/i965/<u></u>gen6_sol.c | 38<br>
++++++++++++++++++++++++++++++<u></u>+<br>
4 files changed, 52 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
b/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
index 7d360b0..fd60853 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
@@ -117,6 +117,7 @@ static void brwInitDriverFunctions( struct<br>
dd_function_table *functions )<br>
brw_init_queryobj_functions(<u></u>functions);<br>
<br>
functions->PrepareExecBegin = brwPrepareExecBegin;<br>
+ functions-><u></u>BeginTransformFeedback =<br>
brw_begin_transform_feedback;<br>
functions-><u></u>EndTransformFeedback = brw_end_transform_feedback;<br>
}<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
b/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
index 8e52488..20623d4 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
@@ -1073,6 +1073,9 @@ brw_fprog_uses_noperspective(<u></u>const struct<br>
gl_fragment_program *fprog);<br>
<br>
/* gen6_sol.c */<br>
void<br>
+brw_begin_transform_feedback(<u></u>struct gl_context *ctx,<br>
+ struct gl_transform_feedback_object<br>
*obj);<br>
+void<br>
brw_end_transform_feedback(<u></u>struct gl_context *ctx,<br>
struct gl_transform_feedback_object<br>
*obj);<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
b/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
index 72d4eca..5dd3734 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_gs_emit.c<br>
@@ -352,6 +352,15 @@ gen6_sol_program(struct brw_gs_compile *c,<br>
struct brw_gs_prog_key *key,<br>
*/<br>
brw_MOV(p, get_element_ud(c->reg.header, 5),<br>
get_element_ud(c->reg.SVBI, 0));<br>
+<br>
+ /* Make sure that the buffers have enough room for all<br>
the vertices. */<br>
+ brw_ADD(p, get_element_ud(c->reg.temp, 0),<br>
+ get_element_ud(c->reg.SVBI, 0),<br>
brw_imm_ud(num_verts));<br>
+ brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L,<br>
+ get_element_ud(c->reg.temp, 0),<br>
+ get_element_ud(c->reg.SVBI, 4));<br>
+ brw_IF(p, BRW_EXECUTE_1);<br>
+<br>
<br>
<br>
Whoops, one other correction. There's an off-by-one error--this should<br>
be BRW_CONDITIONAL_LE.<br>
<br>
For example, let's say we're outputting triangles, the transform<br>
feedback buffer is large enough to hold 6 vertices, and we've output 3<br>
vertices already. In that case num_verts is 3, SVBI.0 is 3, and SVBI.4<br>
is 6. The above logic compares SVBI.0 + num_verts < SVBI.4 (6 < 6), so<br>
it concludes that there isn't room for the second triangle. It should<br>
be computing SVBI.0 + num_verts <= SVBI.4 (6 <= 6), because there is<br>
just barely room for the second triangle.<br>
</div></div></blockquote>
<br>
Do we have piglit test cases for these edge conditions? If we don't, we need them. :)<br></blockquote><div><br>This one was caught by piglit tests that I'm hoping to send to the list today.<br></div></div>