brw_clip_tri.c File Reference

Include dependency graph for brw_clip_tri.c:

Go to the source code of this file.

Functions

static struct brw_reg get_tmp (struct brw_clip_compile *c)
static void release_tmps (struct brw_clip_compile *c)
void brw_clip_tri_alloc_regs (struct brw_clip_compile *c, unsigned nr_verts)
void brw_clip_tri_init_vertices (struct brw_clip_compile *c)
void brw_clip_tri_flat_shade (struct brw_clip_compile *c)
void brw_clip_tri (struct brw_clip_compile *c)
void brw_clip_tri_emit_polygon (struct brw_clip_compile *c)
static void do_clip_tri (struct brw_clip_compile *c)
static void maybe_do_clip_tri (struct brw_clip_compile *c)
static void brw_clip_test (struct brw_clip_compile *c)
void brw_emit_tri_clip (struct brw_clip_compile *c)


Function Documentation

static void brw_clip_test ( struct brw_clip_compile c  )  [static]

Definition at line 449 of file brw_clip_tri.c.

References brw_address(), brw_CMP(), BRW_CONDITIONAL_L, BRW_CONDITIONAL_LE, BRW_CONDITIONAL_NZ, brw_imm_ud(), brw_indirect(), brw_MOV(), brw_null_reg(), brw_OR(), BRW_PREDICATE_NONE, BRW_REGISTER_TYPE_UD, brw_set_predicate_control(), brw_XOR(), deref_4f(), brw_clip_compile::func, get_addr_reg(), get_element(), get_tmp(), negate(), brw_clip_compile::offset, brw_clip_compile::planemask, brw_clip_compile::reg, release_tmps(), retype(), and brw_clip_compile::vertex.

00450 {
00451 #if 0
00452     struct brw_reg t = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
00453     struct brw_reg t1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
00454     struct brw_reg t2 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
00455     struct brw_reg t3 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
00456 
00457     struct brw_reg v0 = get_tmp(c);
00458     struct brw_reg v1 = get_tmp(c);
00459     struct brw_reg v2 = get_tmp(c);
00460 
00461     struct brw_indirect vt0 = brw_indirect(0, 0);
00462     struct brw_indirect vt1 = brw_indirect(1, 0);
00463     struct brw_indirect vt2 = brw_indirect(2, 0);
00464 
00465     struct brw_compile *p = &c->func;
00466 
00467     brw_MOV(p, get_addr_reg(vt0), brw_address(c->reg.vertex[0]));
00468     brw_MOV(p, get_addr_reg(vt1), brw_address(c->reg.vertex[1]));
00469     brw_MOV(p, get_addr_reg(vt2), brw_address(c->reg.vertex[2]));
00470     brw_MOV(p, v0, deref_4f(vt0, c->offset[VERT_RESULT_HPOS]));
00471     brw_MOV(p, v1, deref_4f(vt1, c->offset[VERT_RESULT_HPOS]));
00472     brw_MOV(p, v2, deref_4f(vt2, c->offset[VERT_RESULT_HPOS]));
00473 
00474     /* test nearz, xmin, ymin plane */
00475     brw_CMP(p, t1, BRW_CONDITIONAL_LE, negate(v0), get_element(v0, 3));
00476     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00477     brw_CMP(p, t2, BRW_CONDITIONAL_LE, negate(v1), get_element(v1, 3));
00478     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00479     brw_CMP(p, t3, BRW_CONDITIONAL_LE, negate(v2), get_element(v2, 3));
00480     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00481     brw_XOR(p, t, t1, t2);
00482     brw_XOR(p, t1, t2, t3);
00483     brw_OR(p, t, t, t1);
00484 
00485     brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
00486             get_element(t, 0), brw_imm_ud(0));
00487     brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<5)));
00488     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00489     brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
00490             get_element(t, 1), brw_imm_ud(0));
00491     brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<3)));
00492     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00493     brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
00494             get_element(t, 2), brw_imm_ud(0));
00495     brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<1)));
00496     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00497 
00498     /* test farz, xmax, ymax plane */
00499     brw_CMP(p, t1, BRW_CONDITIONAL_L, v0, get_element(v0, 3));
00500     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00501     brw_CMP(p, t2, BRW_CONDITIONAL_L, v1, get_element(v1, 3));
00502     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00503     brw_CMP(p, t3, BRW_CONDITIONAL_L, v2, get_element(v2, 3));
00504     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00505 
00506     brw_XOR(p, t, t1, t2);
00507     brw_XOR(p, t1, t2, t3);
00508     brw_OR(p, t, t, t1);
00509 
00510     brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
00511             get_element(t, 0), brw_imm_ud(0));
00512     brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<4)));
00513     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00514     brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
00515             get_element(t, 1), brw_imm_ud(0));
00516     brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<2)));
00517     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00518     brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
00519             get_element(t, 2), brw_imm_ud(0));
00520     brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<0)));
00521     brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00522 
00523     release_tmps(c);
00524 #else
00525          #warning "disabled"
00526 #endif
00527 }

