<div dir="ltr">On 20 May 2013 15:54, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Most of the work in BeginTransformFeedback is only necessary on Gen6.<br>
We may as well just skip it on Gen7+.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
Cc: Eric Anholt <<a href="mailto:eric@anholt.net">eric@anholt.net</a>><br>
Cc: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_context.c | 8 +++---<br>
src/mesa/drivers/dri/i965/brw_context.h | 3 +++<br>
src/mesa/drivers/dri/i965/gen6_sol.c | 41 +++++++++++-------------------<br>
src/mesa/drivers/dri/i965/gen7_sol_state.c | 17 +++++++++++++<br>
4 files changed, 40 insertions(+), 29 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 405580f..56c42ba 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.c<br>
@@ -94,12 +94,14 @@ static void brwInitDriverFunctions(struct intel_screen *screen,<br>
gen4_init_queryobj_functions(functions);<br>
<br>
functions->QuerySamplesForFormat = brw_query_samples_for_format;<br>
- functions->BeginTransformFeedback = brw_begin_transform_feedback;<br>
<br>
- if (screen->gen >= 7)<br>
+ if (screen->gen >= 7) {<br>
+ functions->BeginTransformFeedback = gen7_begin_transform_feedback;<br>
functions->EndTransformFeedback = gen7_end_transform_feedback;<br>
- else<br>
+ } else {<br>
+ functions->BeginTransformFeedback = brw_begin_transform_feedback;<br>
functions->EndTransformFeedback = brw_end_transform_feedback;<br>
+ }<br>
<br>
if (screen->gen >= 6)<br>
functions->GetSamplePosition = gen6_get_sample_position;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index be49078..60b713d 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -1228,6 +1228,9 @@ brw_end_transform_feedback(struct gl_context *ctx,<br>
<br>
/* gen7_sol_state.c */<br>
void<br>
+gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,<br>
+ struct gl_transform_feedback_object *obj);<br>
+void<br>
gen7_end_transform_feedback(struct gl_context *ctx,<br>
struct gl_transform_feedback_object *obj);<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c<br>
index cdd6e74..8e197a1 100644<br>
--- a/src/mesa/drivers/dri/i965/gen6_sol.c<br>
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c<br>
@@ -152,36 +152,25 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,<br>
= _mesa_compute_max_transform_feedback_vertices(xfb_obj,<br>
linked_xfb_info);<br>
<br>
- if (intel->gen == 6) {<br></blockquote><div><br></div><div>Can we replace this with "assert(intel->gen == 6)" just to document that this is a Gen6-only function now?<br><br>With that change, the series is:<br>
<br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- /* Initialize the SVBI 0 register to zero and set the maximum index. */<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); /* starting index */<br>
+ OUT_BATCH(max_index);<br>
+ ADVANCE_BATCH();<br>
+<br>
+ /* Initialize the rest of the unused streams to sane values. Otherwise,<br>
+ * they may indicate that there is no room to write data and prevent<br>
+ * anything from happening at all.<br>
+ */<br>
+ for (int i = 1; i < 4; i++) {<br>
BEGIN_BATCH(4);<br>
OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));<br>
- OUT_BATCH(0); /* SVBI 0 */<br>
+ OUT_BATCH(i << SVB_INDEX_SHIFT);<br>
OUT_BATCH(0); /* starting index */<br>
- OUT_BATCH(max_index);<br>
+ OUT_BATCH(0xffffffff);<br>
ADVANCE_BATCH();<br>
-<br>
- /* Initialize the rest of the unused streams to sane values. Otherwise,<br>
- * they may indicate that there is no room to write data and prevent<br>
- * anything from happening at all.<br>
- */<br>
- for (int i = 1; i < 4; i++) {<br>
- BEGIN_BATCH(4);<br>
- OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));<br>
- OUT_BATCH(i << SVB_INDEX_SHIFT);<br>
- OUT_BATCH(0); /* starting index */<br>
- OUT_BATCH(0xffffffff);<br>
- ADVANCE_BATCH();<br>
- }<br>
- } else if (intel->gen >= 7) {<br>
- /* Reset the SOL buffer offset register. */<br>
- for (int i = 0; i < 4; i++) {<br>
- BEGIN_BATCH(3);<br>
- OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));<br>
- OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));<br>
- OUT_BATCH(0);<br>
- ADVANCE_BATCH();<br>
- }<br>
}<br>
}<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c<br>
index 2c4b7f9..8dfac01 100644<br>
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c<br>
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c<br>
@@ -254,6 +254,23 @@ const struct brw_tracked_state gen7_sol_state = {<br>
};<br>
<br>
void<br>
+gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,<br>
+ struct gl_transform_feedback_object *obj)<br>
+{<br>
+ struct brw_context *brw = brw_context(ctx);<br>
+ struct intel_context *intel = &brw->intel;<br>
+<br>
+ /* Reset the SOL buffer offset register. */<br>
+ for (int i = 0; i < 4; i++) {<br>
+ BEGIN_BATCH(3);<br>
+ OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));<br>
+ OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));<br>
+ OUT_BATCH(0);<br>
+ ADVANCE_BATCH();<br>
+ }<br>
+}<br>
+<br>
+void<br>
gen7_end_transform_feedback(struct gl_context *ctx,<br>
struct gl_transform_feedback_object *obj)<br>
{<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.2.3<br>
<br>
</font></span></blockquote></div><br></div></div>