mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Reintroduce a vsync option for people with really bad drivers
This commit is contained in:
		
							parent
							
								
									65613cce81
								
							
						
					
					
						commit
						36c5058d66
					
				
					 8 changed files with 54 additions and 3 deletions
				
			
		|  | @ -123,6 +123,8 @@ void Config::ReadValues() { | |||
|     Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); | ||||
|     Settings::values.frame_limit = | ||||
|         static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); | ||||
|     Settings::values.use_vsync_new = | ||||
|         static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync_new", 1)); | ||||
| 
 | ||||
|     Settings::values.render_3d = static_cast<Settings::StereoRenderOption>( | ||||
|         sdl2_config->GetInteger("Renderer", "render_3d", 0)); | ||||
|  |  | |||
|  | @ -112,6 +112,11 @@ shaders_accurate_mul = | |||
| # 0: Interpreter (slow), 1 (default): JIT (fast) | ||||
| use_shader_jit = | ||||
| 
 | ||||
| # Forces VSync on the display thread. Usually doesn't impact performance, but on some drivers it can | ||||
| # so only turn this off if you notice a speed difference. | ||||
| # 0: Off, 1 (default): On | ||||
| use_vsync_new = | ||||
| 
 | ||||
| # Resolution scale factor | ||||
| # 0: Auto (scales resolution to window size), 1: Native 3DS screen resolution, Otherwise a scale | ||||
| # factor for the 3DS resolution | ||||
|  |  | |||
|  | @ -96,11 +96,22 @@ void EmuThread::run() { | |||
| OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context) | ||||
|     : QWindow(parent), event_handler(event_handler), | ||||
|       context(new QOpenGLContext(shared_context->parent())) { | ||||
| 
 | ||||
|     // disable vsync for any shared contexts
 | ||||
|     auto format = shared_context->format(); | ||||
|     format.setSwapInterval(Settings::values.use_vsync_new ? 1 : 0); | ||||
|     this->setFormat(format); | ||||
| 
 | ||||
|     context->setShareContext(shared_context); | ||||
|     context->setScreen(this->screen()); | ||||
|     context->setFormat(shared_context->format()); | ||||
|     context->setFormat(format); | ||||
|     context->create(); | ||||
| 
 | ||||
|     LOG_WARNING(Frontend, "OpenGLWindow context format Interval {}", | ||||
|                 context->format().swapInterval()); | ||||
| 
 | ||||
|     LOG_WARNING(Frontend, "OpenGLWindow surface format interval {}", this->format().swapInterval()); | ||||
| 
 | ||||
|     setSurfaceType(QWindow::OpenGLSurface); | ||||
| 
 | ||||
|     // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
 | ||||
|  | @ -409,10 +420,16 @@ std::unique_ptr<Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() | |||
| GLContext::GLContext(QOpenGLContext* shared_context) | ||||
|     : context(new QOpenGLContext(shared_context->parent())), | ||||
|       surface(new QOffscreenSurface(nullptr)) { | ||||
| 
 | ||||
|     // disable vsync for any shared contexts
 | ||||
|     auto format = shared_context->format(); | ||||
|     format.setSwapInterval(0); | ||||
| 
 | ||||
|     context->setShareContext(shared_context); | ||||
|     context->setFormat(format); | ||||
|     context->create(); | ||||
|     surface->setParent(shared_context->parent()); | ||||
|     surface->setFormat(shared_context->format()); | ||||
|     surface->setFormat(format); | ||||
|     surface->create(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -428,6 +428,7 @@ void Config::ReadRendererValues() { | |||
|     Settings::values.shaders_accurate_mul = | ||||
|         ReadSetting(QStringLiteral("shaders_accurate_mul"), false).toBool(); | ||||
|     Settings::values.use_shader_jit = ReadSetting(QStringLiteral("use_shader_jit"), true).toBool(); | ||||
|     Settings::values.use_vsync_new = ReadSetting(QStringLiteral("use_vsync_new"), true).toBool(); | ||||
|     Settings::values.resolution_factor = | ||||
|         static_cast<u16>(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt()); | ||||
|     Settings::values.use_frame_limit = | ||||
|  | @ -855,6 +856,7 @@ void Config::SaveRendererValues() { | |||
|     WriteSetting(QStringLiteral("shaders_accurate_mul"), Settings::values.shaders_accurate_mul, | ||||
|                  false); | ||||
|     WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit, true); | ||||
|     WriteSetting(QStringLiteral("use_vsync_new"), Settings::values.use_vsync_new, true); | ||||
|     WriteSetting(QStringLiteral("resolution_factor"), Settings::values.resolution_factor, 1); | ||||
|     WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); | ||||
|     WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); | ||||
|  |  | |||
|  | @ -18,6 +18,8 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) | |||
|     SetConfiguration(); | ||||
| 
 | ||||
|     ui->hw_renderer_group->setEnabled(ui->toggle_hw_renderer->isChecked()); | ||||
|     ui->toggle_vsync_new->setEnabled(!Core::System::GetInstance().IsPoweredOn()); | ||||
| 
 | ||||
|     connect(ui->toggle_hw_renderer, &QCheckBox::toggled, this, [this] { | ||||
|         auto checked = ui->toggle_hw_renderer->isChecked(); | ||||
|         ui->hw_renderer_group->setEnabled(checked); | ||||
|  | @ -46,6 +48,7 @@ void ConfigureGraphics::SetConfiguration() { | |||
|     ui->toggle_hw_shader->setChecked(Settings::values.use_hw_shader); | ||||
|     ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul); | ||||
|     ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); | ||||
|     ui->toggle_vsync_new->setChecked(Settings::values.use_vsync_new); | ||||
| } | ||||
| 
 | ||||
| void ConfigureGraphics::ApplyConfiguration() { | ||||
|  | @ -53,6 +56,7 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
|     Settings::values.use_hw_shader = ui->toggle_hw_shader->isChecked(); | ||||
|     Settings::values.shaders_accurate_mul = ui->toggle_accurate_mul->isChecked(); | ||||
|     Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); | ||||
|     Settings::values.use_vsync_new = ui->toggle_vsync_new->isChecked(); | ||||
| } | ||||
| 
 | ||||
