diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index c15e0e21b..f2e713416 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -19,6 +19,7 @@ bool GPU_HW_OpenGL::Initialize(System* system, DMA* dma, InterruptController* in if (!GPU_HW::Initialize(system, dma, interrupt_controller, timers)) return false; + SetMaxResolutionScale(); CreateFramebuffer(); CreateVertexBuffer(); if (!CompilePrograms()) @@ -103,6 +104,24 @@ std::tuple GPU_HW_OpenGL::ConvertToFramebufferCoordinates(s32 x, s32 y return std::make_tuple(x, static_cast(static_cast(VRAM_HEIGHT) - y)); } +void GPU_HW_OpenGL::SetMaxResolutionScale() +{ + GLint max_texture_size = VRAM_WIDTH; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); + Log_InfoPrintf("Max texture size: %dx%d", max_texture_size, max_texture_size); + const int max_texture_scale = max_texture_size / VRAM_WIDTH; + + std::array line_width_range = {{1, 1}}; + glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, line_width_range.data()); + Log_InfoPrintf("Max line width: %d", line_width_range[1]); + + const u32 max_resolution_scale = std::min(max_texture_scale, line_width_range[1]); + Log_InfoPrintf("Maximum resolution scale is %u", max_resolution_scale); + m_system->GetSettings().max_gpu_resolution_scale = max_resolution_scale; + m_system->GetSettings().gpu_resolution_scale = + std::min(m_system->GetSettings().gpu_resolution_scale, max_resolution_scale); +} + void GPU_HW_OpenGL::CreateFramebuffer() { // save old vram texture/fbo, in case we're changing scale @@ -550,6 +569,7 @@ void GPU_HW_OpenGL::FlushRender() glDisable(GL_DEPTH_TEST); glEnable(GL_SCISSOR_TEST); glDepthMask(GL_FALSE); + glLineWidth(static_cast(m_resolution_scale)); SetProgram(); SetViewport(); SetScissor(); diff --git a/src/core/gpu_hw_opengl.h b/src/core/gpu_hw_opengl.h index 5869faa08..c90d9b969 100644 --- a/src/core/gpu_hw_opengl.h +++ b/src/core/gpu_hw_opengl.h @@ -37,6 +37,7 @@ private: std::tuple ConvertToFramebufferCoordinates(s32 x, s32 y); + void SetMaxResolutionScale(); void CreateFramebuffer(); void ClearFramebuffer(); void DestroyFramebuffer(); diff --git a/src/core/settings.h b/src/core/settings.h index 4b662d32f..be21d14d2 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -12,6 +12,7 @@ struct Settings GPUBackend gpu_backend = GPUBackend::OpenGL; u32 gpu_resolution_scale = 1; + u32 max_gpu_resolution_scale = 1; // TODO: Controllers, memory cards, etc. }; diff --git a/src/duckstation/sdl_interface.cpp b/src/duckstation/sdl_interface.cpp index f8275dfe5..e5dcc1229 100644 --- a/src/duckstation/sdl_interface.cpp +++ b/src/duckstation/sdl_interface.cpp @@ -524,7 +524,7 @@ void SDLInterface::RenderMainMenuBar() if (ImGui::BeginMenu("Internal Resolution")) { const u32 current_internal_resolution = m_system->GetSettings().gpu_resolution_scale; - for (u32 scale = 1; scale <= 16; scale++) + for (u32 scale = 1; scale <= m_system->GetSettings().max_gpu_resolution_scale; scale++) { if (ImGui::MenuItem( TinyString::FromFormat("%ux (%ux%u)", scale, scale * GPU::VRAM_WIDTH, scale * GPU::VRAM_HEIGHT),