Skip to content

Commit

Permalink
Merge pull request #4998 from stenzek/vulkan-aspect-changes
Browse files Browse the repository at this point in the history
Vulkan: Fix issue where target rectangle changes weren't detected
  • Loading branch information
Helios747 committed Mar 4, 2017
2 parents 51e932b + 2fd7789 commit de230f3
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Source/Core/VideoBackends/Vulkan/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
StateTracker::GetInstance()->EndRenderPass();
StateTracker::GetInstance()->OnEndFrame();

// There are a few variables which can alter the final window draw rectangle, and some of them
// are determined by guest state. Currently, the only way to catch these is to update every frame.
UpdateDrawRectangle();

// Render the frame dump image if enabled.
if (IsFrameDumping())
{
Expand Down Expand Up @@ -563,6 +567,10 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
// this can cause a target size change, which would result in a black frame if done earlier.
CheckForTargetResize(fb_width, fb_stride, fb_height);

// Update the window size based on the frame that was just rendered.
// Due to depending on guest state, we need to call this every frame.
SetWindowSize(static_cast<int>(fb_stride), static_cast<int>(fb_height));

// Clean up stale textures.
TextureCache::GetInstance()->Cleanup(frameCount);
}
Expand Down Expand Up @@ -1010,16 +1018,12 @@ void Renderer::CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height)
FramebufferManagerBase::SetLastXfbWidth(new_width);
FramebufferManagerBase::SetLastXfbHeight(new_height);

// Changing the XFB source area will likely change the final drawing rectangle.
UpdateDrawRectangle();
// Changing the XFB source area may alter the target size.
if (CalculateTargetSize())
{
PixelShaderManager::SetEfbScaleChanged();
ResizeEFBTextures();
}

// This call is needed for auto-resizing to work.
SetWindowSize(static_cast<int>(fb_stride), static_cast<int>(fb_height));
}

void Renderer::CheckForSurfaceChange()
Expand Down Expand Up @@ -1101,6 +1105,8 @@ void Renderer::CheckForConfigChanges()
int old_aspect_ratio = g_ActiveConfig.iAspectRatio;
bool old_force_filtering = g_ActiveConfig.bForceFiltering;
bool old_ssaa = g_ActiveConfig.bSSAA;
bool old_use_xfb = g_ActiveConfig.bUseXFB;
bool old_use_realxfb = g_ActiveConfig.bUseRealXFB;

// Copy g_Config to g_ActiveConfig.
// NOTE: This can potentially race with the UI thread, however if it does, the changes will be
Expand All @@ -1115,20 +1121,16 @@ void Renderer::CheckForConfigChanges()
bool stereo_changed = old_stereo_mode != g_ActiveConfig.iStereoMode;
bool efb_scale_changed = s_last_efb_scale != g_ActiveConfig.iEFBScale;
bool aspect_changed = old_aspect_ratio != g_ActiveConfig.iAspectRatio;
bool use_xfb_changed = old_use_xfb != g_ActiveConfig.bUseXFB;
bool use_realxfb_changed = old_use_realxfb != g_ActiveConfig.bUseRealXFB;

// Update texture cache settings with any changed options.
TextureCache::GetInstance()->OnConfigChanged(g_ActiveConfig);

// Handle internal resolution changes.
if (efb_scale_changed)
s_last_efb_scale = g_ActiveConfig.iEFBScale;

// If the aspect ratio is changed, this changes the area that the game is drawn to.
if (aspect_changed)
UpdateDrawRectangle();

if (efb_scale_changed || aspect_changed)
// Handle settings that can cause the target rectangle to change.
if (efb_scale_changed || aspect_changed || use_xfb_changed || use_realxfb_changed)
{
s_last_efb_scale = g_ActiveConfig.iEFBScale;
if (CalculateTargetSize())
ResizeEFBTextures();
}
Expand Down

0 comments on commit de230f3

Please sign in to comment.