Scale directly into the buffer if possible.

This will be possible in the majority of cases, and avoid an extra copy.
A small cost compared to scaling, but even so.
This commit is contained in:
Unknown W. Brackets committed 2016-06-25 08:40:45 -07:00
1 parent 3db69b87d7
commit 4c94cd764d
3 files changed
+39 -31

No files matched your search

+10 -9
View File
@@ -1430,7 +1430,8 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt
if (scaleFactor > 1) {
u32 fmt = dstFmt;
scaler.ScaleAlways(pixelData, fmt, w, h, scaleFactor);
scaler.ScaleAlways((u32 *)writePtr, pixelData, fmt, w, h, scaleFactor);
pixelData = (u32 *)writePtr;
dstFmt = (VkFormat)fmt;
// We always end up at 8888. Other parts assume this.
@@ -1438,6 +1439,14 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt
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);
}
}
}
if ((entry.status & TexCacheEntry::STATUS_CHANGE_FREQUENT) == 0) {
@@ -1447,12 +1456,4 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt
entry.SetAlphaStatus(TexCacheEntry::STATUS_ALPHA_UNKNOWN);
}
}
PROFILE_THIS_SCOPE("loadtex");
if (pixelData != (u32 *)writePtr) {
// This is used when texture scaling was enabled.
for (int y = 0; y < h; y++) {
memcpy(writePtr + rowPitch * y, (const uint8_t *)pixelData + decPitch * y, rowBytes);
}
}
}