mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
Move platform-specific codepaths out into separate files
This commit is contained in:
@@ -154,25 +154,9 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device,
|
||||
void *wndptr = NULL;
|
||||
VkPlatformWSI platform = VK_PLATFORM_MAX_ENUM_WSI;
|
||||
|
||||
#if defined(WIN32)
|
||||
static int dllLocator=0;
|
||||
VkSurfaceDescriptionWindowWSI surfDesc = { VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI };
|
||||
|
||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (const char *)&dllLocator, (HMODULE *)&handleptr);
|
||||
wndptr = wnd;
|
||||
platform = VK_PLATFORM_WIN32_WSI;
|
||||
#elif defined(__linux__)
|
||||
VkPlatformHandleXcbWSI handle;
|
||||
handle.connection = connection;
|
||||
handle.root = screen->root;
|
||||
|
||||
handleptr = &handle;
|
||||
wndptr = &wnd;
|
||||
platform = VK_PLATFORM_X11_WSI;
|
||||
#else
|
||||
#error "unknown platform"
|
||||
#endif
|
||||
|
||||
VkSurfaceDescriptionWindowWSI surfDesc = { VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI, NULL, platform, handleptr, wndptr };
|
||||
InitSurfaceDescription(surfDesc);
|
||||
|
||||
// VKTODOHIGH need to verify which present modes are present
|
||||
VkSwapChainCreateInfoWSI swapInfo = {
|
||||
@@ -1807,18 +1791,14 @@ void VulkanReplay::SetProxyBufferData(ResourceId bufid, byte *data, size_t dataS
|
||||
|
||||
const VulkanFunctions &GetRealVKFunctions();
|
||||
|
||||
// in vk_replay_platform.cpp
|
||||
bool LoadVulkanLibrary();
|
||||
|
||||
ReplayCreateStatus Vulkan_CreateReplayDevice(const char *logfile, IReplayDriver **driver)
|
||||
{
|
||||
RDCDEBUG("Creating a VulkanReplay replay device");
|
||||
|
||||
#if defined(WIN32)
|
||||
bool loaded = Process::LoadModule("vulkan.0.dll");
|
||||
#elif defined(__linux__)
|
||||
bool loaded = Process::LoadModule("libvulkan.so");
|
||||
#else
|
||||
#error "Unknown platform"
|
||||
#endif
|
||||
if(!loaded)
|
||||
if(!LoadVulkanLibrary())
|
||||
{
|
||||
RDCERR("Failed to load vulkan library");
|
||||
return eReplayCreate_APIInitFailed;
|
||||
|
||||
@@ -166,6 +166,8 @@ class VulkanReplay : public IReplayDriver
|
||||
void Create(WrappedVulkan *driver, VkDevice device, bool depth);
|
||||
void Destroy(WrappedVulkan *driver, VkDevice device);
|
||||
|
||||
// implemented in vk_replay_platform.cpp
|
||||
void InitSurfaceDescription(VkSurfaceDescriptionWindowWSI &surfDesc);
|
||||
void SetWindowHandle(void *wn);
|
||||
|
||||
WINDOW_HANDLE_DECL
|
||||
|
||||
@@ -39,6 +39,17 @@ void VulkanReplay::OutputWindow::SetWindowHandle(void *wn)
|
||||
screen = iter.data;
|
||||
}
|
||||
|
||||
void VulkanReplay::OutputWindow::InitSurfaceDescription(VkSurfaceDescriptionWindowWSI &surfDesc)
|
||||
{
|
||||
static VkPlatformHandleXcbWSI handle;
|
||||
handle.connection = connection;
|
||||
handle.root = screen->root;
|
||||
|
||||
surfDesc.pPlatformWindow = &handle;
|
||||
surfDesc.pPlatformWindow = &wnd;
|
||||
surfDesc.platform = VK_PLATFORM_X11_WSI;
|
||||
}
|
||||
|
||||
void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h)
|
||||
{
|
||||
if(id == 0 || m_OutputWindows.find(id) == m_OutputWindows.end())
|
||||
@@ -64,3 +75,8 @@ bool VulkanReplay::IsOutputWindowVisible(uint64_t id)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadVulkanLibrary()
|
||||
{
|
||||
return Process::LoadModule("libvulkan.so");
|
||||
}
|
||||
|
||||
@@ -24,11 +24,22 @@
|
||||
|
||||
#include "vk_replay.h"
|
||||
|
||||
static int dllLocator=0;
|
||||
|
||||
void VulkanReplay::OutputWindow::SetWindowHandle(void *wn)
|
||||
{
|
||||
wnd = (HWND)wn;
|
||||
}
|
||||
|
||||
void VulkanReplay::OutputWindow::InitSurfaceDescription(VkSurfaceDescriptionWindowWSI &surfDesc)
|
||||
{
|
||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
(const char *)&dllLocator, (HMODULE *)&surfDesc.pPlatformHandle);
|
||||
|
||||
surfDesc.pPlatformWindow = wnd;
|
||||
surfDesc.platform = VK_PLATFORM_WIN32_WSI;
|
||||
}
|
||||
|
||||
void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h)
|
||||
{
|
||||
if(id == 0 || m_OutputWindows.find(id) == m_OutputWindows.end())
|
||||
@@ -49,3 +60,8 @@ bool VulkanReplay::IsOutputWindowVisible(uint64_t id)
|
||||
|
||||
return (IsWindowVisible(m_OutputWindows[id].wnd) == TRUE);
|
||||
}
|
||||
|
||||
bool LoadVulkanLibrary()
|
||||
{
|
||||
return Process::LoadModule("vulkan.0.dll");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user