dxgsg9: Fix issues with luminance textures and ATI1 compression

Fixes #1198
This commit is contained in:
rdb 2021-12-31 22:59:01 +01:00
parent ecc6fb6b0c
commit 1e6569e678

View File

@ -427,10 +427,26 @@ create_texture(DXScreenData &scrn) {
}
if (compress_texture) {
if (num_color_channels == 1) {
CHECK_FOR_FMT(ATI1);
} else if (num_alpha_bits == 0 && num_color_channels == 2) {
CHECK_FOR_FMT(ATI2);
// The ATI1 and ATI2 formats can't be compressed by the driver.
// Only choose them if we can compress them on the CPU.
// Also, don't choose ATI for a luminance texture, since it gets read as
// a texture with just a red channel.
if (num_alpha_bits == 0 && !needs_luminance) {
if (num_color_channels == 1) {
if (scrn._supported_tex_formats_mask & ATI1_FLAG) {
if (tex->compress_ram_image(Texture::CM_rgtc)) {
target_pixel_format = D3DFMT_ATI1;
goto found_matching_format;
}
}
} else if (num_color_channels == 2) {
if (scrn._supported_tex_formats_mask & ATI2_FLAG) {
if (tex->compress_ram_image(Texture::CM_rgtc)) {
target_pixel_format = D3DFMT_ATI2;
goto found_matching_format;
}
}
}
}
if (num_alpha_bits <= 1) {
CHECK_FOR_FMT(DXT1);