mirror of
				https://github.com/RetroDECK/Duckstation.git
				synced 2025-04-10 19:15:14 +00:00 
			
		
		
		
	Settings: Simplify resolution scale enumeration
This commit is contained in:
		
							parent
							
								
									f21cb25426
								
							
						
					
					
						commit
						07ba2ecd3d
					
				|  | @ -93,7 +93,8 @@ public: | |||
|     MAX_PRIMITIVE_WIDTH = 1024, | ||||
|     MAX_PRIMITIVE_HEIGHT = 512, | ||||
|     DOT_TIMER_INDEX = 0, | ||||
|     HBLANK_TIMER_INDEX = 1 | ||||
|     HBLANK_TIMER_INDEX = 1, | ||||
|     MAX_RESOLUTION_SCALE = 16 | ||||
|   }; | ||||
| 
 | ||||
|   // 4x4 dither matrix.
 | ||||
|  |  | |||
|  | @ -26,10 +26,16 @@ bool GPU_HW::Initialize(HostDisplay* host_display, System* system, DMA* dma, Int | |||
|   if (!GPU::Initialize(host_display, system, dma, interrupt_controller, timers)) | ||||
|     return false; | ||||
| 
 | ||||
|   m_resolution_scale = std::clamp<u32>(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale); | ||||
|   m_system->GetSettings().max_gpu_resolution_scale = m_max_resolution_scale; | ||||
|   m_resolution_scale = m_system->GetSettings().gpu_resolution_scale; | ||||
|   m_true_color = m_system->GetSettings().gpu_true_color; | ||||
|   m_texture_filtering = m_system->GetSettings().gpu_texture_filtering; | ||||
|   if (m_resolution_scale < 1 || m_resolution_scale > m_max_resolution_scale) | ||||
|   { | ||||
|     m_system->GetHostInterface()->AddFormattedOSDMessage(5.0f, "Invalid resolution scale %ux specified. Maximum is %u.", | ||||
|                                                          m_resolution_scale, m_max_resolution_scale); | ||||
|     m_resolution_scale = std::clamp<u32>(m_resolution_scale, 1u, m_max_resolution_scale); | ||||
|   } | ||||
| 
 | ||||
|   return true; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -898,19 +898,18 @@ void HostInterface::ToggleSoftwareRendering() | |||
| 
 | ||||
| void HostInterface::ModifyResolutionScale(s32 increment) | ||||
| { | ||||
|   const u32 new_resolution_scale = | ||||
|     std::clamp<u32>(static_cast<u32>(static_cast<s32>(m_settings.gpu_resolution_scale) + increment), 1, | ||||
|                     m_settings.max_gpu_resolution_scale); | ||||
|   const u32 new_resolution_scale = std::clamp<u32>( | ||||
|     static_cast<u32>(static_cast<s32>(m_settings.gpu_resolution_scale) + increment), 1, GPU::MAX_RESOLUTION_SCALE); | ||||
|   if (new_resolution_scale == m_settings.gpu_resolution_scale) | ||||
|     return; | ||||
| 
 | ||||
|   m_settings.gpu_resolution_scale = new_resolution_scale; | ||||
|   if (m_system) | ||||
|     m_system->GetGPU()->UpdateSettings(); | ||||
| 
 | ||||
|   AddFormattedOSDMessage(2.0f, "Resolution scale set to %ux (%ux%u)", m_settings.gpu_resolution_scale, | ||||
|                          GPU::VRAM_WIDTH * m_settings.gpu_resolution_scale, | ||||
|                          GPU::VRAM_HEIGHT * m_settings.gpu_resolution_scale); | ||||
| 
 | ||||
|   if (m_system) | ||||
|     m_system->GetGPU()->UpdateSettings(); | ||||
| } | ||||
| 
 | ||||
| void HostInterface::RecreateSystem() | ||||
|  |  | |||
|  | @ -44,7 +44,6 @@ struct Settings | |||
| 
 | ||||
|   GPURenderer gpu_renderer = GPURenderer::Software; | ||||
|   u32 gpu_resolution_scale = 1; | ||||
|   mutable u32 max_gpu_resolution_scale = 1; | ||||
|   bool gpu_true_color = false; | ||||
|   bool gpu_texture_filtering = false; | ||||
|   bool gpu_force_progressive_scan = false; | ||||
|  |  | |||
|  | @ -30,6 +30,6 @@ void GPUSettingsWidget::setupAdditionalUi() | |||
|     m_ui.renderer->addItem(QString::fromLocal8Bit(Settings::GetRendererDisplayName(static_cast<GPURenderer>(i)))); | ||||
| 
 | ||||
|   m_ui.resolutionScale->addItem(tr("Automatic based on window size")); | ||||
|   for (u32 i = 1; i <= 16; i++) | ||||
|   for (u32 i = 1; i <= GPU::MAX_RESOLUTION_SCALE; i++) | ||||
|     m_ui.resolutionScale->addItem(tr("%1x (%2x%3)").arg(i).arg(GPU::VRAM_WIDTH * i).arg(GPU::VRAM_HEIGHT * i)); | ||||
| } | ||||
|  |  | |||
|  | @ -867,7 +867,7 @@ void SDLHostInterface::DrawQuickSettingsMenu() | |||
|   if (ImGui::BeginMenu("Resolution Scale")) | ||||
|   { | ||||
|     const u32 current_internal_resolution = m_settings_copy.gpu_resolution_scale; | ||||
|     for (u32 scale = 1; scale <= m_settings_copy.max_gpu_resolution_scale; scale++) | ||||
|     for (u32 scale = 1; scale <= GPU::MAX_RESOLUTION_SCALE; scale++) | ||||
|     { | ||||
|       char buf[32]; | ||||
|       std::snprintf(buf, sizeof(buf), "%ux (%ux%u)", scale, scale * GPU::VRAM_WIDTH, scale * GPU::VRAM_HEIGHT); | ||||
|  | @ -1235,7 +1235,7 @@ void SDLHostInterface::DrawSettingsWindow() | |||
|         ImGui::Text("Resolution Scale:"); | ||||
|         ImGui::SameLine(indent); | ||||
| 
 | ||||
|         static constexpr std::array<const char*, 16> resolutions = {{ | ||||
|         static constexpr std::array<const char*, GPU::MAX_RESOLUTION_SCALE> resolutions = {{ | ||||
|           "1x (1024x512)", | ||||
|           "2x (2048x1024)", | ||||
|           "3x (3072x1536)", | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Connor McLaughlin
						Connor McLaughlin