mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 19:25:46 -04:00
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:
@ -241,7 +241,8 @@ void D3D11HostDisplay::SetVSync(bool enabled)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device)
|
||||
bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
|
||||
bool threaded_presentation)
|
||||
{
|
||||
#ifndef LIBRETRO
|
||||
UINT create_flags = 0;
|
||||
@ -352,7 +353,8 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
|
||||
return true;
|
||||
}
|
||||
|
||||
bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device)
|
||||
bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
|
||||
bool threaded_presentation)
|
||||
{
|
||||
#ifndef LIBRETRO
|
||||
if (m_window_info.type != WindowInfo::Type::Surfaceless && m_window_info.type != WindowInfo::Type::Libretro &&
|
||||
|
@ -35,8 +35,8 @@ public:
|
||||
virtual bool HasRenderDevice() const override;
|
||||
virtual bool HasRenderSurface() const override;
|
||||
|
||||
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device) override;
|
||||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool threaded_presentation) override;
|
||||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool threaded_presentation) override;
|
||||
virtual void DestroyRenderDevice() override;
|
||||
|
||||
virtual bool MakeRenderContextCurrent() override;
|
||||
|
@ -318,7 +318,8 @@ bool OpenGLHostDisplay::HasRenderSurface() const
|
||||
return m_window_info.type != WindowInfo::Type::Surfaceless;
|
||||
}
|
||||
|
||||
bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device)
|
||||
bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
|
||||
bool threaded_presentation)
|
||||
{
|
||||
m_gl_context = GL::Context::Create(wi);
|
||||
if (!m_gl_context)
|
||||
@ -333,7 +334,8 @@ bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device)
|
||||
bool OpenGLHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
|
||||
bool threaded_presentation)
|
||||
{
|
||||
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast<GLint*>(&m_uniform_buffer_alignment));
|
||||
|
||||
|
@ -35,8 +35,8 @@ public:
|
||||
virtual bool HasRenderDevice() const override;
|
||||
virtual bool HasRenderSurface() const override;
|
||||
|
||||
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device) override;
|
||||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool threaded_presentation) override;
|
||||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool threaded_presentation) override;
|
||||
virtual void DestroyRenderDevice() override;
|
||||
|
||||
virtual bool MakeRenderContextCurrent() override;
|
||||
|
@ -192,6 +192,7 @@ bool VulkanHostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, fl
|
||||
void VulkanHostDisplay::DestroyRenderSurface()
|
||||
{
|
||||
m_window_info = {};
|
||||
g_vulkan_context->WaitForGPUIdle();
|
||||
m_swap_chain.reset();
|
||||
}
|
||||
|
||||
@ -310,9 +311,10 @@ void VulkanHostDisplay::SetVSync(bool enabled)
|
||||
m_swap_chain->SetVSync(enabled);
|
||||
}
|
||||
|
||||
bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device)
|
||||
bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
|
||||
bool threaded_presentation)
|
||||
{
|
||||
if (!Vulkan::Context::Create(adapter_name, &wi, &m_swap_chain, debug_device, false))
|
||||
if (!Vulkan::Context::Create(adapter_name, &wi, &m_swap_chain, threaded_presentation, debug_device, false))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create Vulkan context");
|
||||
return false;
|
||||
@ -328,7 +330,7 @@ bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device)
|
||||
bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool threaded_presentation)
|
||||
{
|
||||
Vulkan::ShaderCache::Create(shader_cache_directory, debug_device);
|
||||
|
||||
@ -648,7 +650,7 @@ bool VulkanHostDisplay::Render()
|
||||
|
||||
g_vulkan_context->SubmitCommandBuffer(m_swap_chain->GetImageAvailableSemaphore(),
|
||||
m_swap_chain->GetRenderingFinishedSemaphore(), m_swap_chain->GetSwapChain(),
|
||||
m_swap_chain->GetCurrentImageIndex());
|
||||
m_swap_chain->GetCurrentImageIndex(), !m_swap_chain->IsVSyncEnabled());
|
||||
g_vulkan_context->MoveToNextCommandBuffer();
|
||||
|
||||
#ifdef WITH_IMGUI
|
||||
|
@ -32,8 +32,10 @@ public:
|
||||
virtual bool HasRenderDevice() const override;
|
||||
virtual bool HasRenderSurface() const override;
|
||||
|
||||
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device) override;
|
||||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device) override;
|
||||
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
|
||||
bool threaded_presentation) override;
|
||||
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
|
||||
bool threaded_presentation) override;
|
||||
virtual void DestroyRenderDevice() override;
|
||||
|
||||
virtual bool MakeRenderContextCurrent() override;
|
||||
|
Reference in New Issue
Block a user