void brw_clip_tri ( struct brw_clip_compile c  ) 

Definition at line 201 of file brw_clip_tri.c.

References brw_ADD(), brw_address(), brw_AND(), brw_clip_interp_vertex(), brw_clip_plane0_address(), brw_clip_plane_stride(), brw_CMP(), BRW_CONDITIONAL_EQ, BRW_CONDITIONAL_GE, BRW_CONDITIONAL_L, BRW_CONDITIONAL_NZ, brw_DO(), brw_DP4(), brw_ELSE(), brw_ENDIF(), BRW_EXECUTE_1, brw_IF(), brw_imm_d(), brw_imm_ud(), brw_imm_uw(), brw_imm_w(), brw_indirect(), brw_math_invert(), brw_MOV(), brw_MUL(), brw_null_reg(), BRW_PREDICATE_NONE, brw_set_conditionalmod(), brw_set_predicate_control(), brw_SHR(), brw_vec8_grf(), brw_WHILE(), deref_1uw(), deref_4b(), deref_4f(), brw_clip_compile::dp, brw_clip_compile::dpPrev, FALSE, brw_clip_compile::func, get_addr_reg(), brw_clip_compile::inlist, brw_clip_compile::key, brw_clip_compile::loopcount, negate(), brw_reg::nr, brw_clip_compile::nr_regs, brw_clip_prog_key::nr_userclip, brw_clip_compile::nr_verts, brw_clip_compile::offset, brw_clip_compile::outlist, brw_clip_compile::plane_equation, brw_clip_compile::planemask, brw_clip_compile::reg, REG_SIZE, brw_clip_compile::t, TRUE, vec1(), vec4(), and brw_clip_compile::vertex.

