Commit 726d9d47 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: ATI2N support using GL_EXT_texture_compression_rgtc.

parent dc25a86c
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment