예제 #1
0
bool
brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg)
{
   union {
      unsigned ud;
      int d;
      float f;
      double df;
   } imm, sat_imm = { 0 };

   const unsigned size = type_sz(type);

   /* We want to either do a 32-bit or 64-bit data copy, the type is otherwise
    * irrelevant, so just check the size of the type and copy from/to an
    * appropriately sized field.
    */
   if (size < 8)
      imm.ud = reg->ud;
   else
      imm.df = reg->df;

   switch (type) {
   case BRW_REGISTER_TYPE_UD:
   case BRW_REGISTER_TYPE_D:
   case BRW_REGISTER_TYPE_UW:
   case BRW_REGISTER_TYPE_W:
   case BRW_REGISTER_TYPE_UQ:
   case BRW_REGISTER_TYPE_Q:
      /* Nothing to do. */
      return false;
   case BRW_REGISTER_TYPE_F:
      sat_imm.f = CLAMP(imm.f, 0.0f, 1.0f);
      break;
   case BRW_REGISTER_TYPE_DF:
      sat_imm.df = CLAMP(imm.df, 0.0, 1.0);
      break;
   case BRW_REGISTER_TYPE_UB:
   case BRW_REGISTER_TYPE_B:
      unreachable("no UB/B immediates");
   case BRW_REGISTER_TYPE_V:
   case BRW_REGISTER_TYPE_UV:
   case BRW_REGISTER_TYPE_VF:
      unreachable("unimplemented: saturate vector immediate");
   case BRW_REGISTER_TYPE_HF:
      unreachable("unimplemented: saturate HF immediate");
   }

   if (size < 8) {
      if (imm.ud != sat_imm.ud) {
         reg->ud = sat_imm.ud;
         return true;
      }
   } else {
      if (imm.df != sat_imm.df) {
         reg->df = sat_imm.df;
         return true;
      }
   }
   return false;
}
예제 #2
0
static void apply_one_offset( struct brw_clip_compile *c,
			  struct brw_indirect vert )
{
   struct brw_compile *p = &c->func;
   struct brw_reg z = deref_1f(vert, c->header_position_offset +
			       2 * type_sz(BRW_REGISTER_TYPE_F));

   brw_ADD(p, z, z, vec1(c->reg.offset));
}
예제 #3
0
void brw_print_reg( struct brw_reg hwreg )
{
   static const char *file[] = {
      "arf",
      "grf",
      "msg",
      "imm"
   };

   static const char *type[] = {
      "ud",
      "d",
      "uw",
      "w",
      "ub",
      "vf",
      "hf",
      "f"
   };

   printf("%s%s", 
	  hwreg.abs ? "abs/" : "",
	  hwreg.negate ? "-" : "");
     
   if (hwreg.file == BRW_GENERAL_REGISTER_FILE &&
       hwreg.nr % 2 == 0 &&
       hwreg.subnr == 0 &&
       hwreg.vstride == BRW_VERTICAL_STRIDE_8 &&
       hwreg.width == BRW_WIDTH_8 &&
       hwreg.hstride == BRW_HORIZONTAL_STRIDE_1 &&
       hwreg.type == BRW_REGISTER_TYPE_F) {
      /* vector register */
      printf("vec%d", hwreg.nr);
   }
   else if (hwreg.file == BRW_GENERAL_REGISTER_FILE &&
	    hwreg.vstride == BRW_VERTICAL_STRIDE_0 &&
	    hwreg.width == BRW_WIDTH_1 &&
	    hwreg.hstride == BRW_HORIZONTAL_STRIDE_0 &&
	    hwreg.type == BRW_REGISTER_TYPE_F) {      
      /* "scalar" register */
      printf("scl%d.%d", hwreg.nr, hwreg.subnr / 4);
   }
   else if (hwreg.file == BRW_IMMEDIATE_VALUE) {
      printf("imm %f", hwreg.dw1.f);
   }
   else {
      printf("%s%d.%d<%d;%d,%d>:%s", 
		   file[hwreg.file],
		   hwreg.nr,
		   hwreg.subnr / type_sz(hwreg.type),
		   hwreg.vstride ? (1<<(hwreg.vstride-1)) : 0,
		   1<<hwreg.width,
		   hwreg.hstride ? (1<<(hwreg.hstride-1)) : 0,		
		   type[hwreg.type]);
   }
}
예제 #4
0
static void apply_one_offset( struct brw_clip_compile *c,
			  struct brw_indirect vert )
{
   struct brw_compile *p = &c->func;
   GLuint ndc_offset = brw_varying_to_offset(&c->vue_map,
                                             BRW_VARYING_SLOT_NDC);
   struct brw_reg z = deref_1f(vert, ndc_offset +
			       2 * type_sz(BRW_REGISTER_TYPE_F));

   brw_ADD(p, z, z, vec1(c->reg.offset));
}