<div dir="ltr">On 20 August 2013 11:30, Paul Berry <span dir="ltr"><<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
src/mesa/drivers/dri/i965/brw_defines.h | 16 ++++++++++++++++<br>
src/mesa/drivers/dri/i965/brw_shader.cpp | 2 ++<br>
src/mesa/drivers/dri/i965/brw_vec4.h | 3 +++<br>
src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 18 ++++++++++++++++++<br>
4 files changed, 39 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h<br>
index 52009e2..ff270da 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_defines.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_defines.h<br>
@@ -817,6 +817,22 @@ enum opcode {<br>
* for Slot {0,1}" fields in the message header.<br>
*/<br>
GS_OPCODE_THREAD_END,<br>
+<br>
+ /**<br>
+ * Set the "Slot {0,1} Offset" fields of a URB_WRITE message header.<br>
+ *<br>
+ * - dst is the MRF containing the message header.<br>
+ *<br>
+ * - src0.x indicates which portion of the URB should be written to (e.g. a<br>
+ * vertex number)<br>
+ *<br>
+ * - src1 is an immediate multiplier which will be applied to src0<br>
+ * (e.g. the size of a single vertex in the URB).<br>
+ *<br>
+ * Note: the hardware will apply this offset *in addition to* the offset in<br>
+ * vec4_instruction::offset.<br>
+ */<br>
+ GS_OPCODE_SET_WRITE_OFFSET,<br>
};<br>
<br>
#define BRW_PREDICATE_NONE 0<br>
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp<br>
index 689e908..e5d939a 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp<br>
@@ -501,6 +501,8 @@ brw_instruction_name(enum opcode op)<br>
return "gs_urb_write";<br>
case GS_OPCODE_THREAD_END:<br>
return "gs_thread_end";<br>
+ case GS_OPCODE_SET_WRITE_OFFSET:<br>
+ return "set_write_offset";<br>
<br>
default:<br>
/* Yes, this leaks. It's in debug code, it should never occur, and if<br>
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h<br>
index a95f61f..484e578 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_vec4.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h<br>
@@ -630,6 +630,9 @@ private:<br>
void generate_vs_urb_write(vec4_instruction *inst);<br>
void generate_gs_urb_write(vec4_instruction *inst);<br>
void generate_gs_thread_end(vec4_instruction *inst);<br>
+ void generate_gs_set_write_offset(struct brw_reg dst,<br>
+ struct brw_reg src0,<br>
+ struct brw_reg src1);<br>
void generate_oword_dual_block_offsets(struct brw_reg m1,<br>
struct brw_reg index);<br>
void generate_scratch_write(vec4_instruction *inst,<br>
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp<br>
index 19ed358..85ad339 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp<br>
@@ -443,6 +443,20 @@ vec4_generator::generate_gs_thread_end(vec4_instruction *inst)<br>
}<br>
<br>
void<br>
+vec4_generator::generate_gs_set_write_offset(struct brw_reg dst,<br>
+ struct brw_reg src0,<br>
+ struct brw_reg src1)<br>
+{<br>
+ brw_push_insn_state(p);<br>
+ brw_set_access_mode(p, BRW_ALIGN_1);<br>
+ brw_set_mask_control(p, BRW_MASK_DISABLE);<br>
+ brw_MUL(p, suboffset(stride(dst, 2, 2, 1), 3), stride(src0, 8, 2, 4),<br>
+ src1);<br></blockquote><div><br>From our in-person code review yesterday:<br></div><div><br></div><div>Comments are needed to explain why I chose the strides I did. These comments should refer to the PRM documentation of the message header.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ brw_set_access_mode(p, BRW_ALIGN_16);<br>
+ brw_pop_insn_state(p);<br>
+}<br>
+<br>
+void<br>
vec4_generator::generate_oword_dual_block_offsets(struct brw_reg m1,<br>
struct brw_reg index)<br>
{<br>
@@ -918,6 +932,10 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,<br>
generate_gs_thread_end(inst);<br>
break;<br>
<br>
+ case GS_OPCODE_SET_WRITE_OFFSET:<br>
+ generate_gs_set_write_offset(dst, src[0], src[1]);<br>
+ break;<br>
+<br>
case SHADER_OPCODE_SHADER_TIME_ADD:<br>
brw_shader_time_add(p, src[0], SURF_INDEX_VS_SHADER_TIME);<br>
mark_surface_used(SURF_INDEX_VS_SHADER_TIME);<br>
<span class=""><font color="#888888">--<br>
1.8.3.4<br>
<br>
</font></span></blockquote></div><br></div></div>