From 1bdbef487bc09c9bf350b5c801d4ec7e00e204cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 11 Aug 2023 00:31:47 +0200 Subject: [PATCH 1/3] D3D11: Pass the swapchain pointer into the thin3d context --- Common/GPU/D3D11/thin3d_d3d11.cpp | 10 ++++++---- Common/GPU/thin3d_create.h | 4 ++-- UWP/PPSSPP_UWPMain.cpp | 2 +- Windows/GPU/D3D11Context.cpp | 9 +++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index ec5fcb44fa..1a15af2674 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -62,7 +62,7 @@ public: class D3D11DrawContext : public DrawContext { public: - D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector deviceList, int maxInflightFrames); + D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, IDXGISwapChain *swapChain, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector deviceList, int maxInflightFrames); ~D3D11DrawContext(); const DeviceCaps &GetDeviceCaps() const override { @@ -185,6 +185,7 @@ private: ID3D11Device1 *device1_; ID3D11DeviceContext *context_; ID3D11DeviceContext1 *context1_; + IDXGISwapChain *swapChain_; ID3D11Texture2D *bbRenderTargetTex_ = nullptr; // NOT OWNED ID3D11RenderTargetView *bbRenderTargetView_ = nullptr; @@ -245,13 +246,14 @@ private: std::vector deviceList_; }; -D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector deviceList, int maxInflightFrames) +D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, IDXGISwapChain *swapChain, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector deviceList, int maxInflightFrames) : hWnd_(hWnd), device_(device), context_(deviceContext1), device1_(device1), context1_(deviceContext1), featureLevel_(featureLevel), + swapChain_(swapChain), deviceList_(deviceList) { // We no longer support Windows Phone. @@ -1869,8 +1871,8 @@ void D3D11DrawContext::GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h } } -DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector adapterNames, int maxInflightFrames) { - return new D3D11DrawContext(device, context, device1, context1, featureLevel, hWnd, adapterNames, maxInflightFrames); +DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, IDXGISwapChain *swapChain, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector adapterNames, int maxInflightFrames) { + return new D3D11DrawContext(device, context, device1, context1, swapChain, featureLevel, hWnd, adapterNames, maxInflightFrames); } } // namespace Draw diff --git a/Common/GPU/thin3d_create.h b/Common/GPU/thin3d_create.h index 7fdd833971..fa56ebbb09 100644 --- a/Common/GPU/thin3d_create.h +++ b/Common/GPU/thin3d_create.h @@ -17,7 +17,7 @@ struct ID3D11Device; struct ID3D11DeviceContext; struct ID3D11Device1; struct ID3D11DeviceContext1; - +struct IDXGISwapChain; #endif class VulkanContext; @@ -28,7 +28,7 @@ DrawContext *T3DCreateGLContext(); #ifdef _WIN32 DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx); -DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector adapterNames, int maxInflightFrames); +DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, IDXGISwapChain *swapChain, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector adapterNames, int maxInflightFrames); #endif DrawContext *T3DCreateVulkanContext(VulkanContext *context, bool useRenderThread); diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 5bf8854a31..eab8c2ab7f 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -316,7 +316,7 @@ UWPGraphicsContext::UWPGraphicsContext(std::shared_ptr reso std::vector adapterNames; draw_ = Draw::T3DCreateD3D11Context( - resources->GetD3DDevice(), resources->GetD3DDeviceContext(), resources->GetD3DDevice(), resources->GetD3DDeviceContext(), resources->GetDeviceFeatureLevel(), 0, adapterNames, g_Config.iInflightFrames); + resources->GetD3DDevice(), resources->GetD3DDeviceContext(), resources->GetD3DDevice(), resources->GetD3DDeviceContext(), resources->GetSwapChain(), resources->GetDeviceFeatureLevel(), 0, adapterNames, g_Config.iInflightFrames); bool success = draw_->CreatePresets(); _assert_(success); } diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index fe485925bb..0a2c5565ac 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -158,10 +158,6 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { } #endif - draw_ = Draw::T3DCreateD3D11Context(device_, context_, device1_, context1_, featureLevel_, hWnd_, adapterNames, g_Config.iInflightFrames); - SetGPUBackend(GPUBackend::DIRECT3D11, chosenAdapterName); - bool success = draw_->CreatePresets(); // If we can run D3D11, there's a compiler installed. I think. - _assert_msg_(success, "Failed to compile preset shaders"); int width; int height; @@ -202,6 +198,11 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) { dxgiFactory->MakeWindowAssociation(hWnd_, DXGI_MWA_NO_ALT_ENTER); dxgiFactory->Release(); + draw_ = Draw::T3DCreateD3D11Context(device_, context_, device1_, context1_, swapChain_, featureLevel_, hWnd_, adapterNames, g_Config.iInflightFrames); + SetGPUBackend(GPUBackend::DIRECT3D11, chosenAdapterName); + bool success = draw_->CreatePresets(); // If we can run D3D11, there's a compiler installed. I think. + _assert_msg_(success, "Failed to compile preset shaders"); + GotBackbuffer(); return true; } From ed9b033f7d250020e5b432eede83803e6f8584dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 11 Aug 2023 00:47:56 +0200 Subject: [PATCH 2/3] D3D9/11: Move away from using context->SwapBuffers(), instead move present to draw_->Present(). --- Common/GPU/D3D11/thin3d_d3d11.cpp | 12 +++++------- Common/GPU/D3D9/thin3d_d3d9.cpp | 13 +++++++++++-- Common/GPU/OpenGL/thin3d_gl.cpp | 4 ++-- Common/GPU/Vulkan/thin3d_vulkan.cpp | 5 +++-- Common/GPU/thin3d.h | 2 +- UI/NativeApp.cpp | 2 +- UWP/App.cpp | 5 ++--- UWP/PPSSPP_UWPMain.cpp | 6 ------ UWP/PPSSPP_UWPMain.h | 6 +++--- Windows/GPU/D3D11Context.cpp | 5 ----- Windows/GPU/D3D11Context.h | 2 +- Windows/GPU/D3D9Context.cpp | 12 ------------ Windows/GPU/D3D9Context.h | 2 +- 13 files changed, 30 insertions(+), 46 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 1a15af2674..133fa9cfa4 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -139,7 +139,7 @@ public: void BeginFrame(DebugFlags debugFlags) override; void EndFrame() override; - void Present() override; + void Present(int vblanks) override; int GetFrameCount() override { return frameCount_; } @@ -426,11 +426,6 @@ void D3D11DrawContext::HandleEvent(Event ev, int width, int height, void *param1 curRTHeight_ = height; break; } - case Event::PRESENTED: - // Make sure that we don't eliminate the next time the render target is set. - curRenderTargetView_ = nullptr; - curDepthStencilView_ = nullptr; - break; } } @@ -438,7 +433,10 @@ void D3D11DrawContext::EndFrame() { curPipeline_ = nullptr; } -void D3D11DrawContext::Present() { +void D3D11DrawContext::Present(int vblanks) { + swapChain_->Present(1, 0); + curRenderTargetView_ = nullptr; + curDepthStencilView_ = nullptr; frameCount_++; } diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 84ce9da268..a23f4220fa 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -580,7 +580,7 @@ public: } void EndFrame() override; - void Present() override; + void Present(int vblanks) override; int GetFrameCount() override { return frameCount_; } @@ -970,7 +970,16 @@ void D3D9Context::EndFrame() { curPipeline_ = nullptr; } -void D3D9Context::Present() { +void D3D9Context::Present(int vblanks) { + if (deviceEx_) { + deviceEx_->EndScene(); + deviceEx_->PresentEx(NULL, NULL, NULL, NULL, 0); + deviceEx_->BeginScene(); + } else { + device_->EndScene(); + device_->Present(NULL, NULL, NULL, NULL); + device_->BeginScene(); + } frameCount_++; } diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 124a5c0583..1e261be7a0 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -366,7 +366,7 @@ public: void BeginFrame(DebugFlags debugFlags) override; void EndFrame() override; - void Present() override; + void Present(int vblanks) override; int GetFrameCount() override { return frameCount_; @@ -802,7 +802,7 @@ void OpenGLContext::EndFrame() { Invalidate(InvalidationFlags::CACHED_RENDER_STATE); } -void OpenGLContext::Present() { +void OpenGLContext::Present(int vblanks) { renderManager_.Present(); frameCount_++; } diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index e4a37eb82e..ad3a74880d 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -480,7 +480,7 @@ public: void BeginFrame(DebugFlags debugFlags) override; void EndFrame() override; - void Present() override; + void Present(int vblanks) override; void WipeQueue() override; @@ -1121,7 +1121,8 @@ void VKContext::EndFrame() { Invalidate(InvalidationFlags::CACHED_RENDER_STATE); } -void VKContext::Present() { +void VKContext::Present(int vblanks) { + _dbg_assert_(vblanks == 0 || vblanks == 1); renderManager_.Present(); frameCount_++; } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index e58b6072ce..c90d8ed93d 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -815,7 +815,7 @@ public: // Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here. virtual void BeginFrame(DebugFlags debugFlags) {} virtual void EndFrame() = 0; - virtual void Present() = 0; + virtual void Present(int vblanks) = 0; // NOTE: Not all backends support vblanks > 1. virtual void WipeQueue() {} diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 9fe58fa44a..7c7c89db98 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1157,7 +1157,7 @@ void NativeFrame(GraphicsContext *graphicsContext) { ClearFailedGPUBackends(); } - g_draw->Present(); + g_draw->Present(1); if (resized) { INFO_LOG(G3D, "Resized flag set - recalculating bounds"); diff --git a/UWP/App.cpp b/UWP/App.cpp index 0d5459845e..9c07b544bc 100644 --- a/UWP/App.cpp +++ b/UWP/App.cpp @@ -198,9 +198,8 @@ void App::Run() { while (!m_windowClosed) { if (m_windowVisible) { CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - if (m_main->Render()) { - m_deviceResources->Present(); - } + m_main->Render(); + // TODO: Adopt some practices from m_deviceResources->Present(); } else { CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); } diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index eab8c2ab7f..91fa56553a 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -164,8 +164,6 @@ void PPSSPP_UWPMain::CreateWindowSizeDependentResources() { // Renders the current frame according to the current application state. // Returns true if the frame was rendered and is ready to be displayed. bool PPSSPP_UWPMain::Render() { - ctx_->GetDrawContext()->HandleEvent(Draw::Event::PRESENTED, 0, 0, nullptr, nullptr); - static bool hasSetThreadName = false; if (!hasSetThreadName) { SetCurrentThreadName("UWPRenderThread"); @@ -325,10 +323,6 @@ void UWPGraphicsContext::Shutdown() { delete draw_; } -void UWPGraphicsContext::SwapInterval(int interval) { - -} - std::string System_GetProperty(SystemProperty prop) { static bool hasCheckedGPUDriverVersion = false; switch (prop) { diff --git a/UWP/PPSSPP_UWPMain.h b/UWP/PPSSPP_UWPMain.h index 3be7b25ce4..0d51f1bbf1 100644 --- a/UWP/PPSSPP_UWPMain.h +++ b/UWP/PPSSPP_UWPMain.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include @@ -19,7 +19,7 @@ public: UWPGraphicsContext(std::shared_ptr resources); void Shutdown() override; - void SwapInterval(int interval) override; + void SwapInterval(int interval) override {} void SwapBuffers() override {} void Resize() override {} Draw::DrawContext * GetDrawContext() override { @@ -70,4 +70,4 @@ private: std::unique_ptr ctx_; }; -} \ No newline at end of file +} diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 0a2c5565ac..4173f9a6ac 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -33,11 +33,6 @@ #error This file should not be compiled for UWP. #endif -void D3D11Context::SwapBuffers() { - swapChain_->Present(swapInterval_, 0); - draw_->HandleEvent(Draw::Event::PRESENTED, 0, 0, nullptr, nullptr); -} - void D3D11Context::SwapInterval(int interval) { swapInterval_ = interval; } diff --git a/Windows/GPU/D3D11Context.h b/Windows/GPU/D3D11Context.h index f2f03b2756..b7d2baf20e 100644 --- a/Windows/GPU/D3D11Context.h +++ b/Windows/GPU/D3D11Context.h @@ -31,7 +31,7 @@ public: bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override; void Shutdown() override; void SwapInterval(int interval) override; - void SwapBuffers() override; + void SwapBuffers() override {} void Resize() override; diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp index faf5568561..776ed26fc0 100644 --- a/Windows/GPU/D3D9Context.cpp +++ b/Windows/GPU/D3D9Context.cpp @@ -21,18 +21,6 @@ #include "Common/GPU/thin3d_create.h" #include "Common/GPU/D3D9/D3DCompilerLoader.h" -void D3D9Context::SwapBuffers() { - if (has9Ex_) { - deviceEx_->EndScene(); - deviceEx_->PresentEx(NULL, NULL, NULL, NULL, 0); - deviceEx_->BeginScene(); - } else { - device_->EndScene(); - device_->Present(NULL, NULL, NULL, NULL); - device_->BeginScene(); - } -} - typedef HRESULT (__stdcall *DIRECT3DCREATE9EX)(UINT, IDirect3D9Ex**); void D3D9Context::SwapInterval(int interval) { diff --git a/Windows/GPU/D3D9Context.h b/Windows/GPU/D3D9Context.h index 9ad836d338..b916ace945 100644 --- a/Windows/GPU/D3D9Context.h +++ b/Windows/GPU/D3D9Context.h @@ -35,7 +35,7 @@ public: bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override; void Shutdown() override; void SwapInterval(int interval) override; - void SwapBuffers() override; + void SwapBuffers() override {} void Resize() override; From 1ea11c233c113a65a53ef4103c8fed8ba3f936f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 11 Aug 2023 00:58:24 +0200 Subject: [PATCH 3/3] Remove "SwapBuffers" from the GraphicsContext interface. Buildfixes More buildfix headless buildfix One more buildfix --- Common/GraphicsContext.h | 2 -- Core/Core.cpp | 4 ---- Qt/QtMain.h | 1 - SDL/SDLGLGraphicsContext.h | 4 ---- SDL/SDLMain.cpp | 2 -- SDL/SDLVulkanGraphicsContext.h | 4 ---- UWP/PPSSPP_UWPMain.h | 1 - Windows/GPU/D3D11Context.h | 1 - Windows/GPU/D3D9Context.h | 1 - Windows/GPU/WindowsGLContext.cpp | 2 +- Windows/GPU/WindowsGLContext.h | 3 ++- Windows/GPU/WindowsGraphicsContext.h | 1 - Windows/GPU/WindowsVulkanContext.h | 1 - android/jni/AndroidJavaGLContext.h | 1 - android/jni/AndroidVulkanContext.h | 1 - headless/SDLHeadlessHost.cpp | 3 --- headless/WindowsHeadlessHost.cpp | 2 -- ios/ViewController.mm | 1 - libretro/LibretroGraphicsContext.h | 1 + libretro/libretro.cpp | 2 +- 20 files changed, 5 insertions(+), 33 deletions(-) diff --git a/Common/GraphicsContext.h b/Common/GraphicsContext.h index 873722764c..73ebf18a7b 100644 --- a/Common/GraphicsContext.h +++ b/Common/GraphicsContext.h @@ -16,8 +16,6 @@ public: virtual void Shutdown() = 0; virtual void SwapInterval(int interval) = 0; - virtual void SwapBuffers() = 0; - // Used during window resize. Must be called from the window thread, // not the rendering thread or CPU thread. virtual void Pause() {} diff --git a/Core/Core.cpp b/Core/Core.cpp index 60064b176c..4abed1a004 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -227,10 +227,6 @@ void Core_RunLoop(GraphicsContext *ctx) { if (sleepTime > 0) sleep_ms(sleepTime); } - - if ((!windowHidden && !Core_IsStepping()) || menuThrottle) { - ctx->SwapBuffers(); - } } void Core_DoSingleStep() { diff --git a/Qt/QtMain.h b/Qt/QtMain.h index 39cce11f77..d1cf6c7d40 100644 --- a/Qt/QtMain.h +++ b/Qt/QtMain.h @@ -70,7 +70,6 @@ public: // See TODO in constructor. // renderManager_->SwapInterval(interval); } - void SwapBuffers() override {} void Resize() override {} Draw::DrawContext *GetDrawContext() override { diff --git a/SDL/SDLGLGraphicsContext.h b/SDL/SDLGLGraphicsContext.h index 95d627deda..b71b99349a 100644 --- a/SDL/SDLGLGraphicsContext.h +++ b/SDL/SDLGLGraphicsContext.h @@ -19,10 +19,6 @@ public: void Shutdown() override; void ShutdownFromRenderThread() override; - void SwapBuffers() override { - // Do nothing, the render thread takes care of this. - } - // Gets forwarded to the render thread. void SwapInterval(int interval) override; diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 64f7ecec08..86bd191316 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -1452,8 +1452,6 @@ int main(int argc, char *argv[]) { break; } - graphicsContext->SwapBuffers(); - { std::lock_guard guard(g_mutexWindow); if (g_windowState.update) { diff --git a/SDL/SDLVulkanGraphicsContext.h b/SDL/SDLVulkanGraphicsContext.h index d309e685d5..1fe5b0c94f 100644 --- a/SDL/SDLVulkanGraphicsContext.h +++ b/SDL/SDLVulkanGraphicsContext.h @@ -26,10 +26,6 @@ public: void Shutdown() override; - void SwapBuffers() override { - // We don't do it this way. - } - void Resize() override; void Poll() override; diff --git a/UWP/PPSSPP_UWPMain.h b/UWP/PPSSPP_UWPMain.h index 0d51f1bbf1..e2cc2edefc 100644 --- a/UWP/PPSSPP_UWPMain.h +++ b/UWP/PPSSPP_UWPMain.h @@ -20,7 +20,6 @@ public: void Shutdown() override; void SwapInterval(int interval) override {} - void SwapBuffers() override {} void Resize() override {} Draw::DrawContext * GetDrawContext() override { return draw_; diff --git a/Windows/GPU/D3D11Context.h b/Windows/GPU/D3D11Context.h index b7d2baf20e..3d40355899 100644 --- a/Windows/GPU/D3D11Context.h +++ b/Windows/GPU/D3D11Context.h @@ -31,7 +31,6 @@ public: bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override; void Shutdown() override; void SwapInterval(int interval) override; - void SwapBuffers() override {} void Resize() override; diff --git a/Windows/GPU/D3D9Context.h b/Windows/GPU/D3D9Context.h index b916ace945..8f1806bf44 100644 --- a/Windows/GPU/D3D9Context.h +++ b/Windows/GPU/D3D9Context.h @@ -35,7 +35,6 @@ public: bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override; void Shutdown() override; void SwapInterval(int interval) override; - void SwapBuffers() override {} void Resize() override; diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 42e65df116..7aa965967c 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -39,7 +39,7 @@ // Currently, just compile time for debugging. May be NVIDIA only. static const int simulateGLES = false; -void WindowsGLContext::SwapBuffers() { +void WindowsGLContext::Poll() { // We no longer call RenderManager::Swap here, it's handled by the render thread, which // we're not on here. diff --git a/Windows/GPU/WindowsGLContext.h b/Windows/GPU/WindowsGLContext.h index 2909be60f1..eac76176c3 100644 --- a/Windows/GPU/WindowsGLContext.h +++ b/Windows/GPU/WindowsGLContext.h @@ -18,7 +18,8 @@ public: void Shutdown() override; void SwapInterval(int interval) override; - void SwapBuffers() override; + + void Poll() override; // Used during window resize. Must be called from the window thread, // not the rendering thread or CPU thread. diff --git a/Windows/GPU/WindowsGraphicsContext.h b/Windows/GPU/WindowsGraphicsContext.h index db022e9b5d..41efb96a2f 100644 --- a/Windows/GPU/WindowsGraphicsContext.h +++ b/Windows/GPU/WindowsGraphicsContext.h @@ -7,4 +7,3 @@ class WindowsGraphicsContext : public GraphicsContext { public: virtual bool Init(HINSTANCE hInst, HWND window, std::string *error_message) = 0; }; - diff --git a/Windows/GPU/WindowsVulkanContext.h b/Windows/GPU/WindowsVulkanContext.h index 49e6613e3e..c331ec1dbb 100644 --- a/Windows/GPU/WindowsVulkanContext.h +++ b/Windows/GPU/WindowsVulkanContext.h @@ -30,7 +30,6 @@ public: bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override; void Shutdown() override; void SwapInterval(int interval) override {} - void SwapBuffers() override {} void Resize() override; void Poll() override; diff --git a/android/jni/AndroidJavaGLContext.h b/android/jni/AndroidJavaGLContext.h index 4b4ff95d14..d02ffcfac1 100644 --- a/android/jni/AndroidJavaGLContext.h +++ b/android/jni/AndroidJavaGLContext.h @@ -15,7 +15,6 @@ public: void ShutdownFromRenderThread() override; void Shutdown() override {} - void SwapBuffers() override {} void SwapInterval(int interval) override {} void Resize() override {} diff --git a/android/jni/AndroidVulkanContext.h b/android/jni/AndroidVulkanContext.h index f938643353..69d302bdea 100644 --- a/android/jni/AndroidVulkanContext.h +++ b/android/jni/AndroidVulkanContext.h @@ -16,7 +16,6 @@ public: void Shutdown() override; void SwapInterval(int interval) override; - void SwapBuffers() override {} void Resize() override; void *GetAPIContext() override { return g_Vulkan; } diff --git a/headless/SDLHeadlessHost.cpp b/headless/SDLHeadlessHost.cpp index 7333e46460..c4cfbc616b 100644 --- a/headless/SDLHeadlessHost.cpp +++ b/headless/SDLHeadlessHost.cpp @@ -96,7 +96,6 @@ public: void Shutdown() override {} void Resize() override {} void SwapInterval(int interval) override {} - void SwapBuffers() override {} private: Draw::DrawContext *draw_ = nullptr; @@ -193,7 +192,6 @@ bool SDLHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext * if (!gfx_->ThreadFrame()) { break; } - gfx_->SwapBuffers(); } threadState_ = RenderThreadState::STOPPING; @@ -221,7 +219,6 @@ void SDLHeadlessHost::ShutdownGraphics() { } void SDLHeadlessHost::SwapBuffers() { - gfx_->SwapBuffers(); } #endif diff --git a/headless/WindowsHeadlessHost.cpp b/headless/WindowsHeadlessHost.cpp index 3aef27028a..a4da9eed64 100644 --- a/headless/WindowsHeadlessHost.cpp +++ b/headless/WindowsHeadlessHost.cpp @@ -132,7 +132,6 @@ bool WindowsHeadlessHost::InitGraphics(std::string *error_message, GraphicsConte if (!gfx_->ThreadFrame()) { break; } - gfx_->SwapBuffers(); } threadState_ = RenderThreadState::STOPPING; @@ -173,5 +172,4 @@ void WindowsHeadlessHost::SwapBuffers() { TranslateMessage(&msg); DispatchMessage(&msg); } - gfx_->SwapBuffers(); } diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 97fd315037..89eff3a67b 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -64,7 +64,6 @@ public: } void SwapInterval(int interval) override {} - void SwapBuffers() override {} void Resize() override {} void Shutdown() override {} diff --git a/libretro/LibretroGraphicsContext.h b/libretro/LibretroGraphicsContext.h index ee15e5a1ac..dbb4f3b051 100644 --- a/libretro/LibretroGraphicsContext.h +++ b/libretro/LibretroGraphicsContext.h @@ -22,6 +22,7 @@ public: DestroyDrawContext(); } void SwapInterval(int interval) override {} + virtual void SwapBuffers() = 0; void Resize() override {} virtual void GotBackbuffer(); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index fb29d8c77d..707418c62d 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -1174,7 +1174,7 @@ namespace Libretro if (ctx->GetDrawContext()) { ctx->GetDrawContext()->EndFrame(); - ctx->GetDrawContext()->Present(); + ctx->GetDrawContext()->Present(1); } }