diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 6d567708ae..d2df038dac 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -1399,9 +1399,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt CachedTextureVulkan *tex = entry.vkTex; int w = gstate.getTextureWidth(level); int h = gstate.getTextureHeight(level); - u32 *pixelData; - int decPitch; - int rowBytes; + { PROFILE_THIS_SCOPE("decodetex"); @@ -1411,8 +1409,8 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt int bufw = GetTextureBufw(level, texaddr, tfmt); int bpp = dstFmt == VULKAN_8888_FORMAT ? 4 : 2; - pixelData = (u32 *)writePtr; - decPitch = rowPitch; + u32 *pixelData = (u32 *)writePtr; + int decPitch = rowPitch; if (scaleFactor > 1) { tmpTexBufRearrange.resize(std::max(bufw, w) * h); pixelData = tmpTexBufRearrange.data(); @@ -1425,7 +1423,6 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt memset(writePtr, 0, rowPitch * h); return; } - rowBytes = w * bpp; gpuStats.numTexturesDecoded++; if (scaleFactor > 1) { @@ -1438,14 +1435,14 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt assert(dstFmt == VULKAN_8888_FORMAT); bpp = sizeof(u32); decPitch = w * bpp; - rowBytes = w * bpp; if (decPitch != rowPitch) { // Rearrange in place to match the requested pitch. // (it can only be larger than w * bpp, and a match is likely.) for (int y = h - 1; y >= 0; --y) { - memcpy(writePtr + rowPitch * y, writePtr + decPitch * y, rowBytes); + memcpy(writePtr + rowPitch * y, writePtr + decPitch * y, w * bpp); } + decPitch = rowPitch; } }