Another attempt at reusing bigger framebuffers. Doesn't solve everything but hopefully won't break much like the last attempt.

This commit is contained in:
Henrik Rydgard 2013-06-20 22:18:44 +02:00
parent 2953d01d15
commit 2694343243
4 changed files with 37 additions and 10 deletions

View file

@ -350,16 +350,35 @@ void FramebufferManager::SetRenderFrameBuffer() {
int drawing_width, drawing_height;
GuessDrawingSize(drawing_width, drawing_height);
// Find a matching framebuffer
int buffer_width = drawing_width;
int buffer_height = drawing_height;
// Find a matching framebuffer, same size or bigger
VirtualFramebuffer *vfb = 0;
for (auto iter = vfbs_.begin(); iter != vfbs_.end(); ++iter) {
VirtualFramebuffer *v = *iter;
if (MaskedEqual(v->fb_address, fb_address) && v->width == drawing_width && v->height == drawing_height && v->format == fmt) {
// Let's not be so picky for now. Let's say this is the one.
vfb = v;
// Update fb stride in case it changed
vfb->fb_stride = fb_stride;
break;
if (MaskedEqual(v->fb_address, fb_address) && v->format == fmt) {
// Okay, let's check the sizes. If the new one is bigger than the old one, recreate.
// If the opposite, just use it and hope that the game sets scissors accordingly.
if (v->bufferWidth >= drawing_width && v->bufferHeight >= drawing_height) {
// Let's not be so picky for now. Let's say this is the one.
vfb = v;
// Update fb stride in case it changed
vfb->fb_stride = fb_stride;
// Just hack the width/height and we should be fine. also hack renderwidth/renderheight?
v->width = drawing_width;
v->height = drawing_height;
break;
} else {
INFO_LOG(HLE, "Embiggening framebuffer (%i, %i) -> (%i, %i)", (int)v->width, (int)v->height, drawing_width, drawing_height);
// drawing_width or drawing_height is bigger. Let's recreate with the max.
// To do this right we should copy the data over too, but meh.
buffer_width = std::max((int)v->width, drawing_width);
buffer_height = std::max((int)v->height, drawing_height);
delete v;
vfbs_.erase(iter);
break;
}
}
}
@ -379,6 +398,8 @@ void FramebufferManager::SetRenderFrameBuffer() {
vfb->height = drawing_height;
vfb->renderWidth = (u16)(drawing_width * renderWidthFactor);
vfb->renderHeight = (u16)(drawing_height * renderHeightFactor);
vfb->bufferWidth = buffer_width;
vfb->bufferHeight = buffer_height;
vfb->format = fmt;
vfb->usageFlags = FB_USAGE_RENDERTARGET;
vfb->dirtyAfterDisplay = true;

View file

@ -54,10 +54,16 @@ struct VirtualFramebuffer {
int z_stride;
// There's also a top left of the drawing region, but meh...
// width/height: The detected size of the current framebuffer.
u16 width;
u16 height;
// renderWidth/renderHeight: The actual size we render at. May be scaled to render at higher resolutions.
u16 renderWidth;
u16 renderHeight;
// bufferWidth/bufferHeight: The actual (but non scaled) size of the buffer we render to. May only be bigger than width/height.
u16 bufferWidth;
u16 bufferHeight;
u16 usageFlags;

View file

@ -265,8 +265,8 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
if (g_Config.bBufferedRendering) {
renderX = 0;
renderY = 0;
renderWidth = framebufferManager_->GetRenderWidth();
renderHeight = framebufferManager_->GetRenderHeight();
renderWidth = framebufferManager_->GetRenderWidth();
renderHeight = framebufferManager_->GetRenderHeight();
renderWidthFactor = (float)renderWidth / framebufferManager_->GetTargetWidth();
renderHeightFactor = (float)renderHeight / framebufferManager_->GetTargetHeight();
} else {

2
native

@ -1 +1 @@
Subproject commit deb4ba83235a86491d073db73a1e5bab2a5ce523
Subproject commit 0a26fae856aecdaa426d92fa5dde101b19487796