gallium/util: remove p_format.h from u_debug.h
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_util.c
index be8bcdf1233e5981b8e7ffc5eaae033ea44d5eef..ebbd561f7d09d0bd598d97903012e1ed0232e261 100644 (file)
@@ -40,8 +40,7 @@ union pointer_hack
 };
 
 void *
-tgsi_align_128bit(
-   void *unaligned )
+tgsi_align_128bit(void *unaligned)
 {
    union pointer_hack ph;
 
@@ -52,9 +51,8 @@ tgsi_align_128bit(
 }
 
 unsigned
-tgsi_util_get_src_register_swizzle(
-   const struct tgsi_src_register *reg,
-   unsigned component )
+tgsi_util_get_src_register_swizzle(const struct tgsi_src_register *reg,
+                                   unsigned component)
 {
    switch (component) {
    case TGSI_CHAN_X:
@@ -74,21 +72,19 @@ tgsi_util_get_src_register_swizzle(
 
 unsigned
 tgsi_util_get_full_src_register_swizzle(
-   const struct tgsi_full_src_register  *reg,
-   unsigned component )
+   const struct tgsi_full_src_register *reg,
+   unsigned component)
 {
-   return tgsi_util_get_src_register_swizzle(
-      &reg->Register,
-      component );
+   return tgsi_util_get_src_register_swizzle(&reg->Register, component);
 }
 
+
 void
-tgsi_util_set_src_register_swizzle(
-   struct tgsi_src_register *reg,
-   unsigned swizzle,
-   unsigned component )
+tgsi_util_set_src_register_swizzle(struct tgsi_src_register *reg,
+                                   unsigned swizzle,
+                                   unsigned component)
 {
-   switch( component ) {
+   switch (component) {
    case 0:
       reg->SwizzleX = swizzle;
       break;
@@ -102,21 +98,22 @@ tgsi_util_set_src_register_swizzle(
       reg->SwizzleW = swizzle;
       break;
    default:
-      assert( 0 );
+      assert(0);
    }
 }
 
+
 unsigned
 tgsi_util_get_full_src_register_sign_mode(
-   const struct  tgsi_full_src_register *reg,
-   unsigned component )
+   const struct tgsi_full_src_register *reg,
+   UNUSED unsigned component)
 {
    unsigned sign_mode;
 
-   if( reg->Register.Absolute ) {
+   if (reg->Register.Absolute) {
       /* Consider only the post-abs negation. */
 
-      if( reg->Register.Negate ) {
+      if (reg->Register.Negate) {
          sign_mode = TGSI_UTIL_SIGN_SET;
       }
       else {
@@ -124,7 +121,7 @@ tgsi_util_get_full_src_register_sign_mode(
       }
    }
    else {
-      if( reg->Register.Negate ) {
+      if (reg->Register.Negate) {
          sign_mode = TGSI_UTIL_SIGN_TOGGLE;
       }
       else {
@@ -135,13 +132,12 @@ tgsi_util_get_full_src_register_sign_mode(
    return sign_mode;
 }
 
+
 void
-tgsi_util_set_full_src_register_sign_mode(
-   struct tgsi_full_src_register *reg,
-   unsigned sign_mode )
+tgsi_util_set_full_src_register_sign_mode(struct tgsi_full_src_register *reg,
+                                          unsigned sign_mode)
 {
-   switch (sign_mode)
-   {
+   switch (sign_mode) {
    case TGSI_UTIL_SIGN_CLEAR:
       reg->Register.Negate = 0;
       reg->Register.Absolute = 1;
@@ -163,10 +159,11 @@ tgsi_util_set_full_src_register_sign_mode(
       break;
 
    default:
-      assert( 0 );
+      assert(0);
    }
 }
 
+
 /**
  * Determine which channels of the specificed src register are effectively
  * used by this instruction.
@@ -230,13 +227,25 @@ tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
       read_mask = TGSI_WRITEMASK_XYZ;
       break;
 
+   case TGSI_OPCODE_DSEQ:
+   case TGSI_OPCODE_DSNE:
+   case TGSI_OPCODE_DSLT:
+   case TGSI_OPCODE_DSGE:
    case TGSI_OPCODE_DP4:
    case TGSI_OPCODE_PK4B:
    case TGSI_OPCODE_PK4UB:
    case TGSI_OPCODE_D2F:
+   case TGSI_OPCODE_D2I:
+   case TGSI_OPCODE_D2U:
    case TGSI_OPCODE_I2F:
    case TGSI_OPCODE_U2F:
+   case TGSI_OPCODE_U64SEQ:
+   case TGSI_OPCODE_U64SNE:
+   case TGSI_OPCODE_U64SLT:
+   case TGSI_OPCODE_U64SGE:
    case TGSI_OPCODE_U642F:
+   case TGSI_OPCODE_I64SLT:
+   case TGSI_OPCODE_I64SGE:
    case TGSI_OPCODE_I642F:
       read_mask = TGSI_WRITEMASK_XYZW;
       break;
@@ -292,17 +301,17 @@ tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
    case TGSI_OPCODE_TXL2:
    case TGSI_OPCODE_LODQ:
    case TGSI_OPCODE_TG4: {
-      unsigned dim_layer_shadow =
+      unsigned dim_layer =
          tgsi_util_get_texture_coord_dim(inst->Texture.Texture);
-      unsigned dim_layer, dim;
+      unsigned dim_layer_shadow, dim;
 
-      /* Remove shadow. */
+      /* Add shadow. */
       if (tgsi_is_shadow_target(inst->Texture.Texture)) {
-         dim_layer = dim_layer_shadow - 1;
+         dim_layer_shadow = dim_layer + 1;
          if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D)
-            dim_layer = 1;
+            dim_layer_shadow = 3;
       } else {
-         dim_layer = dim_layer_shadow;
+         dim_layer_shadow = dim_layer;
       }
 
       /* Remove layer. */
@@ -440,7 +449,7 @@ tgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg)
  * sample index.
  */
 int
-tgsi_util_get_texture_coord_dim(unsigned tgsi_tex)
+tgsi_util_get_texture_coord_dim(enum tgsi_texture_type tgsi_tex)
 {
    /*
     * Depending on the texture target, (src0.xyzw, src1.x) is interpreted
@@ -497,11 +506,15 @@ tgsi_util_get_texture_coord_dim(unsigned tgsi_tex)
 
 
 /**
- * Given a TGSI_TEXTURE_x target, return the src register index for the
- * shadow reference coordinate.
+ * Given a TGSI_TEXTURE_x target, return register component where the
+ * shadow reference/distance coordinate is found.  Typically, components
+ * 0 and 1 are the (s,t) texcoords and component 2 or 3 hold the shadow
+ * reference value.  But if we return 4, it means the reference value is
+ * found in the 0th component of the second coordinate argument to the
+ * TEX2 instruction.
  */
 int
-tgsi_util_get_shadow_ref_src_index(unsigned tgsi_tex)
+tgsi_util_get_shadow_ref_src_index(enum tgsi_texture_type tgsi_tex)
 {
    switch (tgsi_tex) {
    case TGSI_TEXTURE_SHADOW1D:
@@ -524,7 +537,7 @@ tgsi_util_get_shadow_ref_src_index(unsigned tgsi_tex)
 
 
 boolean
-tgsi_is_shadow_target(unsigned target)
+tgsi_is_shadow_target(enum tgsi_texture_type target)
 {
    switch (target) {
    case TGSI_TEXTURE_SHADOW1D: