Make the previous commit slightly more performant.
This commit is contained in:
parent
69b92c6c31
commit
8dbf3d240b
|
@ -785,13 +785,12 @@ bool TextureCache::UploadTexture2D(GLuint texture,
|
||||||
auto allocation = scratch_buffer_->Acquire(unpack_length);
|
auto allocation = scratch_buffer_->Acquire(unpack_length);
|
||||||
|
|
||||||
if (!texture_info.is_tiled) {
|
if (!texture_info.is_tiled) {
|
||||||
if (texture_info.has_packed_mips) {
|
uint32_t offset_x, offset_y;
|
||||||
|
if (texture_info.has_packed_mips &&
|
||||||
|
TextureInfo::GetPackedTileOffset(texture_info, &offset_x, &offset_y)) {
|
||||||
uint32_t bytes_per_block = texture_info.format_info->block_width *
|
uint32_t bytes_per_block = texture_info.format_info->block_width *
|
||||||
texture_info.format_info->block_height *
|
texture_info.format_info->block_height *
|
||||||
texture_info.format_info->bits_per_pixel / 8;
|
texture_info.format_info->bits_per_pixel / 8;
|
||||||
uint32_t offset_x;
|
|
||||||
uint32_t offset_y;
|
|
||||||
TextureInfo::GetPackedTileOffset(texture_info, &offset_x, &offset_y);
|
|
||||||
const uint8_t* src = host_address;
|
const uint8_t* src = host_address;
|
||||||
// TODO(gibbed): this needs checking
|
// TODO(gibbed): this needs checking
|
||||||
src += offset_y * texture_info.size_2d.input_pitch;
|
src += offset_y * texture_info.size_2d.input_pitch;
|
||||||
|
|
|
@ -289,7 +289,7 @@ void TextureInfo::CalculateTextureSizesCube(
|
||||||
output_length = size_cube.output_face_length * 6;
|
output_length = size_cube.output_face_length * 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureInfo::GetPackedTileOffset(const TextureInfo& texture_info,
|
bool TextureInfo::GetPackedTileOffset(const TextureInfo& texture_info,
|
||||||
uint32_t* out_offset_x,
|
uint32_t* out_offset_x,
|
||||||
uint32_t* out_offset_y) {
|
uint32_t* out_offset_y) {
|
||||||
// Tile size is 32x32, and once textures go <=16 they are packed into a
|
// Tile size is 32x32, and once textures go <=16 they are packed into a
|
||||||
|
@ -328,7 +328,7 @@ void TextureInfo::GetPackedTileOffset(const TextureInfo& texture_info,
|
||||||
// Too big, not packed.
|
// Too big, not packed.
|
||||||
*out_offset_x = 0;
|
*out_offset_x = 0;
|
||||||
*out_offset_y = 0;
|
*out_offset_y = 0;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xe::log2_ceil(texture_info.size_2d.logical_width) >
|
if (xe::log2_ceil(texture_info.size_2d.logical_width) >
|
||||||
|
@ -343,6 +343,7 @@ void TextureInfo::GetPackedTileOffset(const TextureInfo& texture_info,
|
||||||
}
|
}
|
||||||
*out_offset_x /= texture_info.format_info->block_width;
|
*out_offset_x /= texture_info.format_info->block_width;
|
||||||
*out_offset_y /= texture_info.format_info->block_height;
|
*out_offset_y /= texture_info.format_info->block_height;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://code.google.com/p/crunch/source/browse/trunk/inc/crn_decomp.h#4104
|
// https://code.google.com/p/crunch/source/browse/trunk/inc/crn_decomp.h#4104
|
||||||
|
|
|
@ -272,7 +272,7 @@ struct TextureInfo {
|
||||||
static bool Prepare(const xenos::xe_gpu_texture_fetch_t& fetch,
|
static bool Prepare(const xenos::xe_gpu_texture_fetch_t& fetch,
|
||||||
TextureInfo* out_info);
|
TextureInfo* out_info);
|
||||||
|
|
||||||
static void GetPackedTileOffset(const TextureInfo& texture_info,
|
static bool GetPackedTileOffset(const TextureInfo& texture_info,
|
||||||
uint32_t* out_offset_x,
|
uint32_t* out_offset_x,
|
||||||
uint32_t* out_offset_y);
|
uint32_t* out_offset_y);
|
||||||
static uint32_t TiledOffset2DOuter(uint32_t y, uint32_t width,
|
static uint32_t TiledOffset2DOuter(uint32_t y, uint32_t width,
|
||||||
|
|
|
@ -986,13 +986,13 @@ void TextureCache::ConvertTexture1D(uint8_t* dest, const TextureInfo& src) {
|
||||||
void TextureCache::ConvertTexture2D(uint8_t* dest, const TextureInfo& src) {
|
void TextureCache::ConvertTexture2D(uint8_t* dest, const TextureInfo& src) {
|
||||||
void* host_address = memory_->TranslatePhysical(src.guest_address);
|
void* host_address = memory_->TranslatePhysical(src.guest_address);
|
||||||
if (!src.is_tiled) {
|
if (!src.is_tiled) {
|
||||||
if (src.has_packed_mips) {
|
uint32_t offset_x, offset_y;
|
||||||
|
if (src.has_packed_mips &&
|
||||||
|
TextureInfo::GetPackedTileOffset(src, &offset_x, &offset_y)) {
|
||||||
uint32_t bytes_per_block = src.format_info->block_width *
|
uint32_t bytes_per_block = src.format_info->block_width *
|
||||||
src.format_info->block_height *
|
src.format_info->block_height *
|
||||||
src.format_info->bits_per_pixel / 8;
|
src.format_info->bits_per_pixel / 8;
|
||||||
uint32_t offset_x;
|
|
||||||
uint32_t offset_y;
|
|
||||||
TextureInfo::GetPackedTileOffset(src, &offset_x, &offset_y);
|
|
||||||
const uint8_t* src_mem = reinterpret_cast<const uint8_t*>(host_address);
|
const uint8_t* src_mem = reinterpret_cast<const uint8_t*>(host_address);
|
||||||
src_mem += offset_y * src.size_2d.input_pitch;
|
src_mem += offset_y * src.size_2d.input_pitch;
|
||||||
src_mem += offset_x * bytes_per_block;
|
src_mem += offset_x * bytes_per_block;
|
||||||
|
|
Loading…
Reference in New Issue