r600: switch tex code to use SETfield macros
authorAlex Deucher <alexdeucher@gmail.com>
Fri, 24 Jul 2009 14:58:47 +0000 (10:58 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Mon, 27 Jul 2009 06:26:41 +0000 (02:26 -0400)
for consistency with the rest of the code.

src/mesa/drivers/dri/r600/r600_tex.c
src/mesa/drivers/dri/r600/r600_texstate.c

index 43d9f641af47390acb783d96d78d53f3f0094070..a1e8945390045db0898a27b9523f5de5dea3cd9c 100644 (file)
@@ -127,10 +127,18 @@ static void r600SetTexDefaultState(radeonTexObjPtr t)
         SETfield(t->SQ_TEX_RESOURCE4, SQ_ENDIAN_NONE,
                  SQ_TEX_RESOURCE_WORD4_0__ENDIAN_SWAP_shift, SQ_TEX_RESOURCE_WORD4_0__ENDIAN_SWAP_mask);
         SETfield(t->SQ_TEX_RESOURCE4, 1, REQUEST_SIZE_shift, REQUEST_SIZE_mask);
-        t->SQ_TEX_RESOURCE4 |= SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift
-                             |SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift
-                             |SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift
-                             |SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift;
+        SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift,
+                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
         SETfield(t->SQ_TEX_RESOURCE4, 0, BASE_LEVEL_shift, BASE_LEVEL_mask); /* mip-maps */
 
         t->SQ_TEX_RESOURCE5 = 0;
@@ -141,17 +149,18 @@ static void r600SetTexDefaultState(radeonTexObjPtr t)
 
         /* Initialize sampler registers */
         t->SQ_TEX_SAMPLER0                           = 0;
-        t->SQ_TEX_SAMPLER0 |=
-                         SQ_TEX_WRAP << SQ_TEX_SAMPLER_WORD0_0__CLAMP_X_shift
-                        |SQ_TEX_WRAP << CLAMP_Y_shift
-                        |SQ_TEX_WRAP << CLAMP_Z_shift
-                        |SQ_TEX_XY_FILTER_POINT << XY_MAG_FILTER_shift
-                        |SQ_TEX_XY_FILTER_POINT << XY_MIN_FILTER_shift
-                        |SQ_TEX_Z_FILTER_NONE << Z_FILTER_shift
-                        |SQ_TEX_Z_FILTER_NONE << MIP_FILTER_shift
-                        |SQ_TEX_BORDER_COLOR_TRANS_BLACK << BORDER_COLOR_TYPE_shift;
-
-        t->SQ_TEX_SAMPLER1 = 0x7FF << MAX_LOD_shift;
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_WRAP, SQ_TEX_SAMPLER_WORD0_0__CLAMP_X_shift,
+                SQ_TEX_SAMPLER_WORD0_0__CLAMP_X_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_WRAP, CLAMP_Y_shift, CLAMP_Y_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_WRAP, CLAMP_Z_shift, CLAMP_Z_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_XY_FILTER_POINT, XY_MAG_FILTER_shift, XY_MAG_FILTER_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_XY_FILTER_POINT, XY_MIN_FILTER_shift, XY_MIN_FILTER_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_Z_FILTER_NONE, Z_FILTER_shift, Z_FILTER_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_Z_FILTER_NONE, MIP_FILTER_shift, MIP_FILTER_mask);
+        SETfield(t->SQ_TEX_SAMPLER0, SQ_TEX_BORDER_COLOR_TRANS_BLACK, BORDER_COLOR_TYPE_shift, BORDER_COLOR_TYPE_mask);
+
+        t->SQ_TEX_SAMPLER1                           = 0;
+        SETfield(t->SQ_TEX_SAMPLER1, MAX_LOD_mask, MAX_LOD_shift, MAX_LOD_mask);
 
         t->SQ_TEX_SAMPLER2                          = 0;
         SETbit(t->SQ_TEX_SAMPLER2, SQ_TEX_SAMPLER_WORD2_0__TYPE_bit);
