mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 07:20:49 +00:00
Prepare to convert the GLES functions too
This commit is contained in:
parent
dea979433c
commit
c6d7423368
@ -2143,7 +2143,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t *TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, int stride, ReplacedTexture &replaced, int srcLevel, int scaleFactor, Draw::DataFormat dstFmt) {
|
||||
void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, int stride, ReplacedTexture &replaced, int srcLevel, int scaleFactor, Draw::DataFormat dstFmt) {
|
||||
int w = gstate.getTextureWidth(srcLevel);
|
||||
int h = gstate.getTextureHeight(srcLevel);
|
||||
|
||||
@ -2205,6 +2205,4 @@ uint8_t *TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *dat
|
||||
replacer_.NotifyTextureDecoded(replacedInfo, pixelData, decPitch, srcLevel, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ protected:
|
||||
ReplacedTexture &FindReplacement(TexCacheEntry *entry, int &w, int &h);
|
||||
|
||||
// Return value is mapData normally, but could be another buffer allocated with AllocateAlignedMemory.
|
||||
uint8_t *LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, int mapRowPitch, ReplacedTexture &replaced, int srcLevel, int scaleFactor, Draw::DataFormat dstFmt);
|
||||
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, int mapRowPitch, ReplacedTexture &replaced, int srcLevel, int scaleFactor, Draw::DataFormat dstFmt);
|
||||
|
||||
template <typename T>
|
||||
inline const T *GetCurrentClut() {
|
||||
|
@ -493,28 +493,29 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) {
|
||||
Draw::DataFormat texFmt = FromD3D11Format(dstFmt);
|
||||
|
||||
for (int i = 0; i < levels; i++) {
|
||||
u8 *data = nullptr;
|
||||
int stride = 0;
|
||||
int bpp = dstFmt == DXGI_FORMAT_B8G8R8A8_UNORM ? 4 : 2;
|
||||
|
||||
int srcLevel = (i == 0) ? plan.baseLevelSrc : i;
|
||||
|
||||
int w = gstate.getTextureWidth(srcLevel);
|
||||
int h = gstate.getTextureHeight(srcLevel);
|
||||
|
||||
u8 *data = nullptr;
|
||||
int stride = 0;
|
||||
|
||||
// For UpdateSubresource, we can't decode directly into the texture so we allocate a buffer :(
|
||||
// NOTE: Could reuse it between levels or textures!
|
||||
if (plan.replaced->GetSize(srcLevel, w, h)) {
|
||||
data = (u8 *)AllocateAlignedMemory(w * h * 4, 16);
|
||||
stride = w * 4;
|
||||
int bpp = (int)Draw::DataFormatSizeInBytes(plan.replaced->Format(srcLevel));
|
||||
stride = w * bpp;
|
||||
data = (u8 *)AllocateAlignedMemory(stride * h, 16);
|
||||
} else {
|
||||
if (plan.scaleFactor > 1) {
|
||||
data = (u8 *)AllocateAlignedMemory(4 * (w * plan.scaleFactor) * (h * plan.scaleFactor), 16);
|
||||
stride = w * plan.scaleFactor * 4;
|
||||
} else {
|
||||
int bpp = dstFmt == DXGI_FORMAT_B8G8R8A8_UNORM ? 4 : 2;
|
||||
|
||||
stride = std::max(w * bpp, 16);
|
||||
size_t bufSize = sizeof(u32) * (stride / bpp) * h;
|
||||
data = (u8 *)AllocateAlignedMemory(bufSize, 16);
|
||||
data = (u8 *)AllocateAlignedMemory(stride * h, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,7 +524,7 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
data = LoadTextureLevel(*entry, data, stride, *plan.replaced, srcLevel, plan.scaleFactor, texFmt);
|
||||
LoadTextureLevel(*entry, data, stride, *plan.replaced, srcLevel, plan.scaleFactor, texFmt);
|
||||
|
||||
ID3D11Texture2D *texture = DxTex(entry);
|
||||
context_->UpdateSubresource(texture, i, nullptr, data, stride, 0);
|
||||
|
@ -460,7 +460,7 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry) {
|
||||
uint8_t *data = (uint8_t *)rect.pBits;
|
||||
int stride = rect.Pitch;
|
||||
|
||||
data = LoadTextureLevel(*entry, data, stride, *plan.replaced, (i == 0) ? plan.baseLevelSrc : i, plan.scaleFactor, texFmt);
|
||||
LoadTextureLevel(*entry, data, stride, *plan.replaced, (i == 0) ? plan.baseLevelSrc : i, plan.scaleFactor, texFmt);
|
||||
|
||||
texture->UnlockRect(dstLevel);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user