1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-23 09:19:41 +01:00

[wsi] Change interface for surface creation

This temporarily breaks Win32 swap chains, but we're fine with that
since this will take some refactoring.
This commit is contained in:
Philip Rebohle 2022-10-27 19:36:12 +02:00
parent bd87e19de1
commit 1754b73ade
4 changed files with 20 additions and 10 deletions

View File

@ -410,7 +410,8 @@ namespace dxvk::vk {
VkResult Presenter::createSurface() {
VkResult status = wsi::createSurface(m_window, m_vki, &m_surface);
/* TODO fix */
VkResult status = wsi::createSurface(m_window, nullptr, m_vki->instance(), &m_surface);
if (status != VK_SUCCESS)
return status;

View File

@ -143,12 +143,13 @@ namespace dxvk::wsi {
VkResult createSurface(
HWND hWindow,
const Rc<vk::InstanceFn>& vki,
VkSurfaceKHR* pSurface) {
HWND hWindow,
PFN_vkGetInstanceProcAddr pfnVkGetInstanceProcAddr,
VkInstance instance,
VkSurfaceKHR* pSurface) {
SDL_Window* window = fromHwnd(hWindow);
return SDL_Vulkan_CreateSurface(window, vki->instance(), pSurface)
return SDL_Vulkan_CreateSurface(window, instance, pSurface)
? VK_SUCCESS
: VK_ERROR_OUT_OF_HOST_MEMORY;
}

View File

@ -276,17 +276,23 @@ namespace dxvk::wsi {
VkResult createSurface(
HWND hWindow,
const Rc<vk::InstanceFn>& vki,
PFN_vkGetInstanceProcAddr pfnVkGetInstanceProcAddr,
VkInstance instance,
VkSurfaceKHR* pSurface) {
HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(
GetWindowLongPtr(hWindow, GWLP_HINSTANCE));
auto pfnVkCreateWin32SurfaceKHR = reinterpret_cast<PFN_vkCreateWin32SurfaceKHR>(
pfnVkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR"));
if (!pfnVkCreateWin32SurfaceKHR)
return VK_ERROR_FEATURE_NOT_PRESENT;
VkWin32SurfaceCreateInfoKHR info = { VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR };
info.hinstance = hInstance;
info.hwnd = hWindow;
return vki->vkCreateWin32SurfaceKHR(
vki->instance(), &info, nullptr, pSurface);
return (*pfnVkCreateWin32SurfaceKHR)(instance, &info, nullptr, pSurface);
}
}

View File

@ -115,12 +115,14 @@ namespace dxvk::wsi {
* \brief Create a surface for a window
*
* \param [in] hWindow The window
* \param [in] vki The instance
* \param [in] pfnVkGetInstanceProcAddr \c vkGetInstanceProcAddr pointer
* \param [in] instance Vulkan instance
* \param [out] pSurface The surface
*/
VkResult createSurface(
HWND hWindow,
const Rc<vk::InstanceFn>& vki,
PFN_vkGetInstanceProcAddr pfnVkGetInstanceProcAddr,
VkInstance instance,
VkSurfaceKHR* pSurface);
}