Skip to content

Commit

Permalink
Fix render resolution race condition. Should help #8002
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 27, 2015
1 parent 89513a3 commit d3b265a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
17 changes: 8 additions & 9 deletions GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,13 @@ FramebufferManagerCommon::FramebufferManagerCommon() :
currentRenderVfb_(0),
framebufRangeEnd_(0),
hackForce04154000Download_(false) {
renderWidth_ = (float)PSP_CoreParameter().renderWidth;
renderHeight_ = (float)PSP_CoreParameter().renderHeight;
pixelWidth_ = PSP_CoreParameter().pixelWidth;
pixelHeight_ = PSP_CoreParameter().pixelHeight;
UpdateSize();
}

FramebufferManagerCommon::~FramebufferManagerCommon() {
}

void FramebufferManagerCommon::Init() {

const std::string gameId = g_paramSFO.GetValueString("DISC_ID");
// This applies a hack to Dangan Ronpa, its demo, and its sequel.
// The game draws solid colors to a small framebuffer, and then reads this directly in VRAM.
Expand All @@ -114,15 +110,18 @@ void FramebufferManagerCommon::Init() {
BeginFrame();
}

void FramebufferManagerCommon::UpdateSize() {
renderWidth_ = (float)PSP_CoreParameter().renderWidth;
renderHeight_ = (float)PSP_CoreParameter().renderHeight;
pixelWidth_ = PSP_CoreParameter().pixelWidth;
pixelHeight_ = PSP_CoreParameter().pixelHeight;
}

void FramebufferManagerCommon::BeginFrame() {
DecimateFBOs();
currentRenderVfb_ = 0;
useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
updateVRAM_ = !(g_Config.iRenderingMode == FB_NON_BUFFERED_MODE || g_Config.iRenderingMode == FB_BUFFERED_MODE);
renderWidth_ = (float)PSP_CoreParameter().renderWidth;
renderHeight_ = (float)PSP_CoreParameter().renderHeight;
pixelWidth_ = PSP_CoreParameter().pixelWidth;
pixelHeight_ = PSP_CoreParameter().pixelHeight;
}

void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
Expand Down
2 changes: 2 additions & 0 deletions GPU/Common/FramebufferCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ class FramebufferManagerCommon {
void SetRenderSize(VirtualFramebuffer *vfb);

protected:
void UpdateSize();

virtual void DisableState() = 0;
virtual void ClearBuffer() = 0;
virtual void ClearDepthBuffer() = 0;
Expand Down
3 changes: 2 additions & 1 deletion GPU/Directx9/FramebufferDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ namespace DX9 {
void FramebufferManagerDX9::EndFrame() {
if (resized_) {
DestroyAllFBOs();
dxstate.viewport.set(0, 0, pixelWidth_, pixelHeight_);
dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
int zoom = g_Config.iInternalResolution;
Expand All @@ -1132,6 +1132,7 @@ namespace DX9 {
PSP_CoreParameter().renderHeight = 272 * zoom;
}

UpdateSize();
ShowScreenResolution();
resized_ = false;
}
Expand Down
6 changes: 5 additions & 1 deletion GPU/GLES/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,10 @@ void ShowScreenResolution();

void FramebufferManager::EndFrame() {
if (resized_) {
// TODO: Only do this if the new size actually changed the renderwidth/height.
DestroyAllFBOs();
glstate.viewport.set(0, 0, pixelWidth_, pixelHeight_);
// Probably not necessary
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);

// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
Expand All @@ -1684,6 +1686,8 @@ void FramebufferManager::EndFrame() {
PSP_CoreParameter().renderHeight = 272 * zoom;
}

UpdateSize();

resized_ = false;
#ifdef _WIN32
ShowScreenResolution();
Expand Down

1 comment on commit d3b265a

@unknownbrackets
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this makes a lot more sense. Cool.

-[Unknown]

Please sign in to comment.