Module: wine Branch: master Commit: 726d9d47afb278e61cd86c4f05a5c4fbf671b3b6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=726d9d47afb278e61cd86c4f05...
Author: Stefan Dösinger stefan@codeweavers.com Date: Wed Jul 23 10:39:04 2008 -0500
wined3d: ATI2N support using GL_EXT_texture_compression_rgtc.
---
dlls/wined3d/arb_program_shader.c | 23 +++++++++++++++-------- dlls/wined3d/directx.c | 3 ++- dlls/wined3d/glsl_shader.c | 33 ++++++++++++++++++++++++--------- dlls/wined3d/utils.c | 7 ++++++- include/wine/wined3d_gl.h | 9 +++++++++ 5 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 9f074ad..22a8b55 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -820,16 +820,23 @@ static void shader_arb_color_correction(SHADER_OPCODE_ARG* arg) { /* GL_ATI_texture_compression_3dc returns the two channels as luminance-alpha, * which means the first one is replicated accross .rgb, and the 2nd one is in * .a. We need the 2nd in .g + * + * GL_EXT_texture_compression_rgtc returns the values in .rg, however, they + * are swapped compared to d3d. So swap red and green. */ - if(strlen(writemask) == 5) { - /* Swap y and z (U and L), and do a sign conversion on x and the new y(V and U) */ - shader_addline(arg->buffer, "MOV %s.%c, %s.%c;\n", - reg, writemask[2], reg, writemask[4]); - } else if(strlen(writemask) == 2) { - /* Nothing to do */ + if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) { + shader_addline(arg->buffer, "SWZ %s, %s, %c, %c, 1, 0;\n", + reg, reg, writemask[2], writemask[1]); } else { - /* This is bad: We have VL, but we need VU */ - FIXME("2 or 3 components sampled from a converted ATI2N texture\n"); + if(strlen(writemask) == 5) { + shader_addline(arg->buffer, "MOV %s.%c, %s.%c;\n", + reg, writemask[2], reg, writemask[4]); + } else if(strlen(writemask) == 2) { + /* Nothing to do */ + } else { + /* This is bad: We have VL, but we need VU */ + FIXME("2 or 3 components sampled from a converted ATI2N texture\n"); + } } break;
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index f4bc0ee..a95c778 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -105,6 +105,7 @@ static const struct { {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 }, {"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) }, {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 }, + {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 }, {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 }, {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 }, {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 }, @@ -2374,7 +2375,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
/* Vendor specific formats */ case WINED3DFMT_ATI2N: - if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) { + if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) { TRACE_(d3d_caps)("[OK]\n"); return TRUE; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 7a20ae1..ce84ea7 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1348,19 +1348,34 @@ static void shader_glsl_color_correction(SHADER_OPCODE_ARG* arg) { /* GL_ATI_texture_compression_3dc returns the two channels as luminance-alpha, * which means the first one is replicated accross .rgb, and the 2nd one is in * .a. We need the 2nd in .g + * + * GL_EXT_texture_compression_rgtc returns the values in .rg, however, they + * are swapped compared to d3d. So swap red and green. */ mask = shader_glsl_add_dst_param(arg, arg->dst, WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param); mask_size = shader_glsl_get_write_mask_size(mask); - if(mask_size == 4) { - /* Swap y and z (U and L), and do a sign conversion on x and the new y(V and U) */ - shader_addline(arg->buffer, "%s.%c = %s.%c;\n", - dst_param.reg_name, dst_param.mask_str[2], - dst_param.reg_name, dst_param.mask_str[4]); - } else if(mask_size == 1) { - /* Nothing to do */ + if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) { + if(mask_size >= 2) { + shader_addline(arg->buffer, "%s.%c%c = %s.%c%c;\n", + dst_param.reg_name, dst_param.mask_str[1], + dst_param.mask_str[2], + dst_param.reg_name, dst_param.mask_str[2], + dst_param.mask_str[1]); + } else { + FIXME("%u components sampled from a converted ATI2N texture\n", mask_size); + } } else { - FIXME("%u components sampled from a converted ATI2N texture\n", mask_size); - /* This is bad: We have .r[gb], but we need .ra */ + if(mask_size == 4) { + /* Swap y and z (U and L), and do a sign conversion on x and the new y(V and U) */ + shader_addline(arg->buffer, "%s.%c = %s.%c;\n", + dst_param.reg_name, dst_param.mask_str[2], + dst_param.reg_name, dst_param.mask_str[4]); + } else if(mask_size == 1) { + /* Nothing to do */ + } else { + FIXME("%u components sampled from a converted ATI2N texture\n", mask_size); + /* This is bad: We have .r[gb], but we need .ra */ + } } break;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 370f50b..da08d4f 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -395,7 +395,12 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info) */ }
- if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) { + if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) { + dst = getFmtIdx(WINED3DFMT_ATI2N); + gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT; + gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT; + gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N; + } else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) { dst = getFmtIdx(WINED3DFMT_ATI2N); gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; diff --git a/include/wine/wined3d_gl.h b/include/wine/wined3d_gl.h index 533c991..ac4967d 100644 --- a/include/wine/wined3d_gl.h +++ b/include/wine/wined3d_gl.h @@ -2996,6 +2996,14 @@ typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const #define GL_ATI_texture_compression_3dc #define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 #endif +/* GL_EXT_texture_compression_rgtc */ +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif
/* GL_VERSION_2_0 */ #ifndef GL_VERSION_2_0 @@ -3327,6 +3335,7 @@ typedef enum _GL_SupportedExt { EXT_STENCIL_WRAP, EXT_TEXTURE3D, EXT_TEXTURE_COMPRESSION_S3TC, + EXT_TEXTURE_COMPRESSION_RGTC, EXT_TEXTURE_FILTER_ANISOTROPIC, EXT_TEXTURE_LOD, EXT_TEXTURE_LOD_BIAS,