| void ConfigureGraphics::RetranslateUI() { | ||||
|  |  | |||
|  | @ -105,6 +105,25 @@ | |||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QGroupBox" name="groupBox"> | ||||
|      <property name="title"> | ||||
|       <string>Advanced</string> | ||||
|      </property> | ||||
|      <layout class="QVBoxLayout" name="verticalLayout_2"> | ||||
|       <item> | ||||
|        <widget class="QCheckBox" name="toggle_vsync_new"> | ||||
|         <property name="toolTip"> | ||||
|          <string>VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference.</string> | ||||
|         </property> | ||||
|         <property name="text"> | ||||
|          <string>Enable VSync</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <spacer name="verticalSpacer"> | ||||
|      <property name="orientation"> | ||||
|  |  | |||
|  | @ -2075,7 +2075,7 @@ int main(int argc, char* argv[]) { | |||
|     QSurfaceFormat format; | ||||
|     format.setVersion(3, 3); | ||||
|     format.setProfile(QSurfaceFormat::CoreProfile); | ||||
|     format.setSwapInterval(1); | ||||
|     format.setSwapInterval(0); | ||||
|     // TODO: expose a setting for buffer value (ie default/single/double/triple)
 | ||||
|     format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior); | ||||
|     QSurfaceFormat::setDefaultFormat(format); | ||||
|  |  | |||
|  | @ -173,6 +173,8 @@ struct Values { | |||
|     bool custom_textures; | ||||
|     bool preload_textures; | ||||
| 
 | ||||
|     bool use_vsync_new; | ||||
| 
 | ||||
|     // Audio
 | ||||
|     bool enable_dsp_lle; | ||||
|     bool enable_dsp_lle_multithread; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue