Ejemplo n.º 1
0
static void do_twoside_color( struct brw_sf_compile *c )
{
   struct brw_compile *p = &c->func;
   GLuint backface_conditional = c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L;

   /* Already done in clip program:
    */
   if (c->key.primitive == SF_UNFILLED_TRIS)
      return;

   /* If the vertex shader provides backface color, do the selection. The VS
    * promises to set up the front color if the backface color is provided, but
    * it may contain junk if never written to.
    */
   if (!(have_attr(c, VARYING_SLOT_COL0) && have_attr(c, VARYING_SLOT_BFC0)) &&
       !(have_attr(c, VARYING_SLOT_COL1) && have_attr(c, VARYING_SLOT_BFC1)))
      return;

   /* Need to use BRW_EXECUTE_4 and also do an 4-wide compare in order
    * to get all channels active inside the IF.  In the clipping code
    * we run with NoMask, so it's not an option and we can use
    * BRW_EXECUTE_1 for all comparisions.
    */
   brw_CMP(p, vec4(brw_null_reg()), backface_conditional, c->det, brw_imm_f(0));
   brw_IF(p, BRW_EXECUTE_4);
   {
      switch (c->nr_verts) {
      case 3: copy_bfc(c, c->vert[2]);
      case 2: copy_bfc(c, c->vert[1]);
      case 1: copy_bfc(c, c->vert[0]);
      }
   }
   brw_ENDIF(p);
}
Ejemplo n.º 2
0
/***********************************************************************
 * Twoside lighting
 */
static void copy_bfc( struct brw_sf_compile *c,
		      struct brw_reg vert )
{
   struct brw_compile *p = &c->func;
   GLuint i;

   for (i = 0; i < 2; i++) {
      if (have_attr(c, VARYING_SLOT_COL0+i) &&
	  have_attr(c, VARYING_SLOT_BFC0+i))
	 brw_MOV(p,
		 get_varying(c, vert, VARYING_SLOT_COL0+i),
		 get_varying(c, vert, VARYING_SLOT_BFC0+i));
   }
}
Ejemplo n.º 3
0
/*********************************************************************** 
 * Twoside lighting
 */
static void copy_bfc( struct brw_sf_compile *c,
		      struct brw_reg vert )
{
   struct brw_compile *p = &c->func;
   GLuint i;

   for (i = 0; i < 2; i++) {
      if (have_attr(c, VERT_RESULT_COL0+i) &&
	  have_attr(c, VERT_RESULT_BFC0+i))
	 brw_MOV(p, 
		 get_vert_result(c, vert, VERT_RESULT_COL0+i),
		 get_vert_result(c, vert, VERT_RESULT_BFC0+i));
   }
}
Ejemplo n.º 4
0
static void do_twoside_color( struct brw_sf_compile *c )
{
    struct brw_compile *p = &c->func;
    GLuint backface_conditional = c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L;

    /* Already done in clip program:
     */
    if (c->key.primitive == SF_UNFILLED_TRIS)
        return;

    /* XXX: What happens if BFC isn't present?  This could only happen
     * for user-supplied vertex programs, as t_vp_build.c always does
     * the right thing.
     */
    if (!(have_attr(c, VERT_RESULT_COL0) && have_attr(c, VERT_RESULT_BFC0)) &&
            !(have_attr(c, VERT_RESULT_COL1) && have_attr(c, VERT_RESULT_BFC1)))
        return;

    /* Need to use BRW_EXECUTE_4 and also do an 4-wide compare in order
     * to get all channels active inside the IF.  In the clipping code
     * we run with NoMask, so it's not an option and we can use
     * BRW_EXECUTE_1 for all comparisions.
     */
    brw_push_insn_state(p);
    brw_CMP(p, vec4(brw_null_reg()), backface_conditional, c->det, brw_imm_f(0));
    brw_IF(p, BRW_EXECUTE_4);
    {
        switch (c->nr_verts) {
        case 3:
            copy_bfc(c, c->vert[2]);
        case 2:
            copy_bfc(c, c->vert[1]);
        case 1:
            copy_bfc(c, c->vert[0]);
        }
    }
    brw_ENDIF(p);
    brw_pop_insn_state(p);
}
Ejemplo n.º 5
0
static void copy_colors( struct brw_sf_compile *c,
                         struct brw_reg dst,
                         struct brw_reg src)
{
    struct brw_compile *p = &c->func;
    GLuint i;

    for (i = VERT_RESULT_COL0; i <= VERT_RESULT_COL1; i++) {
        if (have_attr(c,i))
            brw_MOV(p,
                    get_vert_attr(c, dst, i),
                    get_vert_attr(c, src, i));
    }
}
/**
 * Sets VERT_RESULT_FOGC.Y  for gl_FrontFacing
 *
 * This is currently executed if the fragment program uses VERT_RESULT_FOGC
 * at all, but this could be eliminated with a scan of the FP contents.
 */
static void
do_front_facing( struct brw_sf_compile *c )
{
   struct brw_compile *p = &c->func; 
   int i;

   if (!have_attr(c, VERT_RESULT_FOGC))
      return;

   brw_push_insn_state(p);
   brw_CMP(p, brw_null_reg(), 
        c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L,
        c->det, brw_imm_f(0));
   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
   for (i = 0; i < 3; i++) {
       struct brw_reg fogc = get_vert_attr(c, c->vert[i],FRAG_ATTRIB_FOGC);
       brw_MOV(p, get_element(fogc, 1), brw_imm_f(0));
       brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
       brw_MOV(p, get_element(fogc, 1), brw_imm_f(1));
       brw_set_predicate_control(p, BRW_PREDICATE_NONE);
   }
   brw_pop_insn_state(p);
}