GTE: Remove dependency on GPUDevice
This commit is contained in:
parent
d34707a377
commit
53fb5cd9e1
|
@ -8,7 +8,6 @@
|
|||
#include "cpu_pgxp.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "util/gpu_device.h"
|
||||
#include "util/state_wrapper.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
|
@ -228,7 +227,7 @@ bool GTE::DoState(StateWrapper& sw)
|
|||
return !sw.HasError();
|
||||
}
|
||||
|
||||
void GTE::UpdateAspectRatio()
|
||||
void GTE::UpdateAspectRatio(u32 window_width, u32 window_height)
|
||||
{
|
||||
if (!g_settings.gpu_widescreen_hack)
|
||||
{
|
||||
|
@ -243,14 +242,8 @@ void GTE::UpdateAspectRatio()
|
|||
{
|
||||
case DisplayAspectRatio::MatchWindow:
|
||||
{
|
||||
if (!g_gpu_device || !g_gpu_device->HasMainSwapChain())
|
||||
{
|
||||
s_config.aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
return;
|
||||
}
|
||||
|
||||
num = g_gpu_device->GetMainSwapChain()->GetWidth();
|
||||
denom = g_gpu_device->GetMainSwapChain()->GetHeight();
|
||||
num = window_width;
|
||||
denom = window_height;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace GTE {
|
|||
void Initialize();
|
||||
void Reset();
|
||||
bool DoState(StateWrapper& sw);
|
||||
void UpdateAspectRatio();
|
||||
void UpdateAspectRatio(u32 window_width, u32 window_height);
|
||||
|
||||
// control registers are offset by +32
|
||||
u32 ReadRegister(u32 index);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "imgui_overlays.h"
|
||||
#include "shader_cache_version.h"
|
||||
#include "system.h"
|
||||
#include "system_private.h"
|
||||
|
||||
#include "scmversion/scmversion.h"
|
||||
|
||||
|
@ -354,10 +355,8 @@ void Host::UpdateDisplayWindow(bool fullscreen)
|
|||
if (!g_gpu_device)
|
||||
return;
|
||||
|
||||
const GPUVSyncMode vsync_mode =
|
||||
g_gpu_device->HasMainSwapChain() ? g_gpu_device->GetMainSwapChain()->GetVSyncMode() : GPUVSyncMode::Disabled;
|
||||
const bool allow_present_throttle =
|
||||
g_gpu_device->HasMainSwapChain() && g_gpu_device->GetMainSwapChain()->IsPresentThrottleAllowed();
|
||||
const GPUVSyncMode vsync_mode = System::GetEffectiveVSyncMode();
|
||||
const bool allow_present_throttle = System::ShouldAllowPresentThrottle();
|
||||
std::optional<GPUDevice::ExclusiveFullscreenMode> fullscreen_mode;
|
||||
if (fullscreen && g_gpu_device->SupportsExclusiveFullscreen())
|
||||
{
|
||||
|
@ -394,21 +393,13 @@ void Host::UpdateDisplayWindow(bool fullscreen)
|
|||
return;
|
||||
}
|
||||
|
||||
const float f_width = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetWidth());
|
||||
const float f_height = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetHeight());
|
||||
const u32 new_width = g_gpu_device->GetMainSwapChain()->GetWidth();
|
||||
const u32 new_height = g_gpu_device->GetMainSwapChain()->GetHeight();
|
||||
const float f_width = static_cast<float>(new_width);
|
||||
const float f_height = static_cast<float>(new_height);
|
||||
ImGuiManager::WindowResized(f_width, f_height);
|
||||
InputManager::SetDisplayWindowSize(f_width, f_height);
|
||||
System::HostDisplayResized();
|
||||
|
||||
if (System::IsValid())
|
||||
{
|
||||
// Fix up vsync etc.
|
||||
System::UpdateSpeedLimiterState();
|
||||
|
||||
// If we're paused, re-present the current frame at the new window size.
|
||||
if (System::IsPaused())
|
||||
System::InvalidateDisplay();
|
||||
}
|
||||
System::DisplayWindowResized(new_width, new_height);
|
||||
}
|
||||
|
||||
void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
|
||||
|
@ -426,24 +417,13 @@ void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
|
|||
return;
|
||||
}
|
||||
|
||||
const float f_width = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetWidth());
|
||||
const float f_height = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetHeight());
|
||||
const u32 new_width = g_gpu_device->GetMainSwapChain()->GetWidth();
|
||||
const u32 new_height = g_gpu_device->GetMainSwapChain()->GetHeight();
|
||||
const float f_width = static_cast<float>(new_width);
|
||||
const float f_height = static_cast<float>(new_height);
|
||||
ImGuiManager::WindowResized(f_width, f_height);
|
||||
InputManager::SetDisplayWindowSize(f_width, f_height);
|
||||
|
||||
// If we're paused, re-present the current frame at the new window size.
|
||||
if (System::IsValid())
|
||||
{
|
||||
if (System::IsPaused())
|
||||
{
|
||||
// Hackity hack, on some systems, presenting a single frame isn't enough to actually get it
|
||||
// displayed. Two seems to be good enough. Maybe something to do with direct scanout.
|
||||
System::InvalidateDisplay();
|
||||
System::InvalidateDisplay();
|
||||
}
|
||||
|
||||
System::HostDisplayResized();
|
||||
}
|
||||
System::DisplayWindowResized(new_width, new_height);
|
||||
}
|
||||
|
||||
void Host::ReleaseGPUDevice()
|
||||
|
|
|
@ -1898,7 +1898,8 @@ bool System::Initialize(std::unique_ptr<CDImage> disc, DiscRegion disc_region, b
|
|||
if (!CreateGPU(force_software_renderer ? GPURenderer::Software : g_settings.gpu_renderer, false, fullscreen, error))
|
||||
return false;
|
||||
|
||||
GTE::UpdateAspectRatio();
|
||||
if (GPUSwapChain* swap_chain = g_gpu_device->GetMainSwapChain())
|
||||
GTE::UpdateAspectRatio(swap_chain->GetWidth(), swap_chain->GetHeight());
|
||||
|
||||
if (g_settings.gpu_pgxp_enable)
|
||||
CPU::PGXP::Initialize();
|
||||
|
@ -4347,7 +4348,8 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
|
|||
(g_settings.display_aspect_ratio_custom_numerator != old_settings.display_aspect_ratio_custom_numerator ||
|
||||
g_settings.display_aspect_ratio_custom_denominator != old_settings.display_aspect_ratio_custom_denominator)))
|
||||
{
|
||||
GTE::UpdateAspectRatio();
|
||||
if (GPUSwapChain* swap_chain = g_gpu_device->GetMainSwapChain())
|
||||
GTE::UpdateAspectRatio(swap_chain->GetWidth(), swap_chain->GetHeight());
|
||||
}
|
||||
|
||||
if (g_settings.gpu_pgxp_enable != old_settings.gpu_pgxp_enable ||
|
||||
|
@ -5604,7 +5606,8 @@ void System::ToggleWidescreen()
|
|||
Settings::GetDisplayAspectRatioDisplayName(g_settings.display_aspect_ratio), 5.0f));
|
||||
}
|
||||
|
||||
GTE::UpdateAspectRatio();
|
||||
if (GPUSwapChain* swap_chain = g_gpu_device->GetMainSwapChain())
|
||||
GTE::UpdateAspectRatio(swap_chain->GetWidth(), swap_chain->GetHeight());
|
||||
}
|
||||
|
||||
void System::ToggleSoftwareRendering()
|
||||
|
@ -5650,16 +5653,25 @@ void System::RequestDisplaySize(float scale /*= 0.0f*/)
|
|||
Host::RequestResizeHostDisplay(static_cast<s32>(requested_width), static_cast<s32>(requested_height));
|
||||
}
|
||||
|
||||
void System::HostDisplayResized()
|
||||
void System::DisplayWindowResized(u32 width, u32 height)
|
||||
{
|
||||
if (!IsValid())
|
||||
return;
|
||||
|
||||
if (g_settings.gpu_widescreen_hack && g_settings.display_aspect_ratio == DisplayAspectRatio::MatchWindow)
|
||||
GTE::UpdateAspectRatio();
|
||||
GTE::UpdateAspectRatio(width, height);
|
||||
|
||||
g_gpu->RestoreDeviceContext();
|
||||
g_gpu->UpdateResolutionScale();
|
||||
|
||||
// If we're paused, re-present the current frame at the new window size.
|
||||
if (IsPaused())
|
||||
{
|
||||
// Hackity hack, on some systems, presenting a single frame isn't enough to actually get it
|
||||
// displayed. Two seems to be good enough. Maybe something to do with direct scanout.
|
||||
InvalidateDisplay();
|
||||
InvalidateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
bool System::PresentDisplay(bool explicit_present, u64 present_time)
|
||||
|
|
|
@ -397,10 +397,6 @@ void StopMediaCapture();
|
|||
/// Toggle Widescreen Hack and Aspect Ratio
|
||||
void ToggleWidescreen();
|
||||
|
||||
/// Returns true if vsync should be used.
|
||||
GPUVSyncMode GetEffectiveVSyncMode();
|
||||
bool ShouldAllowPresentThrottle();
|
||||
|
||||
/// Quick switch between software and hardware rendering.
|
||||
void ToggleSoftwareRendering();
|
||||
|
||||
|
@ -408,9 +404,6 @@ void ToggleSoftwareRendering();
|
|||
/// If the scale is set to 0, the internal resolution will be used, otherwise it is treated as a multiplier to 1x.
|
||||
void RequestDisplaySize(float scale = 0.0f);
|
||||
|
||||
/// Call when host display size changes, use with "match display" aspect ratio setting.
|
||||
void HostDisplayResized();
|
||||
|
||||
/// Renders the display.
|
||||
bool PresentDisplay(bool explicit_present, u64 present_time);
|
||||
void InvalidateDisplay();
|
||||
|
|
|
@ -27,6 +27,13 @@ void IncrementFrameNumber();
|
|||
void IncrementInternalFrameNumber();
|
||||
void FrameDone();
|
||||
|
||||
/// Returns true if vsync should be used.
|
||||
GPUVSyncMode GetEffectiveVSyncMode();
|
||||
bool ShouldAllowPresentThrottle();
|
||||
|
||||
/// Call when host display size changes, use with "match display" aspect ratio setting.
|
||||
void DisplayWindowResized(u32 width, u32 height);
|
||||
|
||||
/// Performs mandatory hardware checks.
|
||||
bool PerformEarlyHardwareChecks(Error* error);
|
||||
|
||||
|
|
Loading…
Reference in New Issue