summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_clip_tri.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2011-05-16 12:25:18 -0700
committerKenneth Graunke <kenneth@whitecape.org>2011-05-17 23:32:58 -0700
commit5936d96d33e767aa99f6afa92f2a6582ff04df23 (patch)
treeaad8e0136c88b5f574d984ec8ae8e159980894b8 /src/mesa/drivers/dri/i965/brw_clip_tri.c
parent774fb90db3e83d5e7326b7a72e05ce805c306b24 (diff)
downloadexternal_mesa3d-5936d96d33e767aa99f6afa92f2a6582ff04df23.zip
external_mesa3d-5936d96d33e767aa99f6afa92f2a6582ff04df23.tar.gz
external_mesa3d-5936d96d33e767aa99f6afa92f2a6582ff04df23.tar.bz2
i965: Move IF stack handling into the EU abstraction layer/brw_compile.
This hides the IF stack and back-patching of IF/ELSE instructions from each of the code generators, greatly simplifying the interface. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_clip_tri.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_clip_tri.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c
index cb58d1d..0dca05d 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c
@@ -134,7 +134,6 @@ void brw_clip_tri_init_vertices( struct brw_clip_compile *c )
{
struct brw_compile *p = &c->func;
struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
- struct brw_instruction *is_rev;
/* Initial list of indices for incoming vertexes:
*/
@@ -148,21 +147,21 @@ void brw_clip_tri_init_vertices( struct brw_clip_compile *c )
/* XXX: Is there an easier way to do this? Need to reverse every
* second tristrip element: Can ignore sometimes?
*/
- is_rev = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
brw_MOV(p, get_element(c->reg.inlist, 0), brw_address(c->reg.vertex[1]) );
brw_MOV(p, get_element(c->reg.inlist, 1), brw_address(c->reg.vertex[0]) );
if (c->need_direction)
brw_MOV(p, c->reg.dir, brw_imm_f(-1));
}
- is_rev = brw_ELSE(p, is_rev);
+ brw_ELSE(p);
{
brw_MOV(p, get_element(c->reg.inlist, 0), brw_address(c->reg.vertex[0]) );
brw_MOV(p, get_element(c->reg.inlist, 1), brw_address(c->reg.vertex[1]) );
if (c->need_direction)
brw_MOV(p, c->reg.dir, brw_imm_f(1));
}
- brw_ENDIF(p, is_rev);
+ brw_ENDIF(p);
brw_MOV(p, get_element(c->reg.inlist, 2), brw_address(c->reg.vertex[2]) );
brw_MOV(p, brw_vec8_grf(c->reg.outlist.nr, 0), brw_imm_f(0));
@@ -174,7 +173,6 @@ void brw_clip_tri_init_vertices( struct brw_clip_compile *c )
void brw_clip_tri_flat_shade( struct brw_clip_compile *c )
{
struct brw_compile *p = &c->func;
- struct brw_instruction *is_poly, *is_trifan;
struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK));
@@ -184,12 +182,12 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c )
tmp0,
brw_imm_ud(_3DPRIM_POLYGON));
- is_poly = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
brw_clip_copy_colors(c, 1, 0);
brw_clip_copy_colors(c, 2, 0);
}
- is_poly = brw_ELSE(p, is_poly);
+ brw_ELSE(p);
{
if (c->key.pv_first) {
brw_CMP(p,
@@ -197,24 +195,24 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c )
BRW_CONDITIONAL_EQ,
tmp0,
brw_imm_ud(_3DPRIM_TRIFAN));
- is_trifan = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
brw_clip_copy_colors(c, 0, 1);
brw_clip_copy_colors(c, 2, 1);
}
- is_trifan = brw_ELSE(p, is_trifan);
+ brw_ELSE(p);
{
brw_clip_copy_colors(c, 1, 0);
brw_clip_copy_colors(c, 2, 0);
}
- brw_ENDIF(p, is_trifan);
+ brw_ENDIF(p);
}
else {
brw_clip_copy_colors(c, 0, 2);
brw_clip_copy_colors(c, 1, 2);
}
}
- brw_ENDIF(p, is_poly);
+ brw_ENDIF(p);
}
@@ -232,10 +230,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
struct brw_indirect outlist_ptr = brw_indirect(5, 0);
struct brw_indirect freelist_ptr = brw_indirect(6, 0);
struct brw_instruction *plane_loop;
- struct brw_instruction *plane_active;
struct brw_instruction *vertex_loop;
- struct brw_instruction *next_test;
- struct brw_instruction *prev_test;
brw_MOV(p, get_addr_reg(vtxPrev), brw_address(c->reg.vertex[2]) );
brw_MOV(p, get_addr_reg(plane_ptr), brw_clip_plane0_address(c));
@@ -251,7 +246,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
brw_AND(p, vec1(brw_null_reg()), c->reg.planemask, brw_imm_ud(1));
- plane_active = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
/* vtxOut = freelist_ptr++
*/
@@ -275,13 +270,13 @@ void brw_clip_tri( struct brw_clip_compile *c )
/* IS_NEGATIVE(prev) */
brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
brw_DP4(p, vec4(c->reg.dpPrev), deref_4f(vtxPrev, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
- prev_test = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
/* IS_POSITIVE(next)
*/
brw_set_conditionalmod(p, BRW_CONDITIONAL_GE);
brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
- next_test = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
/* Coming back in.
@@ -307,10 +302,10 @@ void brw_clip_tri( struct brw_clip_compile *c )
brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
}
- brw_ENDIF(p, next_test);
+ brw_ENDIF(p);
}
- prev_test = brw_ELSE(p, prev_test);
+ brw_ELSE(p);
{
/* *outlist_ptr++ = vtxPrev;
* nr_verts++;
@@ -323,7 +318,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
*/
brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
- next_test = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
/* Going out of bounds. Avoid division by zero as we
* know dp != dpPrev from DIFFERENT_SIGNS, above.
@@ -349,9 +344,9 @@ void brw_clip_tri( struct brw_clip_compile *c )
brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
}
- brw_ENDIF(p, next_test);
+ brw_ENDIF(p);
}
- brw_ENDIF(p, prev_test);
+ brw_ENDIF(p);
/* vtxPrev = vtx;
* inlist_ptr++;
@@ -377,7 +372,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
brw_MOV(p, get_addr_reg(inlist_ptr), brw_address(c->reg.inlist));
brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
}
- brw_ENDIF(p, plane_active);
+ brw_ENDIF(p);
/* plane_ptr++;
*/
@@ -404,7 +399,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
{
struct brw_compile *p = &c->func;
- struct brw_instruction *loop, *if_insn;
+ struct brw_instruction *loop;
/* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
*/
@@ -414,7 +409,7 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
c->reg.nr_verts,
brw_imm_d(-2));
- if_insn = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
struct brw_indirect v0 = brw_indirect(0, 0);
struct brw_indirect vptr = brw_indirect(1, 0);
@@ -441,7 +436,7 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
brw_clip_emit_vue(c, v0, 0, 1, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_END));
}
- brw_ENDIF(p, if_insn);
+ brw_ENDIF(p);
}
static void do_clip_tri( struct brw_clip_compile *c )
@@ -455,14 +450,13 @@ static void do_clip_tri( struct brw_clip_compile *c )
static void maybe_do_clip_tri( struct brw_clip_compile *c )
{
struct brw_compile *p = &c->func;
- struct brw_instruction *do_clip;
brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, c->reg.planemask, brw_imm_ud(0));
- do_clip = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
do_clip_tri(c);
}
- brw_ENDIF(p, do_clip);
+ brw_ENDIF(p);
}
static void brw_clip_test( struct brw_clip_compile *c )
@@ -481,7 +475,6 @@ static void brw_clip_test( struct brw_clip_compile *c )
struct brw_indirect vt2 = brw_indirect(2, 0);
struct brw_compile *p = &c->func;
- struct brw_instruction *is_outside;
struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
brw_MOV(p, get_addr_reg(vt0), brw_address(c->reg.vertex[0]));
@@ -508,11 +501,11 @@ static void brw_clip_test( struct brw_clip_compile *c )
brw_OR(p, tmp0, tmp0, get_element(t, 2));
brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
brw_AND(p, brw_null_reg(), tmp0, brw_imm_ud(0x1));
- is_outside = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
brw_clip_kill_thread(c);
}
- brw_ENDIF(p, is_outside);
+ brw_ENDIF(p);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
/* some vertices are inside a plane, some are outside,need to clip */
@@ -549,11 +542,11 @@ static void brw_clip_test( struct brw_clip_compile *c )
brw_OR(p, tmp0, tmp0, get_element(t, 2));
brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
brw_AND(p, brw_null_reg(), tmp0, brw_imm_ud(0x1));
- is_outside = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
brw_clip_kill_thread(c);
}
- brw_ENDIF(p, is_outside);
+ brw_ENDIF(p);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
/* some vertices are inside a plane, some are outside,need to clip */
@@ -580,7 +573,6 @@ static void brw_clip_test( struct brw_clip_compile *c )
void brw_emit_tri_clip( struct brw_clip_compile *c )
{
- struct brw_instruction *neg_rhw;
struct brw_compile *p = &c->func;
struct brw_context *brw = p->brw;
brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
@@ -594,11 +586,11 @@ void brw_emit_tri_clip( struct brw_clip_compile *c )
brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
brw_imm_ud(1<<20));
- neg_rhw = brw_IF(p, BRW_EXECUTE_1);
+ brw_IF(p, BRW_EXECUTE_1);
{
brw_clip_test(c);
}
- brw_ENDIF(p, neg_rhw);
+ brw_ENDIF(p);
}
/* Can't push into do_clip_tri because with polygon (or quad)
* flatshading, need to apply the flatshade here because we don't