mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-03 03:03:50 +01:00
Merge pull request #16756 from unknownbrackets/replace-stride
Replacement: Always return w/h from GetMipSize()
This commit is contained in:
5 files changed
+18
-17
No files matched your search
@@ -2816,15 +2816,15 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, int stride, ReplacedTexture &replaced, int srcLevel, int scaleFactor, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags) {
|
||||
void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, int stride, BuildTexturePlan &plan, int srcLevel, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags) {
|
||||
int w = gstate.getTextureWidth(srcLevel);
|
||||
int h = gstate.getTextureHeight(srcLevel);
|
||||
|
||||
PROFILE_THIS_SCOPE("decodetex");
|
||||
|
||||
if (replaced.GetSize(srcLevel, w, h)) {
|
||||
if (plan.replaceValid && plan.replaced->GetSize(srcLevel, w, h)) {
|
||||
double replaceStart = time_now_d();
|
||||
replaced.Load(srcLevel, data, stride);
|
||||
plan.replaced->Load(srcLevel, data, stride);
|
||||
replacementTimeThisFrame_ += time_now_d() - replaceStart;
|
||||
} else {
|
||||
GETextureFormat tfmt = (GETextureFormat)entry.format;
|
||||
@@ -2833,7 +2833,7 @@ void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, i
|
||||
int bufw = GetTextureBufw(srcLevel, texaddr, tfmt);
|
||||
u32 *pixelData;
|
||||
int decPitch;
|
||||
if (scaleFactor > 1) {
|
||||
if (plan.scaleFactor > 1) {
|
||||
tmpTexBufRearrange_.resize(std::max(bufw, w) * h);
|
||||
pixelData = tmpTexBufRearrange_.data();
|
||||
// We want to end up with a neatly packed texture for scaling.
|
||||
@@ -2853,9 +2853,9 @@ void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, i
|
||||
CheckAlphaResult alphaResult = DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, srcLevel, bufw, texDecFlags);
|
||||
entry.SetAlphaStatus(alphaResult, srcLevel);
|
||||
|
||||
if (scaleFactor > 1) {
|
||||
if (plan.scaleFactor > 1) {
|
||||
// Note that this updates w and h!
|
||||
scaler_.ScaleAlways((u32 *)data, pixelData, w, h, scaleFactor);
|
||||
scaler_.ScaleAlways((u32 *)data, pixelData, w, h, plan.scaleFactor);
|
||||
pixelData = (u32 *)data;
|
||||
|
||||
decPitch = w * 4;
|
||||
@@ -2871,14 +2871,14 @@ void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, i
|
||||
}
|
||||
}
|
||||
|
||||
if (replacer_.Enabled() && replaced.IsInvalid()) {
|
||||
if (replacer_.Enabled() && plan.replaced->IsInvalid()) {
|
||||
ReplacedTextureDecodeInfo replacedInfo;
|
||||
replacedInfo.cachekey = entry.CacheKey();
|
||||
replacedInfo.hash = entry.fullhash;
|
||||
replacedInfo.addr = entry.addr;
|
||||
replacedInfo.isVideo = IsVideo(entry.addr);
|
||||
replacedInfo.isFinal = (entry.status & TexCacheEntry::STATUS_TO_SCALE) == 0;
|
||||
replacedInfo.scaleFactor = scaleFactor;
|
||||
replacedInfo.scaleFactor = plan.scaleFactor;
|
||||
replacedInfo.fmt = dstFmt;
|
||||
|
||||
// NOTE: Reading the decoded texture here may be very slow, if we just wrote it to write-combined memory.
|
||||
|
||||
@@ -290,9 +290,10 @@ struct BuildTexturePlan {
|
||||
bool decodeToClut8;
|
||||
|
||||
void GetMipSize(int level, int *w, int *h) const {
|
||||
if (replaceValid) {
|
||||
replaced->GetSize(level, *w, *h);
|
||||
} else if (depth == 1) {
|
||||
if (replaceValid && replaced->GetSize(level, *w, *h)) {
|
||||
return;
|
||||
}
|
||||
if (depth == 1) {
|
||||
*w = createW >> level;
|
||||
*h = createH >> level;
|
||||
} else {
|
||||
@@ -376,7 +377,7 @@ protected:
|
||||
ReplacedTexture &FindReplacement(TexCacheEntry *entry, int &w, int &h, int &d);
|
||||
|
||||
// Return value is mapData normally, but could be another buffer allocated with AllocateAlignedMemory.
|
||||
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, int mapRowPitch, ReplacedTexture &replaced, int srcLevel, int scaleFactor, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags);
|
||||
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, int mapRowPitch, BuildTexturePlan &plan, int srcLevel, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags);
|
||||
|
||||
template <typename T>
|
||||
inline const T *GetCurrentClut() {
|
||||
|
||||
@@ -381,7 +381,7 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
LoadTextureLevel(*entry, data, stride, *plan.replaced, srcLevel, plan.scaleFactor, texFmt, TexDecodeFlags{});
|
||||
LoadTextureLevel(*entry, data, stride, plan, srcLevel, texFmt, TexDecodeFlags{});
|
||||
if (plan.depth == 1) {
|
||||
context_->UpdateSubresource(texture, i, nullptr, data, stride, 0);
|
||||
} else {
|
||||
|
||||
@@ -308,7 +308,7 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry) {
|
||||
}
|
||||
uint8_t *data = (uint8_t *)rect.pBits;
|
||||
int stride = rect.Pitch;
|
||||
LoadTextureLevel(*entry, data, stride, *plan.replaced, (i == 0) ? plan.baseLevelSrc : i, plan.scaleFactor, FromD3D9Format(dstFmt), TexDecodeFlags{});
|
||||
LoadTextureLevel(*entry, data, stride, plan, (i == 0) ? plan.baseLevelSrc : i, FromD3D9Format(dstFmt), TexDecodeFlags{});
|
||||
((LPDIRECT3DTEXTURE9)texture)->UnlockRect(dstLevel);
|
||||
}
|
||||
} else {
|
||||
@@ -323,7 +323,7 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry) {
|
||||
uint8_t *data = (uint8_t *)box.pBits;
|
||||
int stride = box.RowPitch;
|
||||
for (int i = 0; i < plan.depth; i++) {
|
||||
LoadTextureLevel(*entry, data, stride, *plan.replaced, (i == 0) ? plan.baseLevelSrc : i, plan.scaleFactor, FromD3D9Format(dstFmt), TexDecodeFlags{});
|
||||
LoadTextureLevel(*entry, data, stride, plan, (i == 0) ? plan.baseLevelSrc : i, FromD3D9Format(dstFmt), TexDecodeFlags{});
|
||||
data += box.SlicePitch;
|
||||
}
|
||||
((LPDIRECT3DVOLUMETEXTURE9)texture)->UnlockBox(0);
|
||||
|
||||
@@ -326,7 +326,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
LoadTextureLevel(*entry, data, stride, *plan.replaced, srcLevel, plan.scaleFactor, dstFmt, TexDecodeFlags::REVERSE_COLORS);
|
||||
LoadTextureLevel(*entry, data, stride, plan, srcLevel, dstFmt, TexDecodeFlags::REVERSE_COLORS);
|
||||
|
||||
// NOTE: TextureImage takes ownership of data, so we don't free it afterwards.
|
||||
render_->TextureImage(entry->textureName, i, mipWidth, mipHeight, 1, dstFmt, data, GLRAllocType::ALIGNED);
|
||||
@@ -345,7 +345,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
|
||||
u8 *p = data;
|
||||
|
||||
for (int i = 0; i < plan.depth; i++) {
|
||||
LoadTextureLevel(*entry, p, stride, *plan.replaced, i, plan.scaleFactor, dstFmt, TexDecodeFlags::REVERSE_COLORS);
|
||||
LoadTextureLevel(*entry, p, stride, plan, i, dstFmt, TexDecodeFlags::REVERSE_COLORS);
|
||||
p += levelStride;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user