Remove pf_swizzle_* internal macros.
authorMichal Krol <michal@vmware.com>
Thu, 3 Dec 2009 11:25:49 +0000 (12:25 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 3 Dec 2009 11:25:49 +0000 (12:25 +0100)
src/gallium/drivers/nv50/nv50_vbo.c
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/include/pipe/p_format.h
src/mesa/state_tracker/st_format.c

index db54380241f681afc474d563dec1a60e00cabd55..4b8783899e6ec71be0bb3d2198acb418c08d8f65 100644 (file)
@@ -24,6 +24,8 @@
 #include "pipe/p_state.h"
 #include "pipe/p_inlines.h"
 
+#include "util/u_format.h"
+
 #include "nv50_context.h"
 
 static boolean
@@ -131,7 +133,7 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve)
                return 0x24e80000;
        }
 
-       if (pf_swizzle_x(pf) == 2) /* BGRA */
+       if (util_format_description(pf)->swizzle[0] == UTIL_FORMAT_SWIZZLE_Z) /* BGRA */
                hw_size |= (1 << 31); /* no real swizzle bits :-( */
 
        return (hw_type | hw_size);
index e6c1cb54dac3b29881ddfc2e3fb55242c8512f1f..ab720f366dd9f8648700bcc50649871437513af6 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "pipe/p_format.h"
 
+#include "util/u_format.h"
+
 #include "r300_reg.h"
 
 /* Some maths. These should probably find their way to u_math, if needed. */
@@ -534,6 +536,9 @@ r300_translate_vertex_data_type(enum pipe_format format) {
 
 static INLINE uint16_t
 r300_translate_vertex_data_swizzle(enum pipe_format format) {
+    const struct util_format_description *desc = util_format_description(format);
+
+    assert(format);
 
     if (pf_layout(format) != PIPE_FORMAT_LAYOUT_RGBAZS) {
         debug_printf("r300: Bad format %s in %s:%d\n",
@@ -541,10 +546,10 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) {
         return 0;
     }
 
-    return ((pf_swizzle_x(format) << R300_SWIZZLE_SELECT_X_SHIFT) |
-        (pf_swizzle_y(format) << R300_SWIZZLE_SELECT_Y_SHIFT) |
-        (pf_swizzle_z(format) << R300_SWIZZLE_SELECT_Z_SHIFT) |
-        (pf_swizzle_w(format) << R300_SWIZZLE_SELECT_W_SHIFT) |
+    return ((desc->swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) |
+        (desc->swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) |
+        (desc->swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) |
+        (desc->swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) |
         (0xf << R300_WRITE_ENA_SHIFT));
 }
 
index 52fdab457033902285fe2cb17524e08a8b82ddb6..cc7a8ab8dffce2d5f460ff224d2a06aeebcb08d0 100644 (file)
@@ -112,11 +112,6 @@ static INLINE uint pf_get(pipe_format_rgbazs_t f, uint shift, uint mask)
    return (f >> shift) & mask;
 }
 
-#define pf_swizzle_x(f)       pf_get(f, 2, 0x7)  /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_y(f)       pf_get(f, 5, 0x7)  /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_z(f)       pf_get(f, 8, 0x7)  /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_w(f)       pf_get(f, 11, 0x7) /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_xyzw(f,i)  pf_get(f, 2+((i)*3), 0x7)
 #define pf_size_x(f)          pf_get(f, 14, 0x7) /**< Size of X */
 #define pf_size_y(f)          pf_get(f, 17, 0x7) /**< Size of Y */
 #define pf_size_z(f)          pf_get(f, 20, 0x7) /**< Size of Z */
index c492d77530bb8e4410b8de2a4dd81f28e00a08f2..c9f020c40f83987f4dcd60edf3724f64c59ab8d7 100644 (file)
@@ -81,8 +81,11 @@ GLboolean
 st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
 {
    if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
+      const struct util_format_description *desc = util_format_description(format);
       pipe_format_rgbazs_t info;
 
+      assert(desc);
+
       info = format;
 
 #if 0
@@ -133,10 +136,10 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
       pinfo->size = format_size( info ) / 8;
 
       /* Luminance & Intensity bits */
-      if( pf_swizzle_x(info) == PIPE_FORMAT_COMP_R &&
-          pf_swizzle_y(info) == PIPE_FORMAT_COMP_R &&
-          pf_swizzle_z(info) == PIPE_FORMAT_COMP_R ) {
-         if( pf_swizzle_w(info) == PIPE_FORMAT_COMP_R ) {
+      if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
+          desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X &&
+          desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X) {
+         if (desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
             pinfo->intensity_bits = pinfo->red_bits;
          }
          else {