diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 6a20f805c..c719378b5 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -28,7 +28,7 @@ bool GPU::Initialize(System* system, DMA* dma, InterruptController* interrupt_co void GPU::UpdateSettings() { - m_resolution_scale = std::clamp(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale); + } void GPU::Reset() diff --git a/src/core/gpu.h b/src/core/gpu.h index c808b85aa..85a4d40d6 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -52,9 +52,7 @@ public: void DMARead(u32* words, u32 word_count); void DMAWrite(const u32* words, u32 word_count); - // Resolution scaling. - u32 GetResolutionScale() const { return m_resolution_scale; } - u32 GetMaxResolutionScale() const { return m_max_resolution_scale; } + // Recompile shaders/recreate framebuffers when needed. virtual void UpdateSettings(); // Ticks for hblank/vblank. @@ -299,10 +297,6 @@ protected: InterruptController* m_interrupt_controller = nullptr; Timers* m_timers = nullptr; - // Resolution scale. - u32 m_resolution_scale = 1; - u32 m_max_resolution_scale = 1; - union GPUSTAT { u32 bits; diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 01b0537bb..1ae3d370a 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -17,10 +17,24 @@ void GPU_HW::Reset() m_batch = {}; } +bool GPU_HW::Initialize(System* system, DMA* dma, InterruptController* interrupt_controller, Timers* timers) +{ + if (!GPU::Initialize(system, dma, interrupt_controller, timers)) + return false; + + m_resolution_scale = std::clamp(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale); + m_system->GetSettings().gpu_resolution_scale = m_resolution_scale; + m_system->GetSettings().max_gpu_resolution_scale = m_max_resolution_scale; + m_true_color = m_system->GetSettings().gpu_true_color; + return true; +} + void GPU_HW::UpdateSettings() { GPU::UpdateSettings(); + m_resolution_scale = std::clamp(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale); + m_system->GetSettings().gpu_resolution_scale = m_resolution_scale; m_true_color = m_system->GetSettings().gpu_true_color; } diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index 1aafb37ba..586c70e5a 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -11,6 +11,7 @@ public: GPU_HW(); virtual ~GPU_HW(); + virtual bool Initialize(System* system, DMA* dma, InterruptController* interrupt_controller, Timers* timers) override; virtual void Reset() override; virtual void UpdateSettings() override; @@ -108,6 +109,8 @@ protected: std::string GenerateDisplayFragmentShader(bool depth_24bit, bool interlaced); HWRenderBatch m_batch = {}; + u32 m_resolution_scale = 1; + u32 m_max_resolution_scale = 1; bool m_true_color = false; private: diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 8d046aa99..483cbbf90 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -16,10 +16,11 @@ GPU_HW_OpenGL::~GPU_HW_OpenGL() bool GPU_HW_OpenGL::Initialize(System* system, DMA* dma, InterruptController* interrupt_controller, Timers* timers) { + SetMaxResolutionScale(); + if (!GPU_HW::Initialize(system, dma, interrupt_controller, timers)) return false; - SetMaxResolutionScale(); CreateFramebuffer(); CreateVertexBuffer(); if (!CompilePrograms()) @@ -149,8 +150,6 @@ void GPU_HW_OpenGL::SetMaxResolutionScale() m_max_resolution_scale = std::min(max_texture_scale, line_width_range[1]); Log_InfoPrintf("Maximum resolution scale is %u", m_max_resolution_scale); - - m_resolution_scale = std::min(m_resolution_scale, m_max_resolution_scale); } void GPU_HW_OpenGL::CreateFramebuffer() diff --git a/src/core/system.cpp b/src/core/system.cpp index d0547f7d8..9808931a1 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -130,10 +130,6 @@ bool System::CreateGPU() m_bus->SetGPU(m_gpu.get()); m_dma->SetGPU(m_gpu.get()); - - // the new GPU could have a lower maximum resolution - m_settings.gpu_resolution_scale = m_gpu->GetResolutionScale(); - m_settings.max_gpu_resolution_scale = m_gpu->GetMaxResolutionScale(); return true; }