gallium: fix BGRA vertex color swizzles
authorMarek Olšák <maraeo@gmail.com>
Tue, 9 Mar 2010 01:55:42 +0000 (01:55 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 12 Mar 2010 12:00:27 +0000 (12:00 +0000)
The mapping for vertex_array_bgra:
(gl -> st -> translate)
GL_RGBA -> PIPE_FORMAT_R8G8B8A8 (RGBA) -> no swizzle (XYZW)
GL_BGRA -> PIPE_FORMAT_A8R8G8B8 (ARGB) -> ZYXW (BGRA again??)

Iẗ́'s pretty clear that PIPE_FORMAT_A8R8G8B8 here is wrong. This commit
fixes the pipe format and removes obvious workarounds in util/translate.

Tested with: softpipe, llvmpipe, r300g.

Signed-off-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/translate/translate_generic.c
src/gallium/auxiliary/translate/translate_sse.c
src/mesa/state_tracker/st_draw.c

index c9ec2b32bfec0e17f99c0df36973d952df056f6a..c3ec9ae3f4b611b9d048432c2557bff6c01e0f68 100644 (file)
@@ -393,10 +393,10 @@ static fetch_func get_fetch_func( enum pipe_format format )
       return &fetch_R8G8B8A8_SSCALED;
 
    case PIPE_FORMAT_B8G8R8A8_UNORM:
-      return &fetch_A8R8G8B8_UNORM;
+      return &fetch_B8G8R8A8_UNORM;
 
    case PIPE_FORMAT_A8R8G8B8_UNORM:
-      return &fetch_B8G8R8A8_UNORM;
+      return &fetch_A8R8G8B8_UNORM;
 
    case PIPE_FORMAT_R32_FIXED:
       return &fetch_R32_FIXED;
@@ -552,10 +552,10 @@ static emit_func get_emit_func( enum pipe_format format )
       return &emit_R8G8B8A8_SSCALED;
 
    case PIPE_FORMAT_B8G8R8A8_UNORM:
-      return &emit_A8R8G8B8_UNORM;
+      return &emit_B8G8R8A8_UNORM;
 
    case PIPE_FORMAT_A8R8G8B8_UNORM:
-      return &emit_B8G8R8A8_UNORM;
+      return &emit_A8R8G8B8_UNORM;
 
    default:
       assert(0); 
index 03e093c11eada79793b00d13b3dd1cac77042c23..c13e7427387985418d8d851cacfde2d2385d830d 100644 (file)
@@ -336,7 +336,7 @@ static boolean translate_attr( struct translate_sse *p,
    case PIPE_FORMAT_R32G32B32A32_FLOAT:
       emit_load_R32G32B32A32(p, dataXMM, srcECX);
       break;
-   case PIPE_FORMAT_A8R8G8B8_UNORM:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
       emit_load_R8G8B8A8_UNORM(p, dataXMM, srcECX);
       emit_swizzle(p, dataXMM, dataXMM, SHUF(Z,Y,X,W));
       break;
@@ -360,7 +360,7 @@ static boolean translate_attr( struct translate_sse *p,
    case PIPE_FORMAT_R32G32B32A32_FLOAT:
       emit_store_R32G32B32A32(p, dstEAX, dataXMM);
       break;
-   case PIPE_FORMAT_A8R8G8B8_UNORM:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
       emit_swizzle(p, dataXMM, dataXMM, SHUF(Z,Y,X,W));
       emit_store_R8G8B8A8_UNORM(p, dstEAX, dataXMM);
       break;
index d81b3611b7dee6756200f89c0a917f2b8511921e..c473815c419c6e12b80e89558d4eba2d2529fa15 100644 (file)
@@ -184,7 +184,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
       /* this is an odd-ball case */
       assert(type == GL_UNSIGNED_BYTE);
       assert(normalized);
-      return PIPE_FORMAT_A8R8G8B8_UNORM;
+      return PIPE_FORMAT_B8G8R8A8_UNORM;
    }
 
    if (normalized) {