On 15 December 2011 15:20, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.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">
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_context.c | 1 +<br>
src/mesa/drivers/dri/i965/brw_context.h | 3 ++<br>
src/mesa/drivers/dri/i965/brw_gs_emit.c | 10 ++++++++<br>
src/mesa/drivers/dri/i965/gen6_sol.c | 38 +++++++++++++++++++++++++++++++<br>
4 files changed, 52 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c<br>
index 7d360b0..fd60853 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.c<br>
@@ -117,6 +117,7 @@ static void brwInitDriverFunctions( struct dd_function_table *functions )<br>
brw_init_queryobj_functions(functions);<br>
<br>
functions->PrepareExecBegin = brwPrepareExecBegin;<br>
+ functions->BeginTransformFeedback = brw_begin_transform_feedback;<br>
functions->EndTransformFeedback = brw_end_transform_feedback;<br>
}<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index 8e52488..20623d4 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -1073,6 +1073,9 @@ brw_fprog_uses_noperspective(const struct gl_fragment_program *fprog);<br>
<br>
/* gen6_sol.c */<br>
void<br>
+brw_begin_transform_feedback(struct gl_context *ctx,<br>
+ struct gl_transform_feedback_object *obj);<br></blockquote><div><br>Argh, I fail at code review. I found another problem: this function is missing the argument "GLenum mode", which should come after "gl_context ctx", causing the function pointer assignment in brw_context.c to generate a warning. It's a benign warning, because the function only uses the ctx argument, and the calling conventions work out so that it gets passed in the same way regardless of whether mode is present. But for portability we should make the function signatures match.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+void<br>
brw_end_transform_feedback(struct gl_context *ctx,<br>
struct gl_transform_feedback_object *obj);<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c<br>
index 72d4eca..5dd3734 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_gs_emit.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c<br>
@@ -352,6 +352,15 @@ gen6_sol_program(struct brw_gs_compile *c, 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 the vertices. */<br>
+ brw_ADD(p, get_element_ud(c->reg.temp, 0),<br>
+ get_element_ud(c->reg.SVBI, 0), 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>
/* For each vertex, generate code to output each varying using the<br>
* appropriate binding table entry.<br>
*/<br>
@@ -392,6 +401,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key,<br>
get_element_ud(c->reg.header, 5), brw_imm_ud(1));<br>
}<br>
}<br>
+ brw_ENDIF(p);<br>
<br>
/* Now, reinitialize the header register from R0 to restore the parts of<br>
* the register that we overwrote while streaming out transform feedback<br>
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c<br>
index b11bce2..56d4a6a 100644<br>
--- a/src/mesa/drivers/dri/i965/gen6_sol.c<br>
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c<br>
@@ -26,6 +26,7 @@<br>
* Code to initialize the binding table entries used by transform feedback.<br>
*/<br>
<br>
+#include "main/macros.h"<br>
#include "brw_context.h"<br>
#include "intel_buffer_objects.h"<br>
#include "intel_batchbuffer.h"<br>
@@ -101,6 +102,43 @@ const struct brw_tracked_state gen6_sol_surface = {<br>
};<br>
<br>
void<br>
+brw_begin_transform_feedback(struct gl_context *ctx,<br>
+ struct gl_transform_feedback_object *obj)<br>
+{<br>
+ struct intel_context *intel = intel_context(ctx);<br>
+ const struct gl_shader_program *vs_prog =<br>
+ ctx->Shader.CurrentVertexProgram;<br>
+ const struct gl_transform_feedback_info *linked_xfb_info =<br>
+ &vs_prog->LinkedTransformFeedback;<br>
+ struct gl_transform_feedback_object *xfb_obj =<br>
+ ctx->TransformFeedback.CurrentObject;<br>
+<br>
+ unsigned max_index = 0xffffffff;<br>
+<br>
+ /* Compute the maximum number of vertices that we can write without<br>
+ * overflowing any of the buffers currently being used for feedback.<br>
+ */<br>
+ for (int i = 0; i < MAX_FEEDBACK_ATTRIBS; ++i) {<br>
+ unsigned stride = linked_xfb_info->BufferStride[i];<br>
+<br>
+ /* Skip any inactive buffers, which have a stride of 0. */<br>
+ if (stride == 0)<br>
+ continue;<br>
+<br>
+ unsigned max_for_this_buffer = xfb_obj->Size[i] / (4 * stride);<br>
+ max_index = MIN2(max_index, max_for_this_buffer);<br>
+ }<br>
+<br>
+ /* Initialize the SVBI 0 register to zero and set the maximum index. */<br>
+ BEGIN_BATCH(4);<br>
+ OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));<br>
+ OUT_BATCH(0); /* SVBI 0 */<br>
+ OUT_BATCH(0);<br>
+ OUT_BATCH(max_index);<br>
+ ADVANCE_BATCH();<br>
+}<br>
+<br>
+void<br>
brw_end_transform_feedback(struct gl_context *ctx,<br>
struct gl_transform_feedback_object *obj)<br>
{<br>
<span><font color="#888888">--<br>
1.7.7.3<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>