diff options
| author | Stenzek <stenzek@gmail.com> | 2017-04-16 19:45:22 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2017-04-29 00:14:23 +1000 |
| commit | f4b848949c67ffe99db61e5f4d0b968154e6c5ba (patch) | |
| tree | 8a0a4709aa615f3f46117ff13712d21d3eda6103 /Source/Core/VideoCommon/TextureCacheBase.cpp | |
| parent | bc8a96d713eb0a1fb565f121a5d939b99c2295fa (diff) | |
TextureCache: Support compressed textures and pass pitch/size to upload
This also removes an extra copy of the image for custom textures.
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 89d473cfec..e3a9daa69d 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -750,8 +750,6 @@ TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) } expandedWidth = level.width; expandedHeight = level.height; - CheckTempSize(level.data_size); - memcpy(temp, level.data.get(), level.data_size); } } @@ -774,6 +772,7 @@ TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) config.width = width; config.height = height; config.levels = texLevels; + config.format = hires_tex ? hires_tex->GetFormat() : HostTextureFormat::RGBA8; TCacheEntryBase* entry = AllocateTexture(config); GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true); @@ -784,17 +783,20 @@ TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) const u8* tlut = &texMem[tlutaddr]; if (hires_tex) { - entry->Load(temp, width, height, expandedWidth, 0); + const auto& level = hires_tex->m_levels[0]; + entry->Load(0, level.width, level.height, level.row_length, level.data.get(), level.data_size); } - else if (decode_on_gpu) + if (!hires_tex && decode_on_gpu) { u32 row_stride = bytes_per_block * (expandedWidth / bsw); g_texture_cache->DecodeTextureOnGPU( entry, 0, src_data, texture_size, static_cast<TextureFormat>(texformat), width, height, expandedWidth, expandedHeight, row_stride, tlut, static_cast<TlutFormat>(tlutfmt)); } - else + else if (!hires_tex) { + size_t decoded_texture_size = expandedWidth * sizeof(u32) * expandedHeight; + CheckTempSize(decoded_texture_size); if (!(texformat == GX_TF_RGBA8 && from_tmem)) { TexDecoder_Decode(temp, src_data, expandedWidth, expandedHeight, texformat, tlut, @@ -807,7 +809,7 @@ TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) TexDecoder_DecodeRGBA8FromTmem(temp, src_data, src_data_gb, expandedWidth, expandedHeight); } - entry->Load(temp, width, height, expandedWidth, 0); + entry->Load(0, width, height, expandedWidth, temp, decoded_texture_size); } iter = textures_by_address.emplace(address, entry); @@ -837,9 +839,8 @@ TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) for (u32 level_index = 1; level_index != texLevels; ++level_index) { const auto& level = hires_tex->m_levels[level_index]; - CheckTempSize(level.data_size); - memcpy(temp, level.data.get(), level.data_size); - entry->Load(temp, level.width, level.height, level.width, level_index); + entry->Load(level_index, level.width, level.height, level.row_length, level.data.get(), + level.data_size); } } else @@ -877,9 +878,11 @@ TextureCacheBase::TCacheEntryBase* TextureCacheBase::Load(const u32 stage) } else { + // No need to call CheckTempSize here, as mips will always be smaller than the base level. + size_t decoded_mip_size = expanded_mip_width * sizeof(u32) * expanded_mip_height; TexDecoder_Decode(temp, mip_src_data, expanded_mip_width, expanded_mip_height, texformat, tlut, (TlutFormat)tlutfmt); - entry->Load(temp, mip_width, mip_height, expanded_mip_width, level); + entry->Load(level, mip_width, mip_height, expanded_mip_width, temp, decoded_mip_size); } mip_src_data += mip_size; |