00202 {
00203 #if 0
00204    struct brw_compile *p = &c->func;
00205    struct brw_indirect vtx = brw_indirect(0, 0);
00206    struct brw_indirect vtxPrev = brw_indirect(1, 0);
00207    struct brw_indirect vtxOut = brw_indirect(2, 0);
00208    struct brw_indirect plane_ptr = brw_indirect(3, 0);
00209    struct brw_indirect inlist_ptr = brw_indirect(4, 0);
00210    struct brw_indirect outlist_ptr = brw_indirect(5, 0);
00211    struct brw_indirect freelist_ptr = brw_indirect(6, 0);
00212    struct brw_instruction *plane_loop;
00213    struct brw_instruction *plane_active;
00214    struct brw_instruction *vertex_loop;
00215    struct brw_instruction *next_test;
00216    struct brw_instruction *prev_test;
00217 
00218    brw_MOV(p, get_addr_reg(vtxPrev),     brw_address(c->reg.vertex[2]) );
00219    brw_MOV(p, get_addr_reg(plane_ptr),   brw_clip_plane0_address(c));
00220    brw_MOV(p, get_addr_reg(inlist_ptr),  brw_address(c->reg.inlist));
00221    brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
00222 
00223    brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
00224 
00225    plane_loop = brw_DO(p, BRW_EXECUTE_1);
00226    {
00227       /* if (planemask & 1)
00228        */
00229       brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
00230       brw_AND(p, vec1(brw_null_reg()), c->reg.planemask, brw_imm_ud(1));
00231 
00232       plane_active = brw_IF(p, BRW_EXECUTE_1);
00233       {
00234          /* vtxOut = freelist_ptr++
00235           */
00236          brw_MOV(p, get_addr_reg(vtxOut),       get_addr_reg(freelist_ptr) );
00237          brw_ADD(p, get_addr_reg(freelist_ptr), get_addr_reg(freelist_ptr), brw_imm_uw(c->nr_regs * REG_SIZE));
00238 
00239          if (c->key.nr_userclip)
00240             brw_MOV(p, c->reg.plane_equation, deref_4f(plane_ptr, 0));
00241          else
00242             brw_MOV(p, c->reg.plane_equation, deref_4b(plane_ptr, 0));
00243 
00244          brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
00245          brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
00246 
00247          vertex_loop = brw_DO(p, BRW_EXECUTE_1);
00248          {
00249             /* vtx = *input_ptr;
00250              */
00251             brw_MOV(p, get_addr_reg(vtx), deref_1uw(inlist_ptr, 0));
00252 
00253             /* IS_NEGATIVE(prev) */
00254             brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
00255             brw_DP4(p, vec4(c->reg.dpPrev), deref_4f(vtxPrev, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
00256             prev_test = brw_IF(p, BRW_EXECUTE_1);
00257             {
00258                /* IS_POSITIVE(next)
00259                 */
00260                brw_set_conditionalmod(p, BRW_CONDITIONAL_GE);
00261                brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
00262                next_test = brw_IF(p, BRW_EXECUTE_1);
00263                {
00264 
00265                   /* Coming back in.
00266                    */
00267                   brw_ADD(p, c->reg.t, c->reg.dpPrev, negate(c->reg.dp));
00268                   brw_math_invert(p, c->reg.t, c->reg.t);
00269                   brw_MUL(p, c->reg.t, c->reg.t, c->reg.dpPrev);
00270 
00271                   /* If (vtxOut == 0) vtxOut = vtxPrev
00272                    */
00273                   brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ, get_addr_reg(vtxOut), brw_imm_uw(0) );
00274                   brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtxPrev) );
00275                   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00276 
00277                   brw_clip_interp_vertex(c, vtxOut, vtxPrev, vtx, c->reg.t, FALSE);
00278 
00279                   /* *outlist_ptr++ = vtxOut;
00280                    * nr_verts++;
00281                    * vtxOut = 0;
00282                    */
00283                   brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxOut));
00284                   brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
00285                   brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
00286                   brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
00287                }
00288                brw_ENDIF(p, next_test);
00289 
00290             }
00291             prev_test = brw_ELSE(p, prev_test);
00292             {
00293                /* *outlist_ptr++ = vtxPrev;
00294                 * nr_verts++;
00295                 */
00296                brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxPrev));
00297                brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
00298                brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
00299 
00300                /* IS_NEGATIVE(next)
00301                 */
00302                brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
00303                brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
00304                next_test = brw_IF(p, BRW_EXECUTE_1);
00305                {
00306                   /* Going out of bounds.  Avoid division by zero as we
00307                    * know dp != dpPrev from DIFFERENT_SIGNS, above.
00308                    */
00309                   brw_ADD(p, c->reg.t, c->reg.dp, negate(c->reg.dpPrev));
00310                   brw_math_invert(p, c->reg.t, c->reg.t);
00311                   brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp);
00312 
00313                   /* If (vtxOut == 0) vtxOut = vtx
00314                    */
00315                   brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ, get_addr_reg(vtxOut), brw_imm_uw(0) );
00316                   brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtx) );
00317                   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
00318 
00319                   brw_clip_interp_vertex(c, vtxOut, vtx, vtxPrev, c->reg.t, TRUE);
00320 
00321                   /* *outlist_ptr++ = vtxOut;
00322                    * nr_verts++;
00323                    * vtxOut = 0;
00324                    */
00325                   brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxOut));
00326                   brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
00327                   brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
00328                   brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
00329                }
00330                brw_ENDIF(p, next_test);
00331             }
00332             brw_ENDIF(p, prev_test);
00333 
00334             /* vtxPrev = vtx;
00335              * inlist_ptr++;
00336              */
00337             brw_MOV(p, get_addr_reg(vtxPrev), get_addr_reg(vtx));
00338             brw_ADD(p, get_addr_reg(inlist_ptr), get_addr_reg(inlist_ptr), brw_imm_uw(sizeof(short)));
00339 
00340             /* while (--loopcount != 0)
00341              */
00342             brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
00343             brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
00344          }
00345          brw_WHILE(p, vertex_loop);
00346 
00347          /* vtxPrev = *(outlist_ptr-1)  OR: outlist[nr_verts-1]
00348           * inlist = outlist
00349           * inlist_ptr = &inlist[0]
00350           * outlist_ptr = &outlist[0]
00351           */
00352          brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_w(-2));
00353          brw_MOV(p, get_addr_reg(vtxPrev), deref_1uw(outlist_ptr, 0));
00354          brw_MOV(p, brw_vec8_grf(c->reg.inlist.nr, 0), brw_vec8_grf(c->reg.outlist.nr, 0));
00355          brw_MOV(p, get_addr_reg(inlist_ptr), brw_address(c->reg.inlist));
00356          brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
00357       }
00358       brw_ENDIF(p, plane_active);
00359 
00360       /* plane_ptr++;
00361        */
00362       brw_ADD(p, get_addr_reg(plane_ptr), get_addr_reg(plane_ptr), brw_clip_plane_stride(c));
00363 
00364       /* nr_verts >= 3
00365        */
00366       brw_CMP(p,
00367               vec1(brw_null_reg()),
00368               BRW_CONDITIONAL_GE,
00369               c->reg.nr_verts,
00370               brw_imm_ud(3));
00371 
00372       /* && (planemask>>=1) != 0
00373        */
00374       brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
00375       brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
00376    }
00377    brw_WHILE(p, plane_loop);
00378 #else
00379          #warning "disabled"
00380 #endif
00381 }

void brw_clip_tri_alloc_regs ( struct brw_clip_compile c,
unsigned  nr_verts 
)

Definition at line 54 of file brw_clip_tri.c.

References BRW_GENERAL_REGISTER_FILE, brw_imm_f(), brw_MOV(), BRW_REGISTER_TYPE_UD, brw_uw16_reg(), brw_vec1_grf(), brw_vec4_grf(), brw_vec8_grf(), byte_offset(), brw_clip_prog_data::curb_read_length, brw_clip_compile::dir, brw_clip_prog_key::do_unfilled, brw_clip_compile::dp, brw_clip_compile::dpPrev, brw_clip_compile::first_tmp, brw_clip_compile::fixed_planes, brw_clip_compile::freelist, brw_clip_compile::func, brw_clip_compile::inlist, brw_clip_compile::key, brw_clip_compile::last_tmp, brw_clip_compile::loopcount, brw_clip_compile::nr_attrs, brw_clip_compile::nr_regs, brw_clip_prog_key::nr_userclip, brw_clip_compile::nr_verts, brw_clip_compile::offset, brw_clip_compile::outlist, brw_clip_compile::plane_equation, brw_clip_compile::planemask, brw_clip_compile::prog_data, brw_clip_compile::R0, brw_clip_compile::reg, retype(), brw_clip_compile::t, brw_clip_compile::tmp1, brw_clip_prog_data::total_grf, brw_clip_prog_data::urb_read_length, and brw_clip_compile::vertex.