index 2466aa9595097869100977bdf3ae9a766e7c45b2..c76292a5f8ecbcd35815200f9463f7aaa1579179 100644 (file)
@@ -75,10 +75,10 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
 {
        radeonTexObj *t = radeon_tex_obj(tObj);
 
-       t->SQ_TEX_RESOURCE4 &= ~( SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask
-                                 |SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask
-                                 |SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask
-                                 |SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask );
+       CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+       CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+       CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+       CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
 
        switch (mesa_format) /* This is mesa format. */
        {
@@ -86,163 +86,211 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGBA8888_REV:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ARGB8888:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ARGB8888_REV:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGB888:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGB565:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_5_6_5,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGB565_REV:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_5_6_5,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ARGB4444:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_4_4_4_4,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ARGB4444_REV:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_4_4_4_4,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ARGB1555:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_1_5_5_5,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ARGB1555_REV:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_1_5_5_5,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_AL88:
        case MESA_FORMAT_AL88_REV: /* TODO : Check this. */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGB332:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_3_3_2,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_A8: /* ZERO, ZERO, ZERO, X */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_L8: /* X, X, X, ONE */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_I8: /* X, X, X, X */
        case MESA_FORMAT_CI8:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
                /* YUV422 TODO conversion */  /* X, Y, Z, ONE, G8R8_G8B8 */
                /*
@@ -272,121 +320,157 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                SETfield(t->SQ_TEX_RESOURCE1, FMT_32_32_32_32_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGBA_FLOAT16:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_16_16_16_16_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGB_FLOAT32: /* X, Y, Z, ONE */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_32_32_32_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_RGB_FLOAT16:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_16_16_16_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ALPHA_FLOAT32: /* ZERO, ZERO, ZERO, X */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_32_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_ALPHA_FLOAT16: /* ZERO, ZERO, ZERO, X */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_16_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_LUMINANCE_FLOAT32: /* X, X, X, ONE */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_32_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_LUMINANCE_FLOAT16: /* X, X, X, ONE */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_16_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_32_32_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_16_16_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_32_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */
                SETfield(t->SQ_TEX_RESOURCE1, FMT_16_FLOAT,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                break;
        case MESA_FORMAT_Z16:
        case MESA_FORMAT_Z24_S8:
@@ -407,25 +491,34 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
                };
                switch (tObj->DepthMode) {
                case GL_LUMINANCE:  /* X, X, X, ONE */
-                       t->SQ_TEX_RESOURCE4 |=
-                               (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                               |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                        break;
                case GL_INTENSITY:  /* X, X, X, X */
-                       t->SQ_TEX_RESOURCE4 |=
-                               (SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                        break;
                case GL_ALPHA:     /* ZERO, ZERO, ZERO, X */
-                       t->SQ_TEX_RESOURCE4 |=
-                               (SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                               |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                               |(SQ_SEL_0 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_0,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                        break;
                default:
                        return GL_FALSE;
@@ -441,7 +534,6 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, GLuint mesa_fo
 
 void r600SetDepthTexMode(struct gl_texture_object *tObj)
 {
-       const GLuint *format;
        radeonTexObjPtr t;
 
        if (!tObj)
@@ -616,11 +708,14 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                pitch_val /= 4;
                break;
        case 24:
@@ -628,22 +723,28 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                pitch_val /= 4;
                break;
        case 16:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_5_6_5,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                pitch_val /= 2;
                break;
        }
@@ -739,20 +840,26 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
                        SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                                 SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-                       t->SQ_TEX_RESOURCE4 |=
-                               (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                               |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                               |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                               |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                } else {
                        SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                                 SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-                       t->SQ_TEX_RESOURCE4 |=
-                               (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                               |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                               |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                               |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+                       SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                                SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                }
                pitch_val /= 4;
                break;
@@ -762,22 +869,28 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
                SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_W << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                pitch_val /= 4;
                break;
        case 2:
                SETfield(t->SQ_TEX_RESOURCE1, FMT_5_6_5,
                         SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
 
-               t->SQ_TEX_RESOURCE4 |=
-                       (SQ_SEL_Z << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift)
-                       |(SQ_SEL_Y << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift)
-                       |(SQ_SEL_X << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift)
-                       |(SQ_SEL_1 << SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask);
+               SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
+                        SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
                pitch_val /= 2;
                break;
        }