[PATCH] WineD3D: Use a separate enum for pixel format fixups=0A=

Stefan Doesinger stefan at codeweavers.com
Wed Nov 26 21:46:19 CST 2008


=0A=
This allows better control over the format fixup, so we can e.g.=0A=
put D3DFMT_V8U8(with texture_shader) and D3DFMT_G16R16F into the=0A=
same conversion group, and (later on) allows to pack the format=0A=
conversion information in pixel shader and fragment processing=0A=
description structures better=0A=
---=0A=
 dlls/wined3d/arb_program_shader.c  |  279 =
+++++++++++++++++-------------------=0A=
 dlls/wined3d/ati_fragment_shader.c |    9 +-=0A=
 dlls/wined3d/directx.c             |    4 +-=0A=
 dlls/wined3d/glsl_shader.c         |  211 ++++++++++++++-------------=0A=
 dlls/wined3d/utils.c               |   46 ++++--=0A=
 dlls/wined3d/wined3d_gl.h          |   18 +++-=0A=
 dlls/wined3d/wined3d_private.h     |    6 +-=0A=
 7 files changed, 308 insertions(+), 265 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/arb_program_shader.c =
b/dlls/wined3d/arb_program_shader.c=0A=
index 9194673..5d3a546 100644=0A=
--- a/dlls/wined3d/arb_program_shader.c=0A=
+++ b/dlls/wined3d/arb_program_shader.c=0A=
@@ -596,149 +596,136 @@ static void shader_hw_sample(const =
SHADER_OPCODE_ARG *arg, DWORD sampler_idx, co=0A=
 }=0A=
 =0A=
 static void gen_color_correction(SHADER_BUFFER *buffer, const char =
*reg, const char *writemask,=0A=
-                                 const char *one, const char *two, =
WINED3DFORMAT fmt,=0A=
-                                 const WineD3D_GL_Info *gl_info)=0A=
-{=0A=
-    switch(fmt) {=0A=
-        case WINED3DFMT_V8U8:=0A=
-        case WINED3DFMT_V16U16:=0A=
-            if(GL_SUPPORT(NV_TEXTURE_SHADER) && fmt =3D=3D =
WINED3DFMT_V8U8) {=0A=
-                /* The 3rd channel returns 1.0 in d3d, but 0.0 in gl. =
Fix this while we're at it :-)=0A=
-                 * The dx7 sdk BumpEarth demo needs it because it uses =
BUMPENVMAPLUMINANCE with V8U8.=0A=
-                 * With the luminance(b) value =3D 1.0, =
BUMPENVMAPLUMINANCE =3D=3D BUMPENVMAP, but if b is=0A=
-                 * 0.0(without this fixup), the rendering breaks.=0A=
-                 */=0A=
-                if(strlen(writemask) >=3D 4) {=0A=
-                    shader_addline(buffer, "MOV %s.%c, %s;\n", reg, =
writemask[3], one);=0A=
-                }=0A=
-            } else {=0A=
-                /* Correct the sign, but leave the blue as it is - it =
was loaded correctly already=0A=
-                 * ARB shaders are a bit picky wrt writemasks and =
swizzles. If we're free to scale=0A=
-                 * all registers, do so, this saves an instruction.=0A=
-                 */=0A=
-                if(strlen(writemask) >=3D 5) {=0A=
-                    shader_addline(buffer, "MAD %s, %s, %s, -%s;\n", =
reg, reg, two, one);=0A=
-                } else if(strlen(writemask) >=3D 3) {=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n",=0A=
-                                   reg, writemask[1],=0A=
-                                   reg, writemask[1],=0A=
-                                   two, one);=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n",=0A=
-                                   reg, writemask[2],=0A=
-                                   reg, writemask[2],=0A=
-                                   two, one);=0A=
-                } else if(strlen(writemask) =3D=3D 2) {=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n", reg, writemask[1],=0A=
-                                   reg, writemask[1], two, one);=0A=
-                }=0A=
+                                 const char *one, const char *two, enum =
shader_color_conv correction) {=0A=
+    switch(correction) {=0A=
+        case set_blue_1:=0A=
+            /* Applies to V8U8, V16U16, G16R16, R16R16F, G32R32F=0A=
+             */=0A=
+            if(strlen(writemask) >=3D 4) {=0A=
+                shader_addline(buffer, "MOV %s.%c, %s;\n", reg, =
writemask[3], one);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_X8L8V8U8:=0A=
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
-                /* Red and blue are the signed channels, fix them up; =
Blue(=3DL) is correct already,=0A=
-                 * and a(X) is always 1.0. Cannot do a full conversion =
due to L(blue)=0A=
-                 */=0A=
-                if(strlen(writemask) >=3D 3) {=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n",=0A=
-                                   reg, writemask[1],=0A=
-                                   reg, writemask[1],=0A=
-                                   two, one);=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n",=0A=
-                                   reg, writemask[2],=0A=
-                                   reg, writemask[2],=0A=
-                                   two, one);=0A=
-                } else if(strlen(writemask) =3D=3D 2) {=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n",=0A=
-                                   reg, writemask[1],=0A=
-                                   reg, writemask[1],=0A=
-                                   two, one);=0A=
-                }=0A=
+        case signed_2_no_ba:=0A=
+            /* Applies to V8U8, V16U16. Input blue and alpha are 1.0, =
so the output=0A=
+             * is 1.0 as well=0A=
+             */=0A=
+            if(strlen(writemask) >=3D 5) {=0A=
+                shader_addline(buffer, "MAD %s, %s, %s, -%s;\n", reg, =
reg, two, one);=0A=
+            } else if(strlen(writemask) >=3D 3) {=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",=0A=
+                               reg, writemask[1],=0A=
+                               reg, writemask[1],=0A=
+                               two, one);=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",=0A=
+                               reg, writemask[2],=0A=
+                               reg, writemask[2],=0A=
+                               two, one);=0A=
+            } else if(strlen(writemask) =3D=3D 2) {=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n", =
reg, writemask[1],=0A=
+                                reg, writemask[1], two, one);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_L6V5U5:=0A=
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
-                if(strlen(writemask) >=3D 4) {=0A=
-                    /* Swap y and z (U and L), and do a sign conversion =
on x and the new y(V and U) */=0A=
-                    shader_addline(buffer, "MOV TMP.g, %s.%c;\n",=0A=
-                                   reg, writemask[2]);=0A=
-                    shader_addline(buffer, "MAD %s.%c%c, %s.%c%c%c%c, =
%s, -%s;\n",=0A=
-                                   reg, writemask[1], writemask[2],=0A=
-                                   reg, writemask[3], writemask[1], =
writemask[3], writemask[1],=0A=
-                                   two, one);=0A=
-                    shader_addline(buffer, "MOV %s.%c, TMP.g;\n", reg,=0A=
-                                   writemask[3]);=0A=
-                } else if(strlen(writemask) =3D=3D 3) {=0A=
-                    /* This is bad: We have VL, but we need VU */=0A=
-                    FIXME("2 components sampled from a converted L6V5U5 =
texture\n");=0A=
-                } else {=0A=
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, =
-%s;\n",=0A=
-                                   reg, writemask[1],=0A=
-                                   reg, writemask[1],=0A=
-                                   two, one);=0A=
-                }=0A=
+        case signed_2:=0A=
+            /* Red and blue are the signed channels, fix them up; =
Blue(=3DL) is correct already,=0A=
+             * and a(X) is always 1.0. Cannot do a full conversion due =
to L(blue)=0A=
+             */=0A=
+            if(strlen(writemask) >=3D 3) {=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",=0A=
+                                reg, writemask[1],=0A=
+                                reg, writemask[1],=0A=
+                                two, one);=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",=0A=
+                                reg, writemask[2],=0A=
+                                reg, writemask[2],=0A=
+                                two, one);=0A=
+            } else if(strlen(writemask) =3D=3D 2) {=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",=0A=
+                                reg, writemask[1],=0A=
+                                reg, writemask[1],=0A=
+                                two, one);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_Q8W8V8U8:=0A=
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
-                /* Correct the sign in all channels */=0A=
-                switch(strlen(writemask)) {=0A=
-                    case 4:=0A=
-                        shader_addline(buffer, "MAD %s.%c, %s.%c, =
coefmul.x, -one;\n",=0A=
-                                       reg, writemask[3],=0A=
-                                       reg, writemask[3]);=0A=
-                        /* drop through */=0A=
-                    case 3:=0A=
-                        shader_addline(buffer, "MAD %s.%c, %s.%c, =
coefmul.x, -one;\n",=0A=
-                                       reg, writemask[2],=0A=
-                                       reg, writemask[2]);=0A=
-                        /* drop through */=0A=
-                    case 2:=0A=
-                        shader_addline(buffer, "MAD %s.%c, %s.%c, =
coefmul.x, -one;\n",=0A=
-                                       reg, writemask[1],=0A=
-                                       reg, writemask[1]);=0A=
-                        break;=0A=
-=0A=
-                        /* Should not occur, since it's at minimum '.' =
and a letter */=0A=
-                    case 1:=0A=
-                        ERR("Unexpected writemask: \"%s\"\n", =
writemask);=0A=
-                        break;=0A=
-=0A=
-                    case 5:=0A=
-                    default:=0A=
-                        shader_addline(buffer, "MAD %s, %s, coefmul.x, =
-one;\n", reg, reg);=0A=
-                }=0A=
+        case signed_l6v5u5:=0A=
+            if(strlen(writemask) >=3D 4) {=0A=
+                /* Swap y and z (U and L), and do a sign conversion on =
x and the new y(V and U) */=0A=
+                shader_addline(buffer, "MOV TMP.g, %s.%c;\n",=0A=
+                                reg, writemask[2]);=0A=
+                shader_addline(buffer, "MAD %s.%c%c, %s.%c%c%c%c, %s, =
-%s;\n",=0A=
+                                reg, writemask[1], writemask[2],=0A=
+                                reg, writemask[3], writemask[1], =
writemask[3], writemask[1],=0A=
+                                two, one);=0A=
+                shader_addline(buffer, "MOV %s.%c, TMP.g;\n", reg,=0A=
+                                writemask[3]);=0A=
+            } else if(strlen(writemask) =3D=3D 3) {=0A=
+                /* This is bad: We have VL, but we need VU */=0A=
+                FIXME("2 components sampled from a converted L6V5U5 =
texture\n");=0A=
+            } else {=0A=
+                shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",=0A=
+                                reg, writemask[1],=0A=
+                                reg, writemask[1],=0A=
+                                two, one);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_ATI2N:=0A=
-            /* GL_ATI_texture_compression_3dc returns the two channels =
as luminance-alpha,=0A=
-             * which means the first one is replicated across .rgb, and =
the 2nd one is in=0A=
-             * .a. We need the 2nd in .g=0A=
-             *=0A=
-             * GL_EXT_texture_compression_rgtc returns the values in =
.rg, however, they=0A=
-             * are swapped compared to d3d. So swap red and green.=0A=
-             */=0A=
-            if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {=0A=
-                shader_addline(buffer, "SWZ %s, %s, %c, %c, 1, 0;\n",=0A=
-                               reg, reg, writemask[2], writemask[1]);=0A=
+        case signed_4:=0A=
+            /* Correct the sign in all channels */=0A=
+            switch(strlen(writemask)) {=0A=
+                case 4:=0A=
+                    shader_addline(buffer, "MAD %s.%c, %s.%c, =
coefmul.x, -one;\n",=0A=
+                                    reg, writemask[3],=0A=
+                                    reg, writemask[3]);=0A=
+                /* drop through */=0A=
+                case 3:=0A=
+                    shader_addline(buffer, "MAD %s.%c, %s.%c, =
coefmul.x, -one;\n",=0A=
+                                    reg, writemask[2],=0A=
+                                    reg, writemask[2]);=0A=
+                /* drop through */=0A=
+                case 2:=0A=
+                    shader_addline(buffer, "MAD %s.%c, %s.%c, =
coefmul.x, -one;\n",=0A=
+                                   reg, writemask[1],=0A=
+                                   reg, writemask[1]);=0A=
+                    break;=0A=
+=0A=
+                /* Should not occur, since it's at minimum '.' and a =
letter */=0A=
+                case 1:=0A=
+                    ERR("Unexpected writemask: \"%s\"\n", writemask);=0A=
+                    break;=0A=
+=0A=
+                case 5:=0A=
+                default:=0A=
+                    shader_addline(buffer, "MAD %s, %s, coefmul.x, =
-one;\n", reg, reg);=0A=
+            }=0A=
+            break;=0A=
+=0A=
+        case swap_rg_blue_1:=0A=
+            shader_addline(buffer, "SWZ %s, %s, %c, %c, 1, 1;\n",=0A=
+                          reg, reg, writemask[2], writemask[1]);=0A=
+            break;=0A=
+=0A=
+        case a_to_g_ba_1:=0A=
+            if(strlen(writemask) =3D=3D 5) {=0A=
+                shader_addline(buffer, "SWZ %s, %s, %c, %c, 1, 1;\n",=0A=
+                               reg, reg, writemask[1], writemask[4]);=0A=
+            } else if(strlen(writemask) =3D=3D 2) {=0A=
+                /* Nothing to do */=0A=
             } else {=0A=
-                if(strlen(writemask) =3D=3D 5) {=0A=
-                    shader_addline(buffer, "MOV %s.%c, %s.%c;\n",=0A=
-                                reg, writemask[2], reg, writemask[4]);=0A=
-                } else if(strlen(writemask) =3D=3D 2) {=0A=
-                    /* Nothing to do */=0A=
-                } else {=0A=
-                    /* This is bad: We have VL, but we need VU */=0A=
-                    FIXME("2 or 3 components sampled from a converted =
ATI2N texture\n");=0A=
-                }=0A=
+                /* This is bad: We have VL, but we need VU */=0A=
+                FIXME("2 or 3 components sampled from a converted ATI2N =
texture\n");=0A=
             }=0A=
             break;=0A=
 =0A=
-            /* stupid compiler */=0A=
-        default:=0A=
+        case yuv_yuy2:=0A=
+        case yuv_uyvy:=0A=
+        case yuv_yv12:=0A=
+            /* This is only supported in blits */=0A=
+            FIXME("YUV conversion requested in d3d draw\n");=0A=
+            break;=0A=
+=0A=
+        case fmtconv_none:=0A=
+        case force_dword: /* Silence the compiler */=0A=
             break;=0A=
     }=0A=
 }=0A=
@@ -747,9 +734,8 @@ static void shader_arb_color_correction(const =
SHADER_OPCODE_ARG* arg)=0A=
 {=0A=
     IWineD3DBaseShaderImpl* shader =3D (IWineD3DBaseShaderImpl*) =
arg->shader;=0A=
     IWineD3DDeviceImpl* deviceImpl =3D (IWineD3DDeviceImpl*) =
shader->baseShader.device;=0A=
-    const WineD3D_GL_Info *gl_info =3D &deviceImpl->adapter->gl_info;=0A=
     WINED3DFORMAT fmt;=0A=
-    WINED3DFORMAT conversion_group;=0A=
+    enum shader_color_conv conversion_group;=0A=
     IWineD3DBaseTextureImpl *texture;=0A=
     UINT i;=0A=
     BOOL recorded =3D FALSE;=0A=
@@ -793,7 +779,7 @@ static void shader_arb_color_correction(const =
SHADER_OPCODE_ARG* arg)=0A=
         conversion_group =3D =
texture->baseTexture.shader_conversion_group;=0A=
     } else {=0A=
         fmt =3D WINED3DFMT_UNKNOWN;=0A=
-        conversion_group =3D WINED3DFMT_UNKNOWN;=0A=
+        conversion_group =3D fmtconv_none;=0A=
     }=0A=
 =0A=
     /* before doing anything, record the sampler with the format in the =
format conversion list,=0A=
@@ -814,7 +800,7 @@ static void shader_arb_color_correction(const =
SHADER_OPCODE_ARG* arg)=0A=
     shader_arb_get_write_mask(arg, arg->dst, writemask);=0A=
     if(strlen(writemask) =3D=3D 0) strcpy(writemask, ".xyzw");=0A=
 =0A=
-    gen_color_correction(arg->buffer, reg, writemask, "one", =
"coefmul.x", fmt, gl_info);=0A=
+    gen_color_correction(arg->buffer, reg, writemask, "one", =
"coefmul.x", conversion_group);=0A=
 =0A=
 }=0A=
 =0A=
@@ -2957,7 +2943,7 @@ static GLuint gen_arbfp_ffp_shader(const struct =
ffp_frag_settings *settings, IWi=0A=
 =0A=
         sprintf(colorcor_dst, "tex%u", stage);=0A=
         gen_color_correction(&buffer, colorcor_dst, ".rgba", "const.x", =
"const.y",=0A=
-                                settings->op[stage].color_correction, =
&GLINFO_LOCATION);=0A=
+                             settings->op[stage].color_correction);=0A=
     }=0A=
 =0A=
     /* Generate the main shader */=0A=
@@ -3328,11 +3314,11 @@ static void arbfp_blit_free(IWineD3DDevice =
*iface) {=0A=
     LEAVE_GL();=0A=
 }=0A=
 =0A=
-static BOOL gen_planar_yuv_read(SHADER_BUFFER *buffer, WINED3DFORMAT =
fmt, GLenum textype, char *luminance) {=0A=
+static BOOL gen_planar_yuv_read(SHADER_BUFFER *buffer, enum =
shader_color_conv conv, GLenum textype, char *luminance) {=0A=
     char chroma;=0A=
     const char *tex, *texinstr;=0A=
 =0A=
-    if(fmt =3D=3D WINED3DFMT_UYVY) {=0A=
+    if(conv =3D=3D yuv_uyvy) {=0A=
         chroma =3D 'r';=0A=
         *luminance =3D 'a';=0A=
     } else {=0A=
@@ -3559,7 +3545,7 @@ static BOOL gen_yv12_read(SHADER_BUFFER *buffer, =
WINED3DFORMAT fmt, GLenum texty=0A=
     return TRUE;=0A=
 }=0A=
 =0A=
-static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, WINED3DFORMAT =
fmt, GLenum textype) {=0A=
+static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum =
shader_color_conv conv, GLenum textype) {=0A=
     GLenum shader;=0A=
     SHADER_BUFFER buffer;=0A=
     char luminance_component;=0A=
@@ -3627,13 +3613,13 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl =
*device, WINED3DFORMAT fmt, GLen=0A=
     shader_addline(&buffer, "PARAM yuv_coef =3D {1.403, 0.344, 0.714, =
1.770};\n");=0A=
     shader_addline(&buffer, "PARAM size =3D program.local[0];\n");=0A=
 =0A=
-    if(fmt =3D=3D WINED3DFMT_UYVY || fmt =3D=3DWINED3DFMT_YUY2) {=0A=
-        if(gen_planar_yuv_read(&buffer, fmt, textype, =
&luminance_component) =3D=3D FALSE) {=0A=
+    if(conv =3D=3D yuv_uyvy || conv =3D=3Dyuv_yuy2) {=0A=
+        if(gen_planar_yuv_read(&buffer, conv, textype, =
&luminance_component) =3D=3D FALSE) {=0A=
             HeapFree(GetProcessHeap(), 0, buffer.buffer);=0A=
             return 0;=0A=
         }=0A=
     } else {=0A=
-        if(gen_yv12_read(&buffer, fmt, textype, &luminance_component) =
=3D=3D FALSE) {=0A=
+        if(gen_yv12_read(&buffer, conv, textype, &luminance_component) =
=3D=3D FALSE) {=0A=
             HeapFree(GetProcessHeap(), 0, buffer.buffer);=0A=
             return 0;=0A=
         }=0A=
@@ -3663,13 +3649,13 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl =
*device, WINED3DFORMAT fmt, GLen=0A=
     HeapFree(GetProcessHeap(), 0, buffer.buffer);=0A=
     LEAVE_GL();=0A=
 =0A=
-    if(fmt =3D=3D WINED3DFMT_YUY2) {=0A=
+    if(conv =3D=3D yuv_yuy2) {=0A=
         if(textype =3D=3D GL_TEXTURE_RECTANGLE_ARB) {=0A=
             priv->yuy2_rect_shader =3D shader;=0A=
         } else {=0A=
             priv->yuy2_2d_shader =3D shader;=0A=
         }=0A=
-    } else if(fmt =3D=3D WINED3DFMT_UYVY) {=0A=
+    } else if(conv =3D=3D yuv_uyvy) {=0A=
         if(textype =3D=3D GL_TEXTURE_RECTANGLE_ARB) {=0A=
             priv->uyvy_rect_shader =3D shader;=0A=
         } else {=0A=
@@ -3694,8 +3680,13 @@ static HRESULT arbfp_blit_set(IWineD3DDevice =
*iface, WINED3DFORMAT fmt, GLenum t=0A=
 =0A=
     getFormatDescEntry(fmt, &GLINFO_LOCATION, &glDesc);=0A=
 =0A=
-    if(glDesc->conversion_group !=3D WINED3DFMT_YUY2 && =
glDesc->conversion_group !=3D WINED3DFMT_UYVY &&=0A=
-       glDesc->conversion_group !=3D WINED3DFMT_YV12) {=0A=
+    if(glDesc->conversion_group !=3D yuv_yuy2 && =
glDesc->conversion_group !=3D yuv_uyvy &&=0A=
+       glDesc->conversion_group !=3D yuv_yv12) {=0A=
+        if(glDesc->conversion_group !=3D fmtconv_none) {=0A=
+            FIXME("Unsupported blit source format %s\n", =
debug_d3dformat(fmt));=0A=
+            return WINED3DERR_INVALIDCALL;=0A=
+        }=0A=
+=0A=
         TRACE("Format: %s\n", =
debug_d3dformat(glDesc->conversion_group));=0A=
         /* Don't bother setting up a shader for unconverted formats */=0A=
         ENTER_GL();=0A=
@@ -3705,13 +3696,13 @@ static HRESULT arbfp_blit_set(IWineD3DDevice =
*iface, WINED3DFORMAT fmt, GLenum t=0A=
         return WINED3D_OK;=0A=
     }=0A=
 =0A=
-    if(glDesc->conversion_group =3D=3D WINED3DFMT_YUY2) {=0A=
+    if(glDesc->conversion_group =3D=3D yuv_yuy2) {=0A=
         if(textype =3D=3D GL_TEXTURE_RECTANGLE_ARB) {=0A=
             shader =3D priv->yuy2_rect_shader;=0A=
         } else {=0A=
             shader =3D priv->yuy2_2d_shader;=0A=
         }=0A=
-    } else if(glDesc->conversion_group =3D=3D WINED3DFMT_UYVY) {=0A=
+    } else if(glDesc->conversion_group =3D=3D yuv_uyvy) {=0A=
         if(textype =3D=3D GL_TEXTURE_RECTANGLE_ARB) {=0A=
             shader =3D priv->uyvy_rect_shader;=0A=
         } else {=0A=
diff --git a/dlls/wined3d/ati_fragment_shader.c =
b/dlls/wined3d/ati_fragment_shader.c=0A=
index 4cb551b..5609b98 100644=0A=
--- a/dlls/wined3d/ati_fragment_shader.c=0A=
+++ b/dlls/wined3d/ati_fragment_shader.c=0A=
@@ -343,8 +343,13 @@ static GLuint gen_ati_shader(struct =
texture_stage_op op[MAX_TEXTURES], WineD3D_G=0A=
         if(op[stage].cop !=3D WINED3DTOP_BUMPENVMAP &&=0A=
            op[stage].cop !=3D WINED3DTOP_BUMPENVMAPLUMINANCE) continue;=0A=
 =0A=
-        /* Nice thing, we get the color correction for free :-) */=0A=
-        if(op[stage].color_correction =3D=3D WINED3DFMT_V8U8) {=0A=
+        /* Nice thing, we get the color correction for free :-)=0A=
+         * Don't bother about the blue and alpha parts. We don't =
support BUMPENVMAPLUMINANCE, so=0A=
+         * it doesn't matter=0A=
+         */=0A=
+        if(op[stage].color_correction =3D=3D signed_2_no_ba  ||=0A=
+           op[stage].color_correction =3D=3D signed_2        ||=0A=
+           op[stage].color_correction =3D=3D signed_4) {=0A=
             argmodextra =3D GL_2X_BIT_ATI | GL_BIAS_BIT_ATI;=0A=
         } else {=0A=
             argmodextra =3D 0;=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index 9716398..c3a35a4 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -1990,7 +1990,7 @@ static BOOL CheckBumpMapCapability(UINT Adapter, =
WINED3DDEVTYPE DeviceType, WINE=0A=
         case WINED3DFMT_X8L8V8U8:=0A=
         case WINED3DFMT_Q8W8V8U8:=0A=
             getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);=0A=
-            if(glDesc->conversion_group =3D=3D WINED3DFMT_UNKNOWN) {=0A=
+            if(glDesc->conversion_group =3D=3D fmtconv_none) {=0A=
                 /* We have a GL extension giving native support */=0A=
                 TRACE_(d3d_caps)("[OK]\n");=0A=
                 return TRUE;=0A=
@@ -2278,7 +2278,7 @@ static BOOL CheckTextureCapability(UINT Adapter, =
WINED3DDEVTYPE DeviceType, WINE=0A=
         case WINED3DFMT_V16U16:=0A=
         case WINED3DFMT_W11V11U10:=0A=
             getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);=0A=
-            if(glDesc->conversion_group =3D=3D WINED3DFMT_UNKNOWN) {=0A=
+            if(glDesc->conversion_group =3D=3D fmtconv_none) {=0A=
                 /* We have a GL extension giving native support */=0A=
                 TRACE_(d3d_caps)("[OK]\n");=0A=
                 return TRUE;=0A=
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c=0A=
index 6784b96..7f30888 100644=0A=
--- a/dlls/wined3d/glsl_shader.c=0A=
+++ b/dlls/wined3d/glsl_shader.c=0A=
@@ -1177,11 +1177,10 @@ static void shader_glsl_color_correction(const =
SHADER_OPCODE_ARG *arg)=0A=
 {=0A=
     IWineD3DBaseShaderImpl* shader =3D (IWineD3DBaseShaderImpl*) =
arg->shader;=0A=
     IWineD3DDeviceImpl* deviceImpl =3D (IWineD3DDeviceImpl*) =
shader->baseShader.device;=0A=
-    const WineD3D_GL_Info *gl_info =3D &deviceImpl->adapter->gl_info;=0A=
     glsl_dst_param_t dst_param;=0A=
     glsl_dst_param_t dst_param2;=0A=
     WINED3DFORMAT fmt;=0A=
-    WINED3DFORMAT conversion_group;=0A=
+    enum shader_color_conv conversion_group;=0A=
     IWineD3DBaseTextureImpl *texture;=0A=
     DWORD mask, mask_size;=0A=
     UINT i;=0A=
@@ -1224,7 +1223,7 @@ static void shader_glsl_color_correction(const =
SHADER_OPCODE_ARG *arg)=0A=
         conversion_group =3D =
texture->baseTexture.shader_conversion_group;=0A=
     } else {=0A=
         fmt =3D WINED3DFMT_UNKNOWN;=0A=
-        conversion_group =3D WINED3DFMT_UNKNOWN;=0A=
+        conversion_group =3D fmtconv_none;=0A=
     }=0A=
 =0A=
     /* before doing anything, record the sampler with the format in the =
format conversion list,=0A=
@@ -1242,92 +1241,89 @@ static void shader_glsl_color_correction(const =
SHADER_OPCODE_ARG *arg)=0A=
         shader->baseShader.sampled_format[sampler_idx] =3D =
conversion_group;=0A=
     }=0A=
 =0A=
-    switch(fmt) {=0A=
-        case WINED3DFMT_V8U8:=0A=
-        case WINED3DFMT_V16U16:=0A=
-            if(GL_SUPPORT(NV_TEXTURE_SHADER) && fmt =3D=3D =
WINED3DFMT_V8U8) {=0A=
-                /* The 3rd channel returns 1.0 in d3d, but 0.0 in gl. =
Fix this while we're at it :-) */=0A=
-                mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_2, &dst_param);=0A=
-                mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
-                if(mask_size >=3D 3) {=0A=
-                    shader_addline(arg->buffer, "%s.%c =3D 1.0;\n", =
dst_param.reg_name, dst_param.mask_str[3]);=0A=
-                }=0A=
-            } else {=0A=
-                /* Correct the sign, but leave the blue as it is - it =
was loaded correctly already */=0A=
-                mask =3D shader_glsl_add_dst_param(arg, arg->dst,=0A=
-                                          WINED3DSP_WRITEMASK_0 | =
WINED3DSP_WRITEMASK_1,=0A=
-                                          &dst_param);=0A=
-                mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
-                if(mask_size >=3D 2) {=0A=
-                    shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c * =
2.0 - 1.0;\n",=0A=
-                    dst_param.reg_name, dst_param.mask_str[1], =
dst_param.mask_str[2],=0A=
-                    dst_param.reg_name, dst_param.mask_str[1], =
dst_param.mask_str[2]);=0A=
-                } else if(mask_size =3D=3D 1) {=0A=
-                    shader_addline(arg->buffer, "%s.%c =3D %s.%c * 2.0 =
- 1.0;\n", dst_param.reg_name, dst_param.mask_str[1],=0A=
-                    dst_param.reg_name, dst_param.mask_str[1]);=0A=
-                }=0A=
+    switch(conversion_group) {=0A=
+        case set_blue_1:=0A=
+            /* V16U16, V8U8, G16R16, G16R16F, G32R32F with native GL =
support */=0A=
+            mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_2, &dst_param);=0A=
+            mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
+            if(mask_size >=3D 3) {=0A=
+                shader_addline(arg->buffer, "%s.%c =3D 1.0;\n", =
dst_param.reg_name, dst_param.mask_str[3]);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_X8L8V8U8:=0A=
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
-                /* Red and blue are the signed channels, fix them up; =
Blue(=3DL) is correct already,=0A=
-                 * and a(X) is always 1.0=0A=
-                 */=0A=
-                mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);=0A=
-                mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
-                if(mask_size >=3D 2) {=0A=
-                    shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c * =
2.0 - 1.0;\n",=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[1], dst_param.mask_str[2],=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[1], dst_param.mask_str[2]);=0A=
-                } else if(mask_size =3D=3D 1) {=0A=
-                    shader_addline(arg->buffer, "%s.%c =3D %s.%c * 2.0 =
- 1.0;\n",=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[1],=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[1]);=0A=
-                }=0A=
+        case signed_2_no_ba:=0A=
+            /* Correct the sign, but leave the blue as it is - it was =
loaded correctly already=0A=
+             * V8U8 and V16U16 without GL_NV_texture_shader or =
GL_ATI_envmap_bumpmap=0A=
+             */=0A=
+            mask =3D shader_glsl_add_dst_param(arg, arg->dst,=0A=
+                                             WINED3DSP_WRITEMASK_0 | =
WINED3DSP_WRITEMASK_1,=0A=
+                                             &dst_param);=0A=
+            mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
+            if(mask_size >=3D 2) {=0A=
+                shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c * =
vec2(2.0) - vec2(1.0);\n",=0A=
+                dst_param.reg_name, dst_param.mask_str[1], =
dst_param.mask_str[2],=0A=
+                dst_param.reg_name, dst_param.mask_str[1], =
dst_param.mask_str[2]);=0A=
+            } else if(mask_size =3D=3D 1) {=0A=
+                shader_addline(arg->buffer, "%s.%c =3D %s.%c * 2.0 - =
1.0;\n", dst_param.reg_name, dst_param.mask_str[1],=0A=
+                dst_param.reg_name, dst_param.mask_str[1]);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_L6V5U5:=0A=
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
-                mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);=0A=
-                mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
-                shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_2, &dst_param2);=0A=
-                if(mask_size >=3D 3) {=0A=
-                    /* Swap y and z (U and L), and do a sign conversion =
on x and the new y(V and U) */=0A=
-                    shader_addline(arg->buffer, "tmp0.g =3D %s.%c;\n",=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[2]);=0A=
-                    shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c * =
2.0 - 1.0;\n",=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[2], dst_param.mask_str[1],=0A=
-                                   dst_param2.reg_name, =
dst_param.mask_str[1], dst_param.mask_str[3]);=0A=
-                    shader_addline(arg->buffer, "%s.%c =3D tmp0.g;\n", =
dst_param.reg_name,=0A=
-                                   dst_param.mask_str[3]);=0A=
-                } else if(mask_size =3D=3D 2) {=0A=
-                    /* This is bad: We have VL, but we need VU */=0A=
-                    FIXME("2 components sampled from a converted L6V5U5 =
texture\n");=0A=
-                } else {=0A=
-                    shader_addline(arg->buffer, "%s.%c =3D %s.%c * 2.0 =
- 1.0;\n",=0A=
-                                   dst_param.reg_name, =
dst_param.mask_str[1],=0A=
-                                   dst_param2.reg_name, =
dst_param.mask_str[1]);=0A=
-                }=0A=
+        case signed_2:=0A=
+            /* Red and blue are the signed channels, fix them up; =
Blue(=3DL) is correct already,=0A=
+             * so don't touch it(D3DFMT_X8L8V8U8 without =
GL_NV_texture_shader=0A=
+             */=0A=
+            mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);=0A=
+            mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
+            if(mask_size >=3D 2) {=0A=
+                shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c * =
vec2(2.0) - vec2(1.0);\n",=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[1], dst_param.mask_str[2],=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[1], dst_param.mask_str[2]);=0A=
+            } else if(mask_size =3D=3D 1) {=0A=
+                shader_addline(arg->buffer, "%s.%c =3D %s.%c * 2.0 - =
1.0;\n",=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[1],=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[1]);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_Q8W8V8U8:=0A=
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
-                /* Correct the sign in all channels. The writemask just =
applies as-is, no=0A=
-                 * need for checking the mask size=0A=
-                 */=0A=
-                shader_glsl_add_dst_param(arg, arg->dst,=0A=
-                                          WINED3DSP_WRITEMASK_0 | =
WINED3DSP_WRITEMASK_1 |=0A=
-                                          WINED3DSP_WRITEMASK_2 | =
WINED3DSP_WRITEMASK_3,=0A=
-                                          &dst_param);=0A=
-                shader_addline(arg->buffer, "%s%s =3D %s%s * 2.0 - =
1.0;\n", dst_param.reg_name, dst_param.mask_str,=0A=
-                               dst_param.reg_name, dst_param.mask_str);=0A=
+        case signed_l6v5u5:=0A=
+            /* D3DFMT_L6V5U5 without GL_NV_texture_shader */=0A=
+            mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);=0A=
+            mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
+            shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_2, &dst_param2);=0A=
+            if(mask_size >=3D 3) {=0A=
+                /* Swap y and z (U and L), and do a sign conversion on =
x and the new y(V and U) */=0A=
+                shader_addline(arg->buffer, "tmp0.g =3D %s.%c;\n",=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[2]);=0A=
+                shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c * =
vec2(2.0) - vec2(1.0);\n",=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[2], dst_param.mask_str[1],=0A=
+                                dst_param2.reg_name, =
dst_param.mask_str[1], dst_param.mask_str[3]);=0A=
+                shader_addline(arg->buffer, "%s.%c =3D tmp0.g;\n", =
dst_param.reg_name,=0A=
+                                dst_param.mask_str[3]);=0A=
+            } else if(mask_size =3D=3D 2) {=0A=
+                /* This is bad: We have VL, but we need VU */=0A=
+                FIXME("2 components sampled from a converted L6V5U5 =
texture\n");=0A=
+            } else {=0A=
+                shader_addline(arg->buffer, "%s.%c =3D %s.%c * 2.0 - =
1.0;\n",=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[1],=0A=
+                                dst_param2.reg_name, =
dst_param.mask_str[1]);=0A=
             }=0A=
             break;=0A=
 =0A=
-        case WINED3DFMT_ATI2N:=0A=
+        case signed_4:=0A=
+            /* D3DFMT_Q8W8V8U8 without GL_NV_texture_shader */=0A=
+            /* Correct the sign in all channels. The writemask just =
applies as-is, no=0A=
+             * need for checking the mask size=0A=
+             */=0A=
+            shader_glsl_add_dst_param(arg, arg->dst,=0A=
+                                        WINED3DSP_WRITEMASK_0 | =
WINED3DSP_WRITEMASK_1 |=0A=
+                                        WINED3DSP_WRITEMASK_2 | =
WINED3DSP_WRITEMASK_3,=0A=
+                                        &dst_param);=0A=
+            shader_addline(arg->buffer, "%s%s =3D %s%s * 2.0 - 1.0;\n", =
dst_param.reg_name, dst_param.mask_str,=0A=
+                            dst_param.reg_name, dst_param.mask_str);=0A=
+            break;=0A=
+=0A=
+        case swap_rg_blue_1:=0A=
             /* GL_ATI_texture_compression_3dc returns the two channels =
as luminance-alpha,=0A=
              * which means the first one is replicated across .rgb, and =
the 2nd one is in=0A=
              * .a. We need the 2nd in .g=0A=
@@ -1337,33 +1333,50 @@ static void shader_glsl_color_correction(const =
SHADER_OPCODE_ARG *arg)=0A=
              */=0A=
             mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);=0A=
             mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
-            if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {=0A=
-                if(mask_size >=3D 2) {=0A=
-                    shader_addline(arg->buffer, "%s.%c%c =3D =
%s.%c%c;\n",=0A=
-                                dst_param.reg_name, =
dst_param.mask_str[1],=0A=
-                                                    =
dst_param.mask_str[2],=0A=
-                                dst_param.reg_name, =
dst_param.mask_str[2],=0A=
-                                                    =
dst_param.mask_str[1]);=0A=
-                } else {=0A=
-                    FIXME("%u components sampled from a converted ATI2N =
texture\n", mask_size);=0A=
+            if(mask_size >=3D 2) {=0A=
+                shader_addline(arg->buffer, "%s.%c%c =3D %s.%c%c;\n",=0A=
+                            dst_param.reg_name, dst_param.mask_str[1],=0A=
+                                                dst_param.mask_str[2],=0A=
+                            dst_param.reg_name, dst_param.mask_str[2],=0A=
+                                                dst_param.mask_str[1]);=0A=
+                if(mask_size >=3D 3) {=0A=
+                    shader_addline(arg->buffer, "%s.%c =3D 1.0;\n",=0A=
+                                   dst_param.reg_name, =
dst_param.mask_str[3]);=0A=
                 }=0A=
             } else {=0A=
-                if(mask_size =3D=3D 4) {=0A=
-                    /* Swap y and z (U and L), and do a sign conversion =
on x and the new y(V and U) */=0A=
-                    shader_addline(arg->buffer, "%s.%c =3D %s.%c;\n",=0A=
-                                dst_param.reg_name, =
dst_param.mask_str[2],=0A=
-                                dst_param.reg_name, =
dst_param.mask_str[4]);=0A=
-                } else if(mask_size =3D=3D 1) {=0A=
-                    /* Nothing to do */=0A=
-                } else {=0A=
-                    FIXME("%u components sampled from a converted ATI2N =
texture\n", mask_size);=0A=
-                    /* This is bad: We have .r[gb], but we need .ra */=0A=
-                }=0A=
+                FIXME("%u components sampled from a converted ATI2N =
texture\n", mask_size);=0A=
             }=0A=
             break;=0A=
 =0A=
-            /* stupid compiler */=0A=
-        default:=0A=
+        case a_to_g_ba_1:=0A=
+            mask =3D shader_glsl_add_dst_param(arg, arg->dst, =
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);=0A=
+            mask_size =3D shader_glsl_get_write_mask_size(mask);=0A=
+            if(mask_size =3D=3D 4) {=0A=
+                /* Swap y and z (U and L), and do a sign conversion on =
x and the new y(V and U) */=0A=
+                shader_addline(arg->buffer, "%s.%c =3D %s.%c;\n",=0A=
+                               dst_param.reg_name, =
dst_param.mask_str[2],=0A=
+                               dst_param.reg_name, =
dst_param.mask_str[4]);=0A=
+                shader_addline(arg->buffer, "%s.%c%c =3D 1.0;\n",=0A=
+                                dst_param.reg_name, =
dst_param.mask_str[3],=0A=
+                                dst_param.mask_str[4]);=0A=
+            } else if(mask_size =3D=3D 1) {=0A=
+                /* Nothing to do */=0A=
+            } else {=0A=
+                FIXME("%u components sampled from a converted ATI2N =
texture\n", mask_size);=0A=
+                /* This is bad: We have .r[gb], but we need .ra */=0A=
+            }=0A=
+            break;=0A=
+=0A=
+        case yuv_yuy2:=0A=
+        case yuv_uyvy:=0A=
+        case yuv_yv12:=0A=
+            /* Only supported in blits */=0A=
+            FIXME("YUV conversion requested in a d3d shader\n");=0A=
+            break;=0A=
+=0A=
+        /* Silence compiler warnings */=0A=
+        case fmtconv_none:=0A=
+        case force_dword:=0A=
             break;=0A=
     }=0A=
 }=0A=
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c=0A=
index 151e5ba..7845b8a 100644=0A=
--- a/dlls/wined3d/utils.c=0A=
+++ b/dlls/wined3d/utils.c=0A=
@@ -318,7 +318,7 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)=0A=
         gl_info->gl_formats[dst].glGammaInternal =3D =
gl_formats_template[src].glGammaInternal;=0A=
         gl_info->gl_formats[dst].glFormat        =3D =
gl_formats_template[src].glFormat;=0A=
         gl_info->gl_formats[dst].glType          =3D =
gl_formats_template[src].glType;=0A=
-        gl_info->gl_formats[dst].conversion_group=3D WINED3DFMT_UNKNOWN;=0A=
+        gl_info->gl_formats[dst].conversion_group=3D fmtconv_none;=0A=
         gl_info->gl_formats[dst].Flags           =3D =
gl_formats_template[src].Flags;=0A=
         gl_info->gl_formats[dst].heightscale     =3D 1.0;=0A=
 =0A=
@@ -370,23 +370,34 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)=0A=
      *=0A=
      * V8U8 and V16U16 need a fixup of the undefined blue channel. =
OpenGL=0A=
      * returns 0.0 when sampling from it, DirectX 1.0. So we always =
have in-shader=0A=
-     * conversion for this format.=0A=
+     * conversion for this format. The DirectX 7 BumpEarth sdk demo =
depends on this.=0A=
      */=0A=
-    dst =3D getFmtIdx(WINED3DFMT_V8U8);=0A=
-    gl_info->gl_formats[dst].conversion_group =3D WINED3DFMT_V8U8;=0A=
-    dst =3D getFmtIdx(WINED3DFMT_V16U16);=0A=
-    gl_info->gl_formats[dst].conversion_group =3D WINED3DFMT_V8U8;=0A=
+    if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
+        /* We do not care about the blue and alpha channel, the shader =
backend=0A=
+         * can mess around with them in any way it likes as long as the =
result is=0A=
+         * 1.0.=0A=
+         */=0A=
+        dst =3D getFmtIdx(WINED3DFMT_V8U8);=0A=
+        gl_info->gl_formats[dst].conversion_group =3D signed_2_no_ba;=0A=
+        dst =3D getFmtIdx(WINED3DFMT_V16U16);=0A=
+        gl_info->gl_formats[dst].conversion_group =3D signed_2_no_ba;=0A=
+    } else {=0A=
+        dst =3D getFmtIdx(WINED3DFMT_V8U8);=0A=
+        gl_info->gl_formats[dst].conversion_group =3D set_blue_1;=0A=
+        dst =3D getFmtIdx(WINED3DFMT_V16U16);=0A=
+        gl_info->gl_formats[dst].conversion_group =3D set_blue_1;=0A=
+    }=0A=
 =0A=
     if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {=0A=
         /* If GL_NV_texture_shader is not supported, those formats are =
converted, incompatibly=0A=
          * with each other=0A=
          */=0A=
         dst =3D getFmtIdx(WINED3DFMT_L6V5U5);=0A=
-        gl_info->gl_formats[dst].conversion_group =3D WINED3DFMT_L6V5U5;=0A=
+        gl_info->gl_formats[dst].conversion_group =3D signed_l6v5u5;=0A=
         dst =3D getFmtIdx(WINED3DFMT_X8L8V8U8);=0A=
-        gl_info->gl_formats[dst].conversion_group =3D =
WINED3DFMT_X8L8V8U8;=0A=
+        gl_info->gl_formats[dst].conversion_group =3D signed_2;=0A=
         dst =3D getFmtIdx(WINED3DFMT_Q8W8V8U8);=0A=
-        gl_info->gl_formats[dst].conversion_group =3D =
WINED3DFMT_Q8W8V8U8;=0A=
+        gl_info->gl_formats[dst].conversion_group =3D signed_4;=0A=
     } else {=0A=
         /* If GL_NV_texture_shader is supported, WINED3DFMT_L6V5U5 and =
WINED3DFMT_X8L8V8U8=0A=
          * are converted at surface loading time, but they do not need =
any modification in=0A=
@@ -396,15 +407,22 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)=0A=
     }=0A=
 =0A=
     if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {=0A=
+        /* GL_ATI_texture_compression_3dc returns the two channels as =
luminance-alpha,=0A=
+         * which means the first one is replicated across .rgb, and the =
2nd one is in=0A=
+         * .a. We need the 2nd in .g=0A=
+         */=0A=
         dst =3D getFmtIdx(WINED3DFMT_ATI2N);=0A=
         gl_info->gl_formats[dst].glInternal =3D =
GL_COMPRESSED_RED_GREEN_RGTC2_EXT;=0A=
         gl_info->gl_formats[dst].glGammaInternal =3D =
GL_COMPRESSED_RED_GREEN_RGTC2_EXT;=0A=
-        gl_info->gl_formats[dst].conversion_group=3D WINED3DFMT_ATI2N;=0A=
+        gl_info->gl_formats[dst].conversion_group=3D swap_rg_blue_1;=0A=
     } else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {=0A=
+        /* GL_EXT_texture_compression_rgtc returns the values in .rg, =
however, they=0A=
+         * are swapped compared to d3d. So swap red and green.=0A=
+         */=0A=
         dst =3D getFmtIdx(WINED3DFMT_ATI2N);=0A=
         gl_info->gl_formats[dst].glInternal =3D =
GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;=0A=
         gl_info->gl_formats[dst].glGammaInternal =3D =
GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;=0A=
-        gl_info->gl_formats[dst].conversion_group=3D WINED3DFMT_ATI2N;=0A=
+        gl_info->gl_formats[dst].conversion_group=3D a_to_g_ba_1;=0A=
     }=0A=
 =0A=
     if(!GL_SUPPORT(APPLE_YCBCR_422)) {=0A=
@@ -413,19 +431,19 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)=0A=
         gl_info->gl_formats[dst].glGammaInternal =3D =
GL_LUMINANCE_ALPHA; /* not srgb */=0A=
         gl_info->gl_formats[dst].glFormat =3D GL_LUMINANCE_ALPHA;=0A=
         gl_info->gl_formats[dst].glType =3D GL_UNSIGNED_BYTE;=0A=
-        gl_info->gl_formats[dst].conversion_group =3D WINED3DFMT_YUY2;=0A=
+        gl_info->gl_formats[dst].conversion_group =3D yuv_yuy2;=0A=
 =0A=
         dst =3D getFmtIdx(WINED3DFMT_UYVY);=0A=
         gl_info->gl_formats[dst].glInternal =3D GL_LUMINANCE_ALPHA;=0A=
         gl_info->gl_formats[dst].glGammaInternal =3D =
GL_LUMINANCE_ALPHA; /* not srgb */=0A=
         gl_info->gl_formats[dst].glFormat =3D GL_LUMINANCE_ALPHA;=0A=
         gl_info->gl_formats[dst].glType =3D GL_UNSIGNED_BYTE;=0A=
-        gl_info->gl_formats[dst].conversion_group =3D WINED3DFMT_UYVY;=0A=
+        gl_info->gl_formats[dst].conversion_group =3D yuv_uyvy;=0A=
     }=0A=
 =0A=
     dst =3D getFmtIdx(WINED3DFMT_YV12);=0A=
     gl_info->gl_formats[dst].heightscale =3D 1.5;=0A=
-    gl_info->gl_formats[dst].conversion_group =3D WINED3DFMT_YV12;=0A=
+    gl_info->gl_formats[dst].conversion_group =3D yuv_yv12;=0A=
 =0A=
     return TRUE;=0A=
 }=0A=
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h=0A=
index 0dababc..efd55e0 100644=0A=
--- a/dlls/wined3d/wined3d_gl.h=0A=
+++ b/dlls/wined3d/wined3d_gl.h=0A=
@@ -3813,9 +3813,25 @@ typedef BOOL (WINAPI * =
WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFor=0A=
  * Structures=0A=
  ****************************************************/=0A=
 =0A=
+enum shader_color_conv=0A=
+{=0A=
+    fmtconv_none        =3D 1,=0A=
+    set_blue_1          =3D 2,=0A=
+    signed_2_no_ba      =3D 3,=0A=
+    signed_2            =3D 4,=0A=
+    signed_4            =3D 5,=0A=
+    signed_l6v5u5       =3D 6,=0A=
+    swap_rg_blue_1      =3D 7,=0A=
+    a_to_g_ba_1         =3D 8,=0A=
+    yuv_yuy2            =3D 9,=0A=
+    yuv_uyvy            =3D 10,=0A=
+    yuv_yv12            =3D 11,=0A=
+    force_dword         =3D 0x7ffffff=0A=
+};=0A=
+=0A=
 typedef struct {=0A=
     GLint                   glInternal, glGammaInternal, rtInternal, =
glFormat, glType;=0A=
-    WINED3DFORMAT           conversion_group;=0A=
+    enum shader_color_conv  conversion_group;=0A=
     unsigned int            Flags;=0A=
     float                   heightscale;=0A=
 } GlPixelFormatDesc;=0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index a202884..77579a1 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -855,7 +855,7 @@ struct texture_stage_op=0A=
     unsigned                aarg1 : 6, aarg2 : 6, aarg0 : 6;=0A=
     unsigned                projected : 2;=0A=
     unsigned                padding : 12;                   /* Total of =
64 bits */=0A=
-    WINED3DFORMAT           color_correction;=0A=
+    enum shader_color_conv  color_correction;=0A=
 };=0A=
 =0A=
 struct ffp_frag_settings {=0A=
@@ -1227,7 +1227,7 @@ typedef struct IWineD3DBaseTextureClass=0A=
     DWORD                   sampler;=0A=
     BOOL                    is_srgb;=0A=
     UINT                    srgb_mode_change_count;=0A=
-    WINED3DFORMAT           shader_conversion_group;=0A=
+    enum shader_color_conv  shader_conversion_group;=0A=
     float                   pow2Matrix[16];=0A=
     minMipLookup_t          *minMipLookup;=0A=
     magLookup_t             *magLookup;=0A=
@@ -2344,7 +2344,7 @@ struct stb_const_desc {=0A=
  */=0A=
 struct ps_compile_args {=0A=
     BOOL                        srgb_correction;=0A=
-    WINED3DFORMAT               =
format_conversion[MAX_FRAGMENT_SAMPLERS];=0A=
+    enum shader_color_conv      =
format_conversion[MAX_FRAGMENT_SAMPLERS];=0A=
     enum vertexprocessing_mode  vp_mode;=0A=
     /* Projected textures(ps 1.0-1.3) */=0A=
     /* Texture types(2D, Cube, 3D) in ps 1.x */=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_0011_01C9502F.C477F290--




More information about the wine-patches mailing list