HostDisplay: Add threaded presentation for Vulkan renderer

Can add a significant speedup for fast forward. Automatically disabled
when vsync is enabled.
This commit is contained in:
Connor McLaughlin
2020-12-26 23:22:24 +10:00
parent 1a6a14fcd4
commit 702ed21207
29 changed files with 241 additions and 76 deletions

View File

@ -81,13 +81,15 @@ bool LibretroHostDisplay::HasRenderSurface() const
return true;
}
bool LibretroHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device)
bool LibretroHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
bool threaded_presentation)
{
m_window_info = wi;
return true;
}
bool LibretroHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device)
bool LibretroHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation)
{
return true;
}

View File

@ -15,8 +15,10 @@ public:
bool HasRenderDevice() const override;
bool HasRenderSurface() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device) override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
bool threaded_presentation) override;
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
bool MakeRenderContextCurrent() override;

View File

@ -1297,8 +1297,8 @@ void LibretroHostInterface::SwitchToHardwareRenderer()
Log_ErrorPrintf("Unhandled renderer '%s'", Settings::GetRendererName(renderer.value()));
return;
}
if (!display || !display->CreateRenderDevice(wi, {}, g_settings.gpu_use_debug_device) ||
!display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device))
if (!display || !display->CreateRenderDevice(wi, {}, g_settings.gpu_use_debug_device, false) ||
!display->InitializeRenderDevice(GetShaderCacheBasePath(), g_settings.gpu_use_debug_device, false))
{
Log_ErrorPrintf("Failed to create hardware host display");
return;

View File

@ -98,7 +98,7 @@ bool LibretroOpenGLHostDisplay::RequestHardwareRendererContext(retro_hw_render_c
}
bool LibretroOpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name,
bool debug_device)
bool debug_device, bool threaded_presentation)
{
Assert(wi.type == WindowInfo::Type::Libretro);

View File

@ -4,8 +4,8 @@
#include "core/host_display.h"
#include "frontend-common/opengl_host_display.h"
#include "libretro.h"
#include <string>
#include <memory>
#include <string>
class LibretroOpenGLHostDisplay final : public FrontendCommon::OpenGLHostDisplay
{
@ -17,7 +17,8 @@ public:
RenderAPI GetRenderAPI() const override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device) override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;

View File

@ -85,7 +85,7 @@ bool LibretroVulkanHostDisplay::RequestHardwareRendererContext(retro_hw_render_c
}
bool LibretroVulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name,
bool debug_device)
bool debug_device, bool threaded_presentation)
{
retro_hw_render_interface* ri = nullptr;
if (!g_retro_environment_callback(RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE, &ri))

View File

@ -14,7 +14,8 @@ public:
static bool RequestHardwareRendererContext(retro_hw_render_callback* cb);
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device) override;
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
bool threaded_presentation) override;
void DestroyRenderDevice() override;
void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;