00056 {
00057    unsigned i = 0,j;
00058 
00059    /* Register usage is static, precompute here:
00060     */
00061    c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
00062 
00063    if (c->key.nr_userclip) {
00064       c->reg.fixed_planes = brw_vec4_grf(i, 0);
00065       i += (6 + c->key.nr_userclip + 1) / 2;
00066 
00067       c->prog_data.curb_read_length = (6 + c->key.nr_userclip + 1) / 2;
00068    }
00069    else
00070       c->prog_data.curb_read_length = 0;
00071 
00072 
00073    /* Payload vertices plus space for more generated vertices:
00074     */
00075    for (j = 0; j < nr_verts; j++) {
00076       c->reg.vertex[j] = brw_vec4_grf(i, 0);
00077       i += c->nr_regs;
00078    }
00079 
00080    if (c->nr_attrs & 1) {
00081       for (j = 0; j < 3; j++) {
00082          unsigned delta = c->nr_attrs*16 + 32;
00083          brw_MOV(&c->func, byte_offset(c->reg.vertex[j], delta), brw_imm_f(0));
00084       }
00085    }
00086 
00087    c->reg.t          = brw_vec1_grf(i, 0);
00088    c->reg.loopcount  = retype(brw_vec1_grf(i, 1), BRW_REGISTER_TYPE_UD);
00089    c->reg.nr_verts   = retype(brw_vec1_grf(i, 2), BRW_REGISTER_TYPE_UD);
00090    c->reg.planemask  = retype(brw_vec1_grf(i, 3), BRW_REGISTER_TYPE_UD);
00091    c->reg.plane_equation = brw_vec4_grf(i, 4);
00092    i++;
00093 
00094    c->reg.dpPrev     = brw_vec1_grf(i, 0); /* fixme - dp4 will clobber r.1,2,3 */
00095    c->reg.dp         = brw_vec1_grf(i, 4);
00096    i++;
00097 
00098    c->reg.inlist     = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
00099    i++;
00100 
00101    c->reg.outlist    = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
00102    i++;
00103 
00104    c->reg.freelist   = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
00105    i++;
00106 
00107    if (!c->key.nr_userclip) {
00108       c->reg.fixed_planes = brw_vec8_grf(i, 0);
00109       i++;
00110    }
00111 
00112    if (c->key.do_unfilled) {
00113       c->reg.dir     = brw_vec4_grf(i, 0);
00114       c->reg.offset  = brw_vec4_grf(i, 4);
00115       i++;
00116       c->reg.tmp0    = brw_vec4_grf(i, 0);
00117       c->reg.tmp1    = brw_vec4_grf(i, 4);
00118       i++;
00119    }
00120 
00121    c->first_tmp = i;
00122    c->last_tmp = i;
00123 
00124    c->prog_data.urb_read_length = c->nr_regs; /* ? */
00125    c->prog_data.total_grf = i;
00126 }

void brw_clip_tri_emit_polygon ( struct brw_clip_compile c  ) 

Definition at line 385 of file brw_clip_tri.c.

References _3DPRIM_TRIFAN, brw_ADD(), brw_address(), brw_clip_emit_vue(), BRW_CONDITIONAL_G, BRW_CONDITIONAL_NZ, brw_DO(), brw_ENDIF(), BRW_EXECUTE_1, brw_IF(), brw_imm_d(), brw_imm_uw(), brw_indirect(), brw_MOV(), brw_set_conditionalmod(), brw_WHILE(), deref_1uw(), brw_clip_compile::func, get_addr_reg(), brw_clip_compile::inlist, brw_clip_compile::loopcount, brw_clip_compile::nr_verts, R02_PRIM_END, R02_PRIM_START, and brw_clip_compile::reg.

00386 {
00387    struct brw_compile *p = &c->func;
00388    struct brw_instruction *loop, *if_insn;
00389 
00390    /* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
00391     */
00392    brw_set_conditionalmod(p, BRW_CONDITIONAL_G);
00393    brw_ADD(p,
00394            c->reg.loopcount,
00395            c->reg.nr_verts,
00396            brw_imm_d(-2));
00397 
00398    if_insn = brw_IF(p, BRW_EXECUTE_1);
00399    {
00400       struct brw_indirect v0 = brw_indirect(0, 0);
00401       struct brw_indirect vptr = brw_indirect(1, 0);
00402 
00403       brw_MOV(p, get_addr_reg(vptr), brw_address(c->reg.inlist));
00404       brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
00405 
00406       brw_clip_emit_vue(c, v0, 1, 0, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_START));
00407 
00408       brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
00409       brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
00410 
00411       loop = brw_DO(p, BRW_EXECUTE_1);
00412       {
00413          brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN << 2));
00414 
00415          brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
00416          brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
00417 
00418          brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
00419          brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
00420       }
00421       brw_WHILE(p, loop);
00422 
00423       brw_clip_emit_vue(c, v0, 0, 1, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_END));
00424    }
00425    brw_ENDIF(p, if_insn);
00426 }

void brw_clip_tri_flat_shade ( struct brw_clip_compile c  ) 

Definition at line 171 of file brw_clip_tri.c.

