r300g: fix texture border color for sRGB formats
authorMarek Olšák <maraeo@gmail.com>
Thu, 25 Oct 2012 23:03:53 +0000 (01:03 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 25 Oct 2012 23:27:05 +0000 (01:27 +0200)
NOTE: This is a candidate for the stable branches.

src/gallium/drivers/r300/r300_state_derived.c

index 940179c6e9d99a577e38b8f55924160ab5c7d23c..3ccf396b7418e3dd9069c1572757301fc0361b8c 100644 (file)
@@ -655,6 +655,12 @@ static uint32_t r300_get_border_color(enum pipe_format format,
         case PIPE_FORMAT_LATC2_UNORM:
             util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
             return uc.ui;
+        case PIPE_FORMAT_DXT1_SRGB:
+        case PIPE_FORMAT_DXT1_SRGBA:
+        case PIPE_FORMAT_DXT3_SRGBA:
+        case PIPE_FORMAT_DXT5_SRGBA:
+            util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_SRGB, &uc);
+            return uc.ui;
         default:
             util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
             return uc.ui;
@@ -685,10 +691,18 @@ static uint32_t r300_get_border_color(enum pipe_format format,
 
         default:
         case 8:
-            if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED)
-               util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc);
-            else
-               util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
+            if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {
+                util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc);
+            } else if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+                if (desc->nr_channels == 2) {
+                    border_swizzled[3] = border_swizzled[1];
+                    util_pack_color(border_swizzled, PIPE_FORMAT_L8A8_SRGB, &uc);
+                } else {
+                    util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SRGB, &uc);
+                }
+            } else {
+                util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
+            }
             break;
 
         case 10: