From 8fe8cad8f91201a58a87067153197a298a75222e Mon Sep 17 00:00:00 2001 From: Akash Date: Thu, 24 Aug 2017 00:25:42 +0530 Subject: [PATCH] GSdx-D3D11: Avoid undefined behavior in swapchain PCSX2 sends a negative value (-1) to GSdx when adaptive mode is specified for Vsync, this mode is exclusive to OpenGL at the moment and is unimplemented on the D3D11 renderer. Also the present function of swapchain only accepts values from 0 to 4 as parameter, hence passing negative values to the function is undefined behavior. So let's fallback to standard synchronization method on D3D11 when PCSX2 requests for adaptive mode. --- plugins/GSdx/GSDevice11.cpp | 5 +++++ plugins/GSdx/GSDevice11.h | 1 + 2 files changed, 6 insertions(+) diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index 90e25aa002..c992a39b81 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -432,6 +432,11 @@ void GSDevice11::SetExclusive(bool isExcl) } } +void GSDevice11::SetVSync(int vsync) +{ + m_vsync = vsync ? 1 : 0; +} + void GSDevice11::Flip() { m_swapchain->Present(m_vsync, 0); diff --git a/plugins/GSdx/GSDevice11.h b/plugins/GSdx/GSDevice11.h index 3257bb6446..edf27ec367 100644 --- a/plugins/GSdx/GSDevice11.h +++ b/plugins/GSdx/GSDevice11.h @@ -170,6 +170,7 @@ public: bool Create(const std::shared_ptr &wnd); bool Reset(int w, int h); void Flip(); + void SetVSync(int vsync) final; void SetExclusive(bool isExcl);