References _3DPRIM_POLYGON, brw_AND(), brw_clip_copy_colors(), brw_CMP(), BRW_CONDITIONAL_EQ, brw_ELSE(), brw_ENDIF(), BRW_EXECUTE_1, brw_IF(), brw_imm_ud(), brw_null_reg(), brw_clip_compile::func, get_element_ud(), brw_clip_compile::loopcount, PRIM_MASK, brw_clip_compile::R0, brw_clip_compile::reg, and vec1().

00172 {
00173    struct brw_compile *p = &c->func;
00174    struct brw_instruction *is_poly;
00175    struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
00176 
00177    brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK));
00178    brw_CMP(p,
00179            vec1(brw_null_reg()),
00180            BRW_CONDITIONAL_EQ,
00181            tmp0,
00182            brw_imm_ud(_3DPRIM_POLYGON));
00183 
00184    is_poly = brw_IF(p, BRW_EXECUTE_1);
00185    {
00186       brw_clip_copy_colors(c, 1, 0);
00187       brw_clip_copy_colors(c, 2, 0);
00188    }
00189    is_poly = brw_ELSE(p, is_poly);
00190    {
00191       brw_clip_copy_colors(c, 0, 2);
00192       brw_clip_copy_colors(c, 1, 2);
00193    }
00194    brw_ENDIF(p, is_poly);
00195 }

void brw_clip_tri_init_vertices ( struct brw_clip_compile c  ) 

Definition at line 130 of file brw_clip_tri.c.

References _3DPRIM_TRISTRIP_REVERSE, brw_address(), brw_AND(), brw_CMP(), BRW_CONDITIONAL_EQ, brw_ELSE(), brw_ENDIF(), BRW_EXECUTE_1, brw_IF(), brw_imm_f(), brw_imm_ud(), brw_MOV(), brw_null_reg(), brw_vec8_grf(), brw_clip_compile::dir, brw_clip_compile::func, get_element(), get_element_ud(), brw_clip_compile::inlist, brw_clip_compile::loopcount, brw_clip_compile::need_direction, brw_reg::nr, brw_clip_compile::nr_verts, brw_clip_compile::outlist, PRIM_MASK, brw_clip_compile::R0, brw_clip_compile::reg, vec1(), and brw_clip_compile::vertex.

00131 {
00132    struct brw_compile *p = &c->func;
00133    struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
00134    struct brw_instruction *is_rev;
00135 
00136    /* Initial list of indices for incoming vertexes:
00137     */
00138    brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK));
00139    brw_CMP(p,
00140            vec1(brw_null_reg()),
00141            BRW_CONDITIONAL_EQ,
00142            tmp0,
00143            brw_imm_ud(_3DPRIM_TRISTRIP_REVERSE));
00144 
00145    /* XXX: Is there an easier way to do this?  Need to reverse every
00146     * second tristrip element:  Can ignore sometimes?
00147     */
00148    is_rev = brw_IF(p, BRW_EXECUTE_1);
00149    {
00150       brw_MOV(p, get_element(c->reg.inlist, 0),  brw_address(c->reg.vertex[1]) );
00151       brw_MOV(p, get_element(c->reg.inlist, 1),  brw_address(c->reg.vertex[0]) );
00152       if (c->need_direction)
00153          brw_MOV(p, c->reg.dir, brw_imm_f(-1));
00154    }
00155    is_rev = brw_ELSE(p, is_rev);
00156    {
00157       brw_MOV(p, get_element(c->reg.inlist, 0),  brw_address(c->reg.vertex[0]) );
00158       brw_MOV(p, get_element(c->reg.inlist, 1),  brw_address(c->reg.vertex[1]) );
00159       if (c->need_direction)
00160          brw_MOV(p, c->reg.dir, brw_imm_f(1));
00161    }
00162    brw_ENDIF(p, is_rev);
00163 
00164    brw_MOV(p, get_element(c->reg.inlist, 2),  brw_address(c->reg.vertex[2]) );
00165    brw_MOV(p, brw_vec8_grf(c->reg.outlist.nr, 0), brw_imm_f(0));
00166    brw_MOV(p, c->reg.nr_verts, brw_imm_ud(3));
00167 }

void brw_emit_tri_clip ( struct brw_clip_compile c  ) 

Definition at line 530 of file brw_clip_tri.c.

References brw_AND(), brw_clip_init_clipmask(), brw_clip_kill_thread(), brw_clip_test(), brw_clip_tri_alloc_regs(), brw_clip_tri_emit_polygon(), brw_clip_tri_flat_shade(), brw_clip_tri_init_vertices(), BRW_CLIPMODE_NORMAL, BRW_CONDITIONAL_NZ, brw_ENDIF(), BRW_EXECUTE_1, brw_IF(), brw_imm_ud(), brw_null_reg(), brw_set_conditionalmod(), brw_clip_prog_key::clip_mode, do_clip_tri(), brw_clip_prog_key::do_flat_shading, brw_clip_compile::func, get_element_ud(), brw_clip_compile::key, maybe_do_clip_tri(), brw_clip_prog_key::nr_userclip, brw_clip_compile::R0, and brw_clip_compile::reg.

00531 {
00532    struct brw_instruction *neg_rhw;
00533    struct brw_compile *p = &c->func;
00534    brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
00535    brw_clip_tri_init_vertices(c);
00536    brw_clip_init_clipmask(c);
00537 
00538    /* if -ve rhw workaround bit is set,
00539       do cliptest */
00540    brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
00541    brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
00542            brw_imm_ud(1<<20));
00543    neg_rhw = brw_IF(p, BRW_EXECUTE_1);
00544    {
00545        brw_clip_test(c);
00546    }
00547    brw_ENDIF(p, neg_rhw);
00548 
00549    /* Can't push into do_clip_tri because with polygon (or quad)
00550     * flatshading, need to apply the flatshade here because we don't
00551     * respect the PV when converting to trifan for emit:
00552     */
00553    if (c->key.do_flat_shading)
00554       brw_clip_tri_flat_shade(c);
00555 
00556    if (c->key.clip_mode == BRW_CLIPMODE_NORMAL)
00557       do_clip_tri(c);
00558    else
00559       maybe_do_clip_tri(c);
00560 
00561    brw_clip_tri_emit_polygon(c);
00562 
00563    /* Send an empty message to kill the thread:
00564     */
00565    brw_clip_kill_thread(c);
00566 }

static void do_clip_tri ( struct brw_clip_compile c  )  [static]

Definition at line 428 of file brw_clip_tri.c.

References brw_clip_init_planes(), and brw_clip_tri().

00429 {
00430    brw_clip_init_planes(c);
00431 
00432    brw_clip_tri(c);
00433 }

static struct brw_reg get_tmp ( struct brw_clip_compile c  )  [static, read]

Definition at line 38 of file brw_clip_tri.c.

References brw_vec4_grf().

00039 {
00040    struct brw_reg tmp = brw_vec4_grf(c->last_tmp, 0);
00041 
00042    if (++c->last_tmp > c->prog_data.total_grf)
00043       c->prog_data.total_grf = c->last_tmp;
00044 
00045    return tmp;
00046 }

static void maybe_do_clip_tri ( struct brw_clip_compile c  )  [static]

Definition at line 436 of file brw_clip_tri.c.

References brw_CMP(), BRW_CONDITIONAL_NZ, brw_ENDIF(), BRW_EXECUTE_1, brw_IF(), brw_imm_ud(), brw_null_reg(), do_clip_tri(), brw_clip_compile::func, brw_clip_compile::planemask, brw_clip_compile::reg, and vec1().

00437 {
00438    struct brw_compile *p = &c->func;
00439    struct brw_instruction *do_clip;
00440 
00441    brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, c->reg.planemask, brw_imm_ud(0));
00442    do_clip = brw_IF(p, BRW_EXECUTE_1);
00443    {
00444       do_clip_tri(c);
00445    }
00446    brw_ENDIF(p, do_clip);
00447 }

static void release_tmps ( struct brw_clip_compile c  )  [static]

Definition at line 48 of file brw_clip_tri.c.

References brw_clip_compile::first_tmp, and brw_clip_compile::last_tmp.

00049 {
00050    c->last_tmp = c->first_tmp;
00051 }


Generated on Tue Sep 29 06:25:36 2009 for Gallium3D by  doxygen 1.5.4