GTE: Remove dependency on GPUDevice
This commit is contained in:
parent
d34707a377
commit
53fb5cd9e1
|
@ -8,7 +8,6 @@
|
||||||
#include "cpu_pgxp.h"
|
#include "cpu_pgxp.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "util/gpu_device.h"
|
|
||||||
#include "util/state_wrapper.h"
|
#include "util/state_wrapper.h"
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
@ -228,7 +227,7 @@ bool GTE::DoState(StateWrapper& sw)
|
||||||
return !sw.HasError();
|
return !sw.HasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTE::UpdateAspectRatio()
|
void GTE::UpdateAspectRatio(u32 window_width, u32 window_height)
|
||||||
{
|
{
|
||||||
if (!g_settings.gpu_widescreen_hack)
|
if (!g_settings.gpu_widescreen_hack)
|
||||||
{
|
{
|
||||||
|
@ -243,14 +242,8 @@ void GTE::UpdateAspectRatio()
|
||||||
{
|
{
|
||||||
case DisplayAspectRatio::MatchWindow:
|
case DisplayAspectRatio::MatchWindow:
|
||||||
{
|
{
|
||||||
if (!g_gpu_device || !g_gpu_device->HasMainSwapChain())
|
num = window_width;
|
||||||
{
|
denom = window_height;
|
||||||
s_config.aspect_ratio = DisplayAspectRatio::R4_3;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
num = g_gpu_device->GetMainSwapChain()->GetWidth();
|
|
||||||
denom = g_gpu_device->GetMainSwapChain()->GetHeight();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace GTE {
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Reset();
|
void Reset();
|
||||||
bool DoState(StateWrapper& sw);
|
bool DoState(StateWrapper& sw);
|
||||||
void UpdateAspectRatio();
|
void UpdateAspectRatio(u32 window_width, u32 window_height);
|
||||||
|
|
||||||
// control registers are offset by +32
|
// control registers are offset by +32
|
||||||
u32 ReadRegister(u32 index);
|
u32 ReadRegister(u32 index);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "imgui_overlays.h"
|
#include "imgui_overlays.h"
|
||||||
#include "shader_cache_version.h"
|
#include "shader_cache_version.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "system_private.h"
|
||||||
|
|
||||||
#include "scmversion/scmversion.h"
|
#include "scmversion/scmversion.h"
|
||||||
|
|
||||||
|
@ -354,10 +355,8 @@ void Host::UpdateDisplayWindow(bool fullscreen)
|
||||||
if (!g_gpu_device)
|
if (!g_gpu_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const GPUVSyncMode vsync_mode =
|
const GPUVSyncMode vsync_mode = System::GetEffectiveVSyncMode();
|
||||||
g_gpu_device->HasMainSwapChain() ? g_gpu_device->GetMainSwapChain()->GetVSyncMode() : GPUVSyncMode::Disabled;
|
const bool allow_present_throttle = System::ShouldAllowPresentThrottle();
|
||||||
const bool allow_present_throttle =
|
|
||||||
g_gpu_device->HasMainSwapChain() && g_gpu_device->GetMainSwapChain()->IsPresentThrottleAllowed();
|
|
||||||
std::optional<GPUDevice::ExclusiveFullscreenMode> fullscreen_mode;
|
std::optional<GPUDevice::ExclusiveFullscreenMode> fullscreen_mode;
|
||||||
if (fullscreen && g_gpu_device->SupportsExclusiveFullscreen())
|
if (fullscreen && g_gpu_device->SupportsExclusiveFullscreen())
|
||||||
{
|
{
|
||||||
|
@ -394,21 +393,13 @@ void Host::UpdateDisplayWindow(bool fullscreen)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float f_width = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetWidth());
|
const u32 new_width = g_gpu_device->GetMainSwapChain()->GetWidth();
|
||||||
const float f_height = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetHeight());
|
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);
|
ImGuiManager::WindowResized(f_width, f_height);
|
||||||
InputManager::SetDisplayWindowSize(f_width, f_height);
|
InputManager::SetDisplayWindowSize(f_width, f_height);
|
||||||
System::HostDisplayResized();
|
System::DisplayWindowResized(new_width, new_height);
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
|
void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
|
||||||
|
@ -426,24 +417,13 @@ void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float f_width = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetWidth());
|
const u32 new_width = g_gpu_device->GetMainSwapChain()->GetWidth();
|
||||||
const float f_height = static_cast<float>(g_gpu_device->GetMainSwapChain()->GetHeight());
|
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);
|
ImGuiManager::WindowResized(f_width, f_height);
|
||||||
InputManager::SetDisplayWindowSize(f_width, f_height);
|
InputManager::SetDisplayWindowSize(f_width, f_height);
|
||||||
|
System::DisplayWindowResized(new_width, new_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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::ReleaseGPUDevice()
|
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))
|
if (!CreateGPU(force_software_renderer ? GPURenderer::Software : g_settings.gpu_renderer, false, fullscreen, error))
|
||||||
return false;
|
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)
|
if (g_settings.gpu_pgxp_enable)
|
||||||
CPU::PGXP::Initialize();
|
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_numerator != old_settings.display_aspect_ratio_custom_numerator ||
|
||||||
g_settings.display_aspect_ratio_custom_denominator != old_settings.display_aspect_ratio_custom_denominator)))
|
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 ||
|
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));
|
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()
|
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));
|
Host::RequestResizeHostDisplay(static_cast<s32>(requested_width), static_cast<s32>(requested_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::HostDisplayResized()
|
void System::DisplayWindowResized(u32 width, u32 height)
|
||||||
{
|
{
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_settings.gpu_widescreen_hack && g_settings.display_aspect_ratio == DisplayAspectRatio::MatchWindow)
|
if (g_settings.gpu_widescreen_hack && g_settings.display_aspect_ratio == DisplayAspectRatio::MatchWindow)
|
||||||
GTE::UpdateAspectRatio();
|
GTE::UpdateAspectRatio(width, height);
|
||||||
|
|
||||||
g_gpu->RestoreDeviceContext();
|
g_gpu->RestoreDeviceContext();
|
||||||
g_gpu->UpdateResolutionScale();
|
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)
|
bool System::PresentDisplay(bool explicit_present, u64 present_time)
|
||||||
|
|
|
@ -397,10 +397,6 @@ void StopMediaCapture();
|
||||||
/// Toggle Widescreen Hack and Aspect Ratio
|
/// Toggle Widescreen Hack and Aspect Ratio
|
||||||
void ToggleWidescreen();
|
void ToggleWidescreen();
|
||||||
|
|
||||||
/// Returns true if vsync should be used.
|
|
||||||
GPUVSyncMode GetEffectiveVSyncMode();
|
|
||||||
bool ShouldAllowPresentThrottle();
|
|
||||||
|
|
||||||
/// Quick switch between software and hardware rendering.
|
/// Quick switch between software and hardware rendering.
|
||||||
void ToggleSoftwareRendering();
|
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.
|
/// 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);
|
void RequestDisplaySize(float scale = 0.0f);
|
||||||
|
|
||||||
/// Call when host display size changes, use with "match display" aspect ratio setting.
|
|
||||||
void HostDisplayResized();
|
|
||||||
|
|
||||||
/// Renders the display.
|
/// Renders the display.
|
||||||
bool PresentDisplay(bool explicit_present, u64 present_time);
|
bool PresentDisplay(bool explicit_present, u64 present_time);
|
||||||
void InvalidateDisplay();
|
void InvalidateDisplay();
|
||||||
|
|
|
@ -27,6 +27,13 @@ void IncrementFrameNumber();
|
||||||
void IncrementInternalFrameNumber();
|
void IncrementInternalFrameNumber();
|
||||||
void FrameDone();
|
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.
|
/// Performs mandatory hardware checks.
|
||||||
bool PerformEarlyHardwareChecks(Error* error);
|
bool PerformEarlyHardwareChecks(Error* error);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue