i965: new VS: Use output_reg[] to find NDC and HPOS registers.
authorPaul Berry <stereotype441@gmail.com>
Tue, 23 Aug 2011 17:17:34 +0000 (10:17 -0700)
committerPaul Berry <stereotype441@gmail.com>
Tue, 6 Sep 2011 18:04:05 +0000 (11:04 -0700)
Previously, emit_vue_header_gen4() used local variables to keep track
of which registers were storing the NDC and HPOS.  This patch uses the
output_reg[] array instead, so that the code that manipulates NDC and
HPOS can be more easily refactored.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 58d8556b8d2ace6b9aff84e8c79c50ee3928e2bc..dfe9c025e823ebd353a571fedc507a11b6c0c75f 100644 (file)
@@ -360,7 +360,7 @@ public:
    /* Regs for vertex results.  Generated at ir_variable visiting time
     * for the ir->location's used.
     */
-   dst_reg output_reg[VERT_RESULT_MAX];
+   dst_reg output_reg[BRW_VERT_RESULT_MAX];
    int uniform_size[MAX_UNIFORMS];
    int uniform_vector_size[MAX_UNIFORMS];
    int uniforms;
index 2393a426ca36e90c303a29c9f752391501f3c7c6..71d8b395d556ed804913bc6713a1837f202bf821 100644 (file)
@@ -1706,6 +1706,7 @@ vec4_visitor::emit_vue_header_gen4(int header_mrf)
 
    /* Build ndc coords, which are (x/w, y/w, z/w, 1/w) */
    dst_reg ndc = dst_reg(this, glsl_type::vec4_type);
+   output_reg[BRW_VERT_RESULT_NDC] = ndc;
 
    current_annotation = "NDC";
    dst_reg ndc_w = ndc;
@@ -1738,7 +1739,8 @@ vec4_visitor::emit_vue_header_gen4(int header_mrf)
       for (i = 0; i < c->key.nr_userclip; i++) {
         vec4_instruction *inst;
 
-        inst = emit(DP4(dst_null_f(), pos, src_reg(c->userplane[i])));
+        inst = emit(DP4(dst_null_f(), src_reg(output_reg[VERT_RESULT_HPOS]),
+                         src_reg(c->userplane[i])));
         inst->conditional_mod = BRW_CONDITIONAL_L;
 
         emit(OR(header1, src_reg(header1), 1u << i));
@@ -1760,11 +1762,11 @@ vec4_visitor::emit_vue_header_gen4(int header_mrf)
         brw_CMP(p,
                 vec8(brw_null_reg()),
                 BRW_CONDITIONAL_L,
-                brw_swizzle1(ndc, 3),
+                brw_swizzle1(output_reg[BRW_VERT_RESULT_NDC], 3),
                 brw_imm_f(0));
 
         brw_OR(p, brw_writemask(header1, WRITEMASK_W), header1, brw_imm_ud(1<<6));
-        brw_MOV(p, ndc, brw_imm_f(0));
+        brw_MOV(p, output_reg[BRW_VERT_RESULT_NDC], brw_imm_f(0));
         brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 #endif
       }
@@ -1786,10 +1788,12 @@ vec4_visitor::emit_vue_header_gen4(int header_mrf)
        * m7 is the first vertex data we fill.
        */
       current_annotation = "NDC";
-      emit(MOV(brw_message_reg(header_mrf++), src_reg(ndc)));
+      emit(MOV(brw_message_reg(header_mrf++),
+               src_reg(output_reg[BRW_VERT_RESULT_NDC])));
 
       current_annotation = "gl_Position";
-      emit(MOV(brw_message_reg(header_mrf++), pos));
+      emit(MOV(brw_message_reg(header_mrf++),
+               src_reg(output_reg[VERT_RESULT_HPOS])));
 
       /* user clip distance. */
       header_mrf += 2;
@@ -1804,10 +1808,12 @@ vec4_visitor::emit_vue_header_gen4(int header_mrf)
        * dword 8-11 (m3) is the first vertex data.
        */
       current_annotation = "NDC";
-      emit(MOV(brw_message_reg(header_mrf++), src_reg(ndc)));
+      emit(MOV(brw_message_reg(header_mrf++),
+               src_reg(output_reg[BRW_VERT_RESULT_NDC])));
 
       current_annotation = "gl_Position";
-      emit(MOV(brw_message_reg(header_mrf++), pos));
+      emit(MOV(brw_message_reg(header_mrf++),
+               src_reg(output_reg[VERT_RESULT_HPOS])));
    }
 
    return header_mrf;