[PATCH] WineD3D: ATI2N support using =

Stefan Doesinger stefan at codeweavers.com
Wed Jul 23 10:39:04 CDT 2008


GL_EXT_texture_compression_rgtc=0A=
=0A=
This is for Nvidia GeForce 8+ cards=0A=
---=0A=
 dlls/wined3d/arb_program_shader.c |   23 +++++++++++++++--------=0A=
 dlls/wined3d/directx.c            |    3 ++-=0A=
 dlls/wined3d/glsl_shader.c        |   33 =
++++++++++++++++++++++++---------=0A=
 dlls/wined3d/utils.c              |    7 ++++++-=0A=
 include/wine/wined3d_gl.h         |    9 +++++++++=0A=
 5 files changed, 56 insertions(+), 19 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/arb_program_shader.c =
b/dlls/wined3d/arb_program_shader.c=0A=
index 9f074ad..22a8b55 100644=0A=
--- a/dlls/wined3d/arb_program_shader.c=0A=
+++ b/dlls/wined3d/arb_program_shader.c=0A=
@@ -820,16 +820,23 @@ static void =
shader_arb_color_correction(SHADER_OPCODE_ARG* arg) {=0A=
             /* GL_ATI_texture_compression_3dc returns the two channels =
as luminance-alpha,=0A=
              * which means the first one is replicated accross .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(strlen(writemask) =3D=3D 5) {=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, "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=
+            if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {=0A=
+                shader_addline(arg->buffer, "SWZ %s, %s, %c, %c, 1, =
0;\n",=0A=
+                               reg, reg, writemask[2], writemask[1]);=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=
+                if(strlen(writemask) =3D=3D 5) {=0A=
+                    shader_addline(arg->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=
             }=0A=
             break;=0A=
 =0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index f4bc0ee..a95c778 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -105,6 +105,7 @@ static const struct {=0A=
     {"GL_EXT_stencil_wrap",                 EXT_STENCIL_WRAP,           =
    0                           },=0A=
     {"GL_EXT_texture3D",                    EXT_TEXTURE3D,              =
    MAKEDWORD_VERSION(1, 2)     },=0A=
     {"GL_EXT_texture_compression_s3tc",     =
EXT_TEXTURE_COMPRESSION_S3TC,   0                           },=0A=
+    {"GL_EXT_texture_compression_rgtc",     =
EXT_TEXTURE_COMPRESSION_RGTC,   0                           },=0A=
     {"GL_EXT_texture_env_add",              EXT_TEXTURE_ENV_ADD,        =
    0                           },=0A=
     {"GL_EXT_texture_env_combine",          EXT_TEXTURE_ENV_COMBINE,    =
    0                           },=0A=
     {"GL_EXT_texture_env_dot3",             EXT_TEXTURE_ENV_DOT3,       =
    0                           },=0A=
@@ -2374,7 +2375,7 @@ static BOOL CheckTextureCapability(UINT Adapter, =
WINED3DFORMAT CheckFormat)=0A=
 =0A=
         /* Vendor specific formats */=0A=
         case WINED3DFMT_ATI2N:=0A=
-            if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {=0A=
+            if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || =
GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {=0A=
                 TRACE_(d3d_caps)("[OK]\n");=0A=
                 return TRUE;=0A=
             }=0A=
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c=0A=
index 7a20ae1..ce84ea7 100644=0A=
--- a/dlls/wined3d/glsl_shader.c=0A=
+++ b/dlls/wined3d/glsl_shader.c=0A=
@@ -1348,19 +1348,34 @@ static void =
shader_glsl_color_correction(SHADER_OPCODE_ARG* arg) {=0A=
             /* GL_ATI_texture_compression_3dc returns the two channels =
as luminance-alpha,=0A=
              * which means the first one is replicated accross .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=
             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=
-            } else if(mask_size =3D=3D 1) {=0A=
-                /* Nothing to do */=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=
+                }=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=
+                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=
             }=0A=
             break;=0A=
 =0A=
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c=0A=
index 370f50b..da08d4f 100644=0A=
--- a/dlls/wined3d/utils.c=0A=
+++ b/dlls/wined3d/utils.c=0A=
@@ -395,7 +395,12 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)=0A=
          */=0A=
     }=0A=
 =0A=
-    if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {=0A=
+    if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {=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=
+    } else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {=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=
diff --git a/include/wine/wined3d_gl.h b/include/wine/wined3d_gl.h=0A=
index 533c991..ac4967d 100644=0A=
--- a/include/wine/wined3d_gl.h=0A=
+++ b/include/wine/wined3d_gl.h=0A=
@@ -2996,6 +2996,14 @@ typedef void (WINE_GLAPI =
*PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const=0A=
 #define GL_ATI_texture_compression_3dc=0A=
 #define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837=0A=
 #endif=0A=
+/* GL_EXT_texture_compression_rgtc */=0A=
+#ifndef GL_EXT_texture_compression_rgtc=0A=
+#define GL_EXT_texture_compression_rgtc=0A=
+#define GL_COMPRESSED_RED_RGTC1_EXT                       0x8DBB=0A=
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT                0x8DBC=0A=
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT                 0x8DBD=0A=
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT          0x8DBE=0A=
+#endif=0A=
 =0A=
 /* GL_VERSION_2_0 */=0A=
 #ifndef GL_VERSION_2_0=0A=
@@ -3327,6 +3335,7 @@ typedef enum _GL_SupportedExt {=0A=
   EXT_STENCIL_WRAP,=0A=
   EXT_TEXTURE3D,=0A=
   EXT_TEXTURE_COMPRESSION_S3TC,=0A=
+  EXT_TEXTURE_COMPRESSION_RGTC,=0A=
   EXT_TEXTURE_FILTER_ANISOTROPIC,=0A=
   EXT_TEXTURE_LOD,=0A=
   EXT_TEXTURE_LOD_BIAS,=0A=
-- =0A=
1.5.4.5=0A=
=0A=

------=_NextPart_000_000B_01C8ECB5.FDE66670--




More information about the wine-patches mailing list