mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Implement game render thread delay (#180)
More details: https://www.reddit.com/r/Citra/comments/1e1v4e1/fixing_luigis_mansion_2_performance_issues_once/
This commit is contained in:
		
							parent
							
								
									cc220928bd
								
							
						
					
					
						commit
						e90795b616
					
				
					 13 changed files with 168 additions and 3 deletions
				
			
		|  | @ -667,6 +667,8 @@ void Config::ReadRendererValues() { | |||
|     ReadGlobalSetting(Settings::values.texture_filter); | ||||
|     ReadGlobalSetting(Settings::values.texture_sampling); | ||||
| 
 | ||||
|     ReadGlobalSetting(Settings::values.delay_game_render_thread_us); | ||||
| 
 | ||||
|     if (global) { | ||||
|         ReadBasicSetting(Settings::values.use_shader_jit); | ||||
|     } | ||||
|  | @ -1168,6 +1170,8 @@ void Config::SaveRendererValues() { | |||
|     WriteGlobalSetting(Settings::values.texture_filter); | ||||
|     WriteGlobalSetting(Settings::values.texture_sampling); | ||||
| 
 | ||||
|     WriteGlobalSetting(Settings::values.delay_game_render_thread_us); | ||||
| 
 | ||||
|     if (global) { | ||||
|         WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit.GetValue(), | ||||
|                      true); | ||||
|  |  | |||
|  | @ -26,6 +26,10 @@ ConfigureGraphics::ConfigureGraphics(QString gl_renderer, std::span<const QStrin | |||
|     // Set the index to -1 to ensure the below lambda is called with setCurrentIndex
 | ||||
|     ui->graphics_api_combo->setCurrentIndex(-1); | ||||
| 
 | ||||
|     const auto width = static_cast<int>(QString::fromStdString("000000000").size() * 6); | ||||
|     ui->delay_render_display_label->setMinimumWidth(width); | ||||
|     ui->delay_render_combo->setVisible(!Settings::IsConfiguringGlobal()); | ||||
| 
 | ||||
|     auto graphics_api_combo_model = | ||||
|         qobject_cast<QStandardItemModel*>(ui->graphics_api_combo->model()); | ||||
| #ifndef ENABLE_SOFTWARE_RENDERER | ||||
|  | @ -82,12 +86,25 @@ ConfigureGraphics::ConfigureGraphics(QString gl_renderer, std::span<const QStrin | |||
|     connect(ui->graphics_api_combo, qOverload<int>(&QComboBox::currentIndexChanged), this, | ||||
|             &ConfigureGraphics::SetPhysicalDeviceComboVisibility); | ||||
| 
 | ||||
|     connect(ui->delay_render_slider, &QSlider::valueChanged, this, [&](int value) { | ||||
|         ui->delay_render_display_label->setText( | ||||
|             QStringLiteral("%1 ms") | ||||
|                 .arg(((double)value) / 1000.f, 0, 'f', 3) | ||||
|                 .rightJustified(QString::fromStdString("000000000").size())); | ||||
|     }); | ||||
| 
 | ||||
|     SetConfiguration(); | ||||
| } | ||||
| 
 | ||||
| ConfigureGraphics::~ConfigureGraphics() = default; | ||||
| 
 | ||||
| void ConfigureGraphics::SetConfiguration() { | ||||
|     ui->delay_render_slider->setValue(Settings::values.delay_game_render_thread_us.GetValue()); | ||||
|     ui->delay_render_display_label->setText( | ||||
|         QStringLiteral("%1 ms") | ||||
|             .arg(((double)ui->delay_render_slider->value()) / 1000, 0, 'f', 3) | ||||
|             .rightJustified(QString::fromStdString("000000000").size())); | ||||
| 
 | ||||
|     if (!Settings::IsConfiguringGlobal()) { | ||||
|         ConfigurationShared::SetHighlight(ui->graphics_api_group, | ||||
|                                           !Settings::values.graphics_api.UsingGlobal()); | ||||
|  | @ -101,6 +118,16 @@ void ConfigureGraphics::SetConfiguration() { | |||
|                                                &Settings::values.texture_sampling); | ||||
|         ConfigurationShared::SetHighlight(ui->widget_texture_sampling, | ||||
|                                           !Settings::values.texture_sampling.UsingGlobal()); | ||||
|         ConfigurationShared::SetHighlight( | ||||
|             ui->delay_render_layout, !Settings::values.delay_game_render_thread_us.UsingGlobal()); | ||||
| 
 | ||||
|         if (Settings::values.delay_game_render_thread_us.UsingGlobal()) { | ||||
|             ui->delay_render_combo->setCurrentIndex(0); | ||||
|             ui->delay_render_slider->setEnabled(false); | ||||
|         } else { | ||||
|             ui->delay_render_combo->setCurrentIndex(1); | ||||
|             ui->delay_render_slider->setEnabled(true); | ||||
|         } | ||||
|     } else { | ||||
|         ui->graphics_api_combo->setCurrentIndex( | ||||
|             static_cast<int>(Settings::values.graphics_api.GetValue())); | ||||
|  | @ -144,6 +171,9 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
|                                              ui->toggle_disk_shader_cache, use_disk_shader_cache); | ||||
|     ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync_new, ui->toggle_vsync_new, | ||||
|                                              use_vsync_new); | ||||
|     ConfigurationShared::ApplyPerGameSetting( | ||||
|         &Settings::values.delay_game_render_thread_us, ui->delay_render_combo, | ||||
|         [this](s32) { return ui->delay_render_slider->value(); }); | ||||
| 
 | ||||
|     if (Settings::IsConfiguringGlobal()) { | ||||
|         Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); | ||||
|  | @ -170,9 +200,16 @@ void ConfigureGraphics::SetupPerGameUI() { | |||
|         ui->toggle_async_present->setEnabled(Settings::values.async_presentation.UsingGlobal()); | ||||
|         ui->graphics_api_combo->setEnabled(Settings::values.graphics_api.UsingGlobal()); | ||||
|         ui->physical_device_combo->setEnabled(Settings::values.physical_device.UsingGlobal()); | ||||
|         ui->delay_render_combo->setEnabled( | ||||
|             Settings::values.delay_game_render_thread_us.UsingGlobal()); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     connect(ui->delay_render_combo, qOverload<int>(&QComboBox::activated), this, [this](int index) { | ||||
|         ui->delay_render_slider->setEnabled(index == 1); | ||||
|         ConfigurationShared::SetHighlight(ui->delay_render_layout, index == 1); | ||||
|     }); | ||||
| 
 | ||||
|     ui->toggle_shader_jit->setVisible(false); | ||||
| 
 | ||||
|     ConfigurationShared::SetColoredComboBox( | ||||
|  |  | |||
|  | @ -307,6 +307,83 @@ | |||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|         <widget class="QWidget" name="delay_render_layout" native="true"> | ||||
|           <layout class="QHBoxLayout" name="delay_render_layout_inner"> | ||||
|             <property name="leftMargin"> | ||||
|               <number>0</number> | ||||
|             </property> | ||||
|             <property name="topMargin"> | ||||
|               <number>0</number> | ||||
|             </property> | ||||
|             <property name="rightMargin"> | ||||
|               <number>0</number> | ||||
|             </property> | ||||
|             <property name="bottomMargin"> | ||||
|               <number>0</number> | ||||
|             </property> | ||||
|             <item> | ||||
|               <widget class="QComboBox" name="delay_render_combo"> | ||||
|                 <item> | ||||
|                   <property name="text"> | ||||
|                     <string>Use global</string> | ||||
|                   </property> | ||||
|                 </item> | ||||
|                 <item> | ||||
|                   <property name="text"> | ||||
|                     <string>Use per-game</string> | ||||
|                   </property> | ||||
|                 </item> | ||||
|               </widget> | ||||
|             </item> | ||||
|             <item> | ||||
|               <widget class="QLabel" name="label_delay_render"> | ||||
|                 <property name="text"> | ||||
|                   <string>Delay game render thread:</string> | ||||
|                 </property> | ||||
|                 <property name="toolTip"> | ||||
|                   <string><html><head/><body><p>Delays the emulated game render thread the specified amount of milliseconds every time it submits render commands to the GPU.</p><p>Adjust this feature in the (very few) dynamic-fps games to fix performance issues.</p></body></html></string> | ||||
|                 </property> | ||||
|               </widget> | ||||
|             </item> | ||||
|             <item> | ||||
|               <widget class="QSlider" name="delay_render_slider"> | ||||
|                 <property name="minimum"> | ||||
|                   <number>0</number> | ||||
|                 </property> | ||||
|                 <property name="maximum"> | ||||
|                   <number>16000</number> | ||||
|                 </property> | ||||
|                 <property name="singleStep"> | ||||
|                   <number>100</number> | ||||
|                 </property> | ||||
|                 <property name="pageStep"> | ||||
|                   <number>250</number> | ||||
|                 </property> | ||||
|                 <property name="value"> | ||||
|                   <number>0</number> | ||||
|                 </property> | ||||
|                 <property name="orientation"> | ||||
|                   <enum>Qt::Horizontal</enum> | ||||
|                 </property> | ||||
|                 <property name="tickPosition"> | ||||
|                   <enum>QSlider::TicksBelow</enum> | ||||
|                 </property> | ||||
|               </widget> | ||||
|             </item> | ||||
|             <item> | ||||
|               <widget class="QLabel" name="delay_render_display_label"> | ||||
|                 <property name="text"> | ||||
|                   <string/> | ||||
|                 </property> | ||||
|                 <property name="alignment"> | ||||
|                   <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||||
|                 </property> | ||||
|               </widget> | ||||
|             </item> | ||||
|           </layout> | ||||
|         </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue