Clarify some logic, improve framebuffer names

This commit is contained in:
Henrik Rydgård 2020-11-01 23:19:25 +01:00
parent 085900adb5
commit 32eb882bc6
7 changed files with 28 additions and 14 deletions

View file

@ -265,10 +265,13 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame
if (v->fb_address == params.fb_address) {
vfb = v;
// Update fb stride in case it changed
if (vfb->fb_stride != params.fb_stride || vfb->format != params.fmt) {
vfbFormatChanged = true;
if (vfb->fb_stride != params.fb_stride) {
vfb->fb_stride = params.fb_stride;
vfbFormatChanged = true;
}
if (vfb->format != params.fmt) {
vfb->format = params.fmt;
vfbFormatChanged = true;
}
if (vfb->z_address == 0 && vfb->z_stride == 0 && params.z_stride != 0) {
@ -1087,7 +1090,7 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w,
shaderManager_->DirtyLastShader();
char tag[256];
snprintf(tag, sizeof(tag), "%08x_%08x_%dx%d", vfb->fb_address, vfb->z_address, w, h);
snprintf(tag, sizeof(tag), "%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString((GEBufferFormat)vfb->colorDepth));
vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, (Draw::FBColorDepth)vfb->colorDepth, tag });
if (old.fbo) {
INFO_LOG(FRAMEBUF, "Resizing FBO for %08x : %dx%dx%s", vfb->fb_address, w, h, GeBufferFormatToString(vfb->format));

View file

@ -55,7 +55,7 @@ struct VirtualFramebuffer {
int fb_stride;
int z_stride;
GEBufferFormat format; // virtual, right now they are all RGBA8888
GEBufferFormat format; // virtual, in reality they are all RGBA8888 for better quality but we can reinterpret that as necessary
// width/height: The detected size of the current framebuffer, in original PSP pixels.
u16 width;

View file

@ -471,11 +471,16 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
// No texture found, or changed (depending on entry).
// Check for framebuffers.
TextureDefinition def{};
TextureDefinition def;
def.addr = texaddr;
def.dim = dim;
def.format = format;
def.bufw = bufw;
def.swizzled = gstate.isTextureSwizzled();
if (texaddr == 0x40cc000) {
texaddr = texaddr;
}
std::vector<AttachCandidate> candidates = GetFramebufferCandidates(def, 0);
if (candidates.size() > 0) {
@ -851,9 +856,11 @@ FramebufferMatchInfo TextureCacheCommon::MatchFramebuffer(
// NOTE: This check is okay because the first texture formats are the same as the buffer formats.
if (entry.format != (GETextureFormat)framebuffer->format) {
WARN_LOG_ONCE(diffFormat1, G3D, "Texturing from framebuffer with different formats %s != %s", GeTextureFormatToString(entry.format), GeBufferFormatToString(framebuffer->format));
return FramebufferMatchInfo{ FramebufferMatch::NO_MATCH };
} else {
return FramebufferMatchInfo{ FramebufferMatch::VALID };
} else {
// TODO: Here we should either change the format of the framebuffer, reinterpreting it,
// or read from it while reinterpreting it. Not sure which is generally best.
return FramebufferMatchInfo{ FramebufferMatch::NO_MATCH };
}
} else {
// Apply to buffered mode only.
@ -1007,6 +1014,7 @@ bool TextureCacheCommon::SetOffsetTexture(u32 yOffset) {
def.format = fmt;
def.bufw = GetTextureBufw(0, texaddr, fmt);
def.dim = gstate.getTextureDimension(0);
def.swizzled = gstate.isTextureSwizzled();
std::vector<AttachCandidate> candidates = GetFramebufferCandidates(def, texaddrOffset);
if (candidates.size() > 0) {

View file

@ -98,6 +98,7 @@ struct TextureDefinition {
GETextureFormat format;
u32 dim;
u32 bufw;
bool swizzled;
};

View file

@ -496,6 +496,7 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) {
// Don't scale the PPGe texture.
if (entry->addr > 0x05000000 && entry->addr < PSP_GetKernelMemoryEnd())
scaleFactor = 1;
if ((entry->status & TexCacheEntry::STATUS_CHANGE_FREQUENT) != 0 && scaleFactor != 1) {
// Remember for later that we /wanted/ to scale this texture.
entry->status |= TexCacheEntry::STATUS_TO_SCALE;

View file

@ -492,9 +492,6 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
}
}
// If GLES3 is available, we can preallocate the storage, which makes texture loading more efficient.
Draw::DataFormat dstFmt = GetDestFormat(GETextureFormat(entry->format), gstate.getClutPaletteFormat());
int scaleFactor = standardScaleFactor_;
// Rachet down scale factor in low-memory mode.
@ -535,7 +532,10 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
texelsScaledThisFrame_ += w * h;
}
}
// If GLES3 is available, we can preallocate the storage, which makes texture loading more efficient.
Draw::DataFormat dstFmt = GetDestFormat(GETextureFormat(entry->format), gstate.getClutPaletteFormat());
// GLES2 doesn't have support for a "Max lod" which is critical as PSP games often
// don't specify mips all the way down. As a result, we either need to manually generate
// the bottom few levels or rely on OpenGL's autogen mipmaps instead, which might not
@ -546,10 +546,11 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
// NOTE: Since the level is not part of the cache key, we assume it never changes.
u8 level = std::max(0, gstate.getTexLevelOffset16() / 16);
LoadTextureLevel(*entry, replaced, level, scaleFactor, dstFmt);
} else
} else {
LoadTextureLevel(*entry, replaced, 0, scaleFactor, dstFmt);
}
// Mipmapping only enable when texture scaling disable
// Mipmapping is only enabled when texture scaling is disabled.
int texMaxLevel = 0;
bool genMips = false;
if (maxLevel > 0 && scaleFactor == 1) {

View file

@ -285,7 +285,7 @@ void CGEDebugger::DescribePrimaryPreview(const GPUgstate &state, wchar_t desc[25
switch (PrimaryDisplayType(fbTabs->CurrentTabIndex())) {
case PRIMARY_FRAMEBUF:
_snwprintf(desc, 256, L"Color: 0x%08x (%dx%d) fmt %i", state.getFrameBufRawAddress(), primaryBuffer_->GetStride(), primaryBuffer_->GetHeight(), state.FrameBufFormat());
_snwprintf(desc, 256, L"Color: 0x%08x (%dx%d) fmt %s", state.getFrameBufRawAddress(), primaryBuffer_->GetStride(), primaryBuffer_->GetHeight(), GeBufferFormatToString(state.FrameBufFormat()));
break;
case PRIMARY_DEPTHBUF: