From fe3475b88cab75b3debd5e9d4b1c060dc51a839d Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Tue, 3 Feb 2015 23:46:12 -0800 Subject: [PATCH] Fixing texture sizing. Probably. Fixes some DXT issues. --- src/xenia/gpu/gl4/texture_cache.cc | 2 +- src/xenia/gpu/texture_info.cc | 40 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/xenia/gpu/gl4/texture_cache.cc b/src/xenia/gpu/gl4/texture_cache.cc index c7418614b..152c83c85 100644 --- a/src/xenia/gpu/gl4/texture_cache.cc +++ b/src/xenia/gpu/gl4/texture_cache.cc @@ -506,7 +506,7 @@ bool TextureCache::UploadTexture2D(GLuint texture, case TextureFormat::k_DXT1: case TextureFormat::k_DXT1_AS_16_16_16_16: // or GL_COMPRESSED_RGB_S3TC_DXT1_EXT? - internal_format = format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + internal_format = format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break; case TextureFormat::k_DXT2_3: case TextureFormat::k_DXT2_3_AS_16_16_16_16: diff --git a/src/xenia/gpu/texture_info.cc b/src/xenia/gpu/texture_info.cc index 04e808c13..9fd7aa744 100644 --- a/src/xenia/gpu/texture_info.cc +++ b/src/xenia/gpu/texture_info.cc @@ -194,36 +194,36 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) { size_2d.block_width = size_2d.logical_width / block_size; size_2d.block_height = size_2d.logical_height / block_size; - if (!is_compressed) { - // must be 32x32 but also must have a pitch that is a multiple of 256 bytes + // Must be 32x32 but also must have a pitch that is a multiple of 256 bytes. uint32_t bytes_per_block = block_size * block_size * texel_pitch; uint32_t width_multiple = 32; - if (bytes_per_block) { - uint32_t minimum_multiple = 256 / bytes_per_block; - if (width_multiple < minimum_multiple) { - width_multiple = minimum_multiple; - } + if (!is_tiled) { + // 256 stride requirement for untiled textures. + width_multiple = poly::round_up(width_multiple, 256 / bytes_per_block); } size_2d.input_width = poly::round_up(size_2d.logical_width, width_multiple); size_2d.input_height = poly::round_up(size_2d.logical_height, 32); size_2d.output_width = size_2d.logical_width; size_2d.output_height = size_2d.logical_height; - } else { - // must be 128x128 - size_2d.input_width = poly::round_up(size_2d.logical_width, 128); - size_2d.input_height = poly::round_up(size_2d.logical_height, 128); - size_2d.output_width = poly::next_pow2(size_2d.logical_width); - size_2d.output_height = poly::next_pow2(size_2d.logical_height); - } - size_2d.logical_pitch = (size_2d.logical_width / block_size) * texel_pitch; - size_2d.input_pitch = (size_2d.input_width / block_size) * texel_pitch; - - if (!is_tiled) { - input_length = size_2d.block_height * size_2d.logical_pitch; - } else { + size_2d.logical_pitch = (size_2d.logical_width / block_size) * texel_pitch; + size_2d.input_pitch = (size_2d.input_width / block_size) * texel_pitch; input_length = size_2d.block_height * size_2d.logical_pitch; // ? + } else { + // Must be 128x128 minimum (block_size * 32). + size_2d.input_width = + poly::round_up(size_2d.logical_width, block_size * 32); + size_2d.input_height = + poly::round_up(size_2d.logical_height, block_size * 32); + size_2d.output_width = size_2d.input_width; + size_2d.output_height = size_2d.input_height; + + uint32_t block_count = (size_2d.input_width / block_size) * + (size_2d.input_height / block_size); + size_2d.logical_pitch = (size_2d.input_width / block_size) * texel_pitch; + size_2d.input_pitch = (size_2d.input_width / block_size) * texel_pitch; + input_length = block_count * texel_pitch; } }