mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 22:00:05 +00:00 
			
		
		
		
	Prepare frontend for multiple graphics APIs (#6347)
* externals: Update dynarmic * settings: Introduce GraphicsAPI enum * For now it's OpenGL only but will be expanded upon later * citra_qt: Introduce backend agnostic context management * Mostly a direct port from yuzu * core: Simplify context acquire * settings: Add option to create debug contexts * renderer_opengl: Abstract initialization to Driver * This commit also updates glad and adds some useful extensions which we will use in part 2 * Rasterizer construction is moved to the specific renderer instead of RendererBase. Software rendering has been disable to achieve this but will be brought back in the next commit. * video_core: Remove Init/Shutdown methods from renderer * The constructor and destructor can do the same job * In addition move opengl function loading to Qt since SDL already does this. Also remove ErrorVideoCore which is never reached * citra_qt: Decouple software renderer from opengl part 1 * citra: Decouple software renderer from opengl part 2 * android: Decouple software renderer from opengl part 3 * swrasterizer: Decouple software renderer from opengl part 4 * This commit simply enforces the renderer naming conventions in the software renderer * video_core: Move RendererBase to VideoCore * video_core: De-globalize screenshot state * video_core: Pass system to the renderers * video_core: Commonize shader uniform data * video_core: Abstract backend agnostic rasterizer operations * bootmanager: Remove references to OpenGL for macOS OpenGL macOS headers definitions clash heavily with each other * citra_qt: Proper title for api settings * video_core: Reduce boost usage * bootmanager: Fix hide mouse option Remove event handlers from RenderWidget for events that are already handled by the parent GRenderWindow. Also enable mouse tracking on the RenderWidget. * android: Remove software from graphics api list * code: Address review comments * citra: Port per-game settings read * Having to update the default value for all backends is a pain so lets centralize it * android: Rename to OpenGLES --------- Co-authored-by: MerryMage <MerryMage@users.noreply.github.com> Co-authored-by: Vitor Kiguchi <vitor-kiguchi@hotmail.com>
This commit is contained in:
		
							parent
							
								
									9ef42040af
								
							
						
					
					
						commit
						b5d6f645bd
					
				
					 99 changed files with 3165 additions and 4501 deletions
				
			
		|  | @ -482,6 +482,7 @@ void Config::ReadDebuggingValues() { | |||
|         qt_config->value(QStringLiteral("record_frame_times"), false).toBool(); | ||||
|     ReadBasicSetting(Settings::values.use_gdbstub); | ||||
|     ReadBasicSetting(Settings::values.gdbstub_port); | ||||
|     ReadBasicSetting(Settings::values.renderer_debug); | ||||
| 
 | ||||
|     qt_config->beginGroup(QStringLiteral("LLE")); | ||||
|     for (const auto& service_module : Service::service_module_map) { | ||||
|  | @ -625,7 +626,7 @@ void Config::ReadPathValues() { | |||
| void Config::ReadRendererValues() { | ||||
|     qt_config->beginGroup(QStringLiteral("Renderer")); | ||||
| 
 | ||||
|     ReadGlobalSetting(Settings::values.use_hw_renderer); | ||||
|     ReadGlobalSetting(Settings::values.graphics_api); | ||||
|     ReadGlobalSetting(Settings::values.use_hw_shader); | ||||
| #ifdef __APPLE__ | ||||
|     // Hardware shader is broken on macos with Intel GPUs thanks to poor drivers.
 | ||||
|  | @ -992,6 +993,7 @@ void Config::SaveDebuggingValues() { | |||
|     qt_config->setValue(QStringLiteral("record_frame_times"), Settings::values.record_frame_times); | ||||
|     WriteBasicSetting(Settings::values.use_gdbstub); | ||||
|     WriteBasicSetting(Settings::values.gdbstub_port); | ||||
|     WriteBasicSetting(Settings::values.renderer_debug); | ||||
| 
 | ||||
|     qt_config->beginGroup(QStringLiteral("LLE")); | ||||
|     for (const auto& service_module : Settings::values.lle_modules) { | ||||
|  | @ -1103,7 +1105,7 @@ void Config::SavePathValues() { | |||
| void Config::SaveRendererValues() { | ||||
|     qt_config->beginGroup(QStringLiteral("Renderer")); | ||||
| 
 | ||||
|     WriteGlobalSetting(Settings::values.use_hw_renderer); | ||||
|     WriteGlobalSetting(Settings::values.graphics_api); | ||||
|     WriteGlobalSetting(Settings::values.use_hw_shader); | ||||
| #ifdef __APPLE__ | ||||
|     // Hardware shader is broken on macos thanks to poor drivers.
 | ||||
|  |  | |||
|  | @ -83,6 +83,21 @@ template <> | |||
| void SetPerGameSetting(QComboBox* combobox, | ||||
|                        const Settings::SwitchableSetting<std::string>* setting); | ||||
| 
 | ||||
| /// Given an index of a combobox setting extracts the setting taking into
 | ||||
| /// account per-game status
 | ||||
| template <typename Type, bool ranged> | ||||
| Type GetComboboxSetting(int index, const Settings::SwitchableSetting<Type, ranged>* setting) { | ||||
|     if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { | ||||
|         return static_cast<Type>(index); | ||||
|     } else if (!Settings::IsConfiguringGlobal()) { | ||||
|         if (index == 0) { | ||||
|             return setting->GetValue(); | ||||
|         } else { | ||||
|             return static_cast<Type>(index - ConfigurationShared::USE_GLOBAL_OFFSET); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Given a Qt widget sets the background color to indicate whether the setting
 | ||||
| /// is per-game overriden (highlighted) or global (non-highlighted)
 | ||||
| void SetHighlight(QWidget* widget, bool highlighted); | ||||
|  |  | |||
|  | @ -37,6 +37,7 @@ ConfigureDebug::ConfigureDebug(QWidget* parent) | |||
| 
 | ||||
|     const bool is_powered_on = Core::System::GetInstance().IsPoweredOn(); | ||||
|     ui->toggle_cpu_jit->setEnabled(!is_powered_on); | ||||
|     ui->toggle_renderer_debug->setEnabled(!is_powered_on); | ||||
| 
 | ||||
|     // Set a minimum width for the label to prevent the slider from changing size.
 | ||||
|     // This scales across DPIs. (This value should be enough for "xxx%")
 | ||||
|  | @ -62,6 +63,7 @@ void ConfigureDebug::SetConfiguration() { | |||
|     ui->toggle_console->setChecked(UISettings::values.show_console.GetValue()); | ||||
|     ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue())); | ||||
|     ui->toggle_cpu_jit->setChecked(Settings::values.use_cpu_jit.GetValue()); | ||||
|     ui->toggle_renderer_debug->setChecked(Settings::values.renderer_debug.GetValue()); | ||||
| 
 | ||||
|     if (!Settings::IsConfiguringGlobal()) { | ||||
|         if (Settings::values.cpu_clock_percentage.UsingGlobal()) { | ||||
|  | @ -91,6 +93,7 @@ void ConfigureDebug::ApplyConfiguration() { | |||
|     filter.ParseFilterString(Settings::values.log_filter.GetValue()); | ||||
|     Log::SetGlobalFilter(filter); | ||||
|     Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked(); | ||||
|     Settings::values.renderer_debug = ui->toggle_renderer_debug->isChecked(); | ||||
| 
 | ||||
|     ConfigurationShared::ApplyPerGameSetting( | ||||
|         &Settings::values.cpu_clock_percentage, ui->clock_speed_combo, | ||||
|  |  | |||
|  | @ -23,5 +23,6 @@ public: | |||
|     void SetConfiguration(); | ||||
|     void SetupPerGameUI(); | ||||
| 
 | ||||
| private: | ||||
|     std::unique_ptr<Ui::ConfigureDebug> ui; | ||||
| }; | ||||
|  |  | |||
|  | @ -6,8 +6,8 @@ | |||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>443</width> | ||||
|     <height>358</height> | ||||
|     <width>523</width> | ||||
|     <height>447</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|  | @ -112,12 +112,34 @@ | |||
|       <string>CPU</string> | ||||
|      </property> | ||||
|      <layout class="QGridLayout" name="gridLayout_2"> | ||||
|       <item row="2" column="0"> | ||||
|        <widget class="QCheckBox" name="toggle_cpu_jit"> | ||||
|         <property name="toolTip"> | ||||
|          <string><html><head/><body><p>Enables the use of the ARM JIT compiler for emulating the 3DS CPUs. Don't disable unless for debugging purposes</p></body></html></string> | ||||
|         </property> | ||||
|         <property name="text"> | ||||
|          <string>Enable CPU JIT</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item row="1" column="0"> | ||||
|        <widget class="QWidget" name="clock_speed_widget" native="true"> | ||||
|         <layout class="QHBoxLayout" name="clock_speed_layout"> | ||||
|          <property name="spacing"> | ||||
|           <number>7</number> | ||||
|          </property> | ||||
|          <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="clock_speed_combo"> | ||||
|            <item> | ||||
|  | @ -180,13 +202,10 @@ | |||
|         </layout> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item row="2" column="0"> | ||||
|        <widget class="QCheckBox" name="toggle_cpu_jit"> | ||||
|         <property name="toolTip"> | ||||
|          <string><html><head/><body><p>Enables the use of the ARM JIT compiler for emulating the 3DS CPUs. Don't disable unless for debugging purposes</p></body></html></string> | ||||
|         </property> | ||||
|       <item row="3" column="0"> | ||||
|        <widget class="QCheckBox" name="toggle_renderer_debug"> | ||||
|         <property name="text"> | ||||
|          <string>Enable CPU JIT</string> | ||||
|          <string>Enable debug renderer</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|  |  | |||
|  | @ -22,7 +22,9 @@ ConfigureEnhancements::ConfigureEnhancements(QWidget* parent) | |||
| 
 | ||||
|     ui->layout_group->setEnabled(!Settings::values.custom_layout); | ||||
| 
 | ||||
|     ui->resolution_factor_combobox->setEnabled(Settings::values.use_hw_renderer.GetValue()); | ||||
|     const auto graphics_api = Settings::values.graphics_api.GetValue(); | ||||
|     const bool res_scale_enabled = graphics_api != Settings::GraphicsAPI::Software; | ||||
|     ui->resolution_factor_combobox->setEnabled(res_scale_enabled); | ||||
| 
 | ||||
|     connect(ui->render_3d_combobox, | ||||
|             static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, | ||||
|  |  | |||
|  | @ -16,22 +16,20 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) | |||
|     : QWidget(parent), ui(std::make_unique<Ui::ConfigureGraphics>()) { | ||||
|     ui->setupUi(this); | ||||
| 
 | ||||
|     SetupPerGameUI(); | ||||
|     SetConfiguration(); | ||||
| 
 | ||||
|     ui->hw_renderer_group->setEnabled(ui->hw_renderer_group->isEnabled() && | ||||
|                                       ui->toggle_hw_renderer->isChecked()); | ||||
|     ui->toggle_vsync_new->setEnabled(!Core::System::GetInstance().IsPoweredOn()); | ||||
|     // Set the index to -1 to ensure the below lambda is called with setCurrentIndex
 | ||||
|     ui->graphics_api_combo->setCurrentIndex(-1); | ||||
| 
 | ||||
|     connect(ui->toggle_hw_renderer, &QCheckBox::toggled, this, [this] { | ||||
|         const bool checked = ui->toggle_hw_renderer->isChecked(); | ||||
|         ui->hw_renderer_group->setEnabled(checked); | ||||
|         ui->toggle_disk_shader_cache->setEnabled(checked && ui->toggle_hw_shader->isChecked()); | ||||
|     }); | ||||
|     connect(ui->graphics_api_combo, qOverload<int>(&QComboBox::currentIndexChanged), this, | ||||
|             [this](int index) { | ||||
|                 const auto graphics_api = | ||||
|                     ConfigurationShared::GetComboboxSetting(index, &Settings::values.graphics_api); | ||||
|                 const bool is_software = graphics_api == Settings::GraphicsAPI::Software; | ||||
| 
 | ||||
|     ui->hw_shader_group->setEnabled(ui->toggle_hw_shader->isChecked()); | ||||
|     ui->toggle_disk_shader_cache->setEnabled(ui->toggle_hw_renderer->isChecked() && | ||||
|                                              ui->toggle_hw_shader->isChecked()); | ||||
|                 ui->hw_renderer_group->setEnabled(!is_software); | ||||
|                 ui->toggle_disk_shader_cache->setEnabled(!is_software && | ||||
|                                                          ui->toggle_hw_shader->isChecked()); | ||||
|             }); | ||||
| 
 | ||||
|     connect(ui->toggle_hw_shader, &QCheckBox::toggled, this, [this] { | ||||
|         const bool checked = ui->toggle_hw_shader->isChecked(); | ||||
|  | @ -60,12 +58,24 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) | |||
|     // TODO(B3N30): Hide this for macs with none Intel GPUs, too.
 | ||||
|     ui->toggle_separable_shader->setVisible(false); | ||||
| #endif | ||||
| 
 | ||||
|     SetupPerGameUI(); | ||||
|     SetConfiguration(); | ||||
| } | ||||
| 
 | ||||
| ConfigureGraphics::~ConfigureGraphics() = default; | ||||
| 
 | ||||
| void ConfigureGraphics::SetConfiguration() { | ||||
|     ui->toggle_hw_renderer->setChecked(Settings::values.use_hw_renderer.GetValue()); | ||||
|     if (!Settings::IsConfiguringGlobal()) { | ||||
|         ConfigurationShared::SetHighlight(ui->graphics_api_group, | ||||
|                                           !Settings::values.graphics_api.UsingGlobal()); | ||||
|         ConfigurationShared::SetPerGameSetting(ui->graphics_api_combo, | ||||
|                                                &Settings::values.graphics_api); | ||||
|     } else { | ||||
|         ui->graphics_api_combo->setCurrentIndex( | ||||
|             static_cast<int>(Settings::values.graphics_api.GetValue())); | ||||
|     } | ||||
| 
 | ||||
|     ui->toggle_hw_shader->setChecked(Settings::values.use_hw_shader.GetValue()); | ||||
|     ui->toggle_separable_shader->setChecked(Settings::values.separable_shader.GetValue()); | ||||
|     ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul.GetValue()); | ||||
|  | @ -78,8 +88,8 @@ void ConfigureGraphics::SetConfiguration() { | |||
| } | ||||
| 
 | ||||
| void ConfigureGraphics::ApplyConfiguration() { | ||||
|     ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_hw_renderer, | ||||
|                                              ui->toggle_hw_renderer, use_hw_renderer); | ||||
|     ConfigurationShared::ApplyPerGameSetting(&Settings::values.graphics_api, | ||||
|                                              ui->graphics_api_combo); | ||||
|     ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_hw_shader, ui->toggle_hw_shader, | ||||
|                                              use_hw_shader); | ||||
|     ConfigurationShared::ApplyPerGameSetting(&Settings::values.separable_shader, | ||||
|  | @ -103,7 +113,7 @@ void ConfigureGraphics::RetranslateUI() { | |||
| void ConfigureGraphics::SetupPerGameUI() { | ||||
|     // Block the global settings if a game is currently running that overrides them
 | ||||
|     if (Settings::IsConfiguringGlobal()) { | ||||
|         ui->toggle_hw_renderer->setEnabled(Settings::values.use_hw_renderer.UsingGlobal()); | ||||
|         ui->graphics_api_group->setEnabled(Settings::values.graphics_api.UsingGlobal()); | ||||
|         ui->toggle_hw_shader->setEnabled(Settings::values.use_hw_shader.UsingGlobal()); | ||||
|         ui->toggle_separable_shader->setEnabled(Settings::values.separable_shader.UsingGlobal()); | ||||
|         ui->toggle_accurate_mul->setEnabled(Settings::values.shaders_accurate_mul.UsingGlobal()); | ||||
|  | @ -115,8 +125,10 @@ void ConfigureGraphics::SetupPerGameUI() { | |||
| 
 | ||||
|     ui->toggle_shader_jit->setVisible(false); | ||||
| 
 | ||||
|     ConfigurationShared::SetColoredTristate(ui->toggle_hw_renderer, | ||||
|                                             Settings::values.use_hw_renderer, use_hw_renderer); | ||||
|     ConfigurationShared::SetColoredComboBox( | ||||
|         ui->graphics_api_combo, ui->graphics_api_group, | ||||
|         static_cast<u32>(Settings::values.graphics_api.GetValue(true))); | ||||
| 
 | ||||
|     ConfigurationShared::SetColoredTristate(ui->toggle_hw_shader, Settings::values.use_hw_shader, | ||||
|                                             use_hw_shader); | ||||
|     ConfigurationShared::SetColoredTristate(ui->toggle_separable_shader, | ||||
|  |  | |||
|  | @ -28,9 +28,9 @@ public: | |||
| 
 | ||||
|     void UpdateBackgroundColorButton(const QColor& color); | ||||
| 
 | ||||
| private: | ||||
|     void SetupPerGameUI(); | ||||
| 
 | ||||
|     ConfigurationShared::CheckState use_hw_renderer; | ||||
|     ConfigurationShared::CheckState use_hw_shader; | ||||
|     ConfigurationShared::CheckState separable_shader; | ||||
|     ConfigurationShared::CheckState shaders_accurate_mul; | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ | |||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>400</width> | ||||
|     <height>430</height> | ||||
|     <height>443</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="minimumSize"> | ||||
|  | @ -20,27 +20,65 @@ | |||
|    <string>Form</string> | ||||
|   </property> | ||||
|   <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|    <item> | ||||
|     <widget class="QGroupBox" name="apiBox"> | ||||
|      <property name="title"> | ||||
|       <string>API Settings</string> | ||||
|      </property> | ||||
|      <layout class="QVBoxLayout" name="verticalLayout_3"> | ||||
|       <item> | ||||
|        <widget class="QWidget" name="graphics_api_group" native="true"> | ||||
|         <layout class="QHBoxLayout" name="graphics_api_group_2"> | ||||
|          <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="QLabel" name="graphics_api_label"> | ||||
|            <property name="text"> | ||||
|             <string>Graphics API</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QComboBox" name="graphics_api_combo"> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string>Software</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string>OpenGL</string> | ||||
|             </property> | ||||
|            </item> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QGroupBox" name="rendererBox"> | ||||
|      <property name="title"> | ||||
|       <string>Renderer</string> | ||||
|      </property> | ||||
|      <layout class="QVBoxLayout" name="verticalLayout_6"> | ||||
|       <item> | ||||
|        <widget class="QCheckBox" name="toggle_hw_renderer"> | ||||
|         <property name="toolTip"> | ||||
|          <string><html><head/><body><p>Use OpenGL to accelerate rendering.</p><p>Disable to debug graphics-related problem.</p></body></html></string> | ||||
|         </property> | ||||
|         <property name="text"> | ||||
|          <string>Enable Hardware Renderer</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QWidget" name="hw_renderer_group" native="true"> | ||||
|         <layout class="QVBoxLayout" name="verticalLayout_5"> | ||||
|          <property name="leftMargin"> | ||||
|           <number>16</number> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="topMargin"> | ||||
|           <number>0</number> | ||||
|  | @ -157,8 +195,6 @@ | |||
|   </layout> | ||||
|  </widget> | ||||
|  <tabstops> | ||||
|   <tabstop>toggle_hw_renderer</tabstop> | ||||
|   <tabstop>toggle_hw_shader</tabstop> | ||||
|   <tabstop>toggle_separable_shader</tabstop> | ||||
|   <tabstop>toggle_accurate_mul</tabstop> | ||||
|   <tabstop>toggle_shader_jit</tabstop> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue