mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
demos: Make the demos work in the Windows build.
Commit 02fe9f5bdf
introduced linking the
Windows build of the demos with d3d12 and dxgi, while also still linking
to libvkd3d-utils.la. That happens to more or less work on Wine; we get
vkd3d-utils' D3D12CreateDevice(), and Wine's
IDXGIFactory2_CreateSwapChainForHwnd(), but because Wine's
implementation of d3d12 swapchains uses vkd3d, we're able to use the
resulting swapchain buffers even though the instance of vkd3d used by
Wine may not be the same instance of vkd3d used by the demos. Perhaps
unsurprisingly, things don't go nearly as well on Windows.
We could of course stop linking the demos to vkd3d-utils on Windows, but
that's not that interesting; we're trying to show what vkd3d can do
here, not what d3d12 can do.
This commit is contained in:
Notes:
Henri Verbeet
2025-04-28 13:01:05 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1468
@@ -27,6 +27,25 @@ struct demo_window_win32
|
||||
HWND window;
|
||||
};
|
||||
|
||||
#ifndef VKD3D_CROSSTEST
|
||||
static VkSurfaceKHR demo_window_win32_create_vk_surface(struct demo_window *window, VkInstance vk_instance)
|
||||
{
|
||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||
struct VkWin32SurfaceCreateInfoKHR surface_desc;
|
||||
VkSurfaceKHR vk_surface;
|
||||
|
||||
surface_desc.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
surface_desc.pNext = NULL;
|
||||
surface_desc.flags = 0;
|
||||
surface_desc.hinstance = window_win32->instance;
|
||||
surface_desc.hwnd = window_win32->window;
|
||||
if (vkCreateWin32SurfaceKHR(vk_instance, &surface_desc, NULL, &vk_surface) < 0)
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
return vk_surface;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void demo_window_win32_destroy(struct demo_window *window)
|
||||
{
|
||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||
@@ -54,7 +73,12 @@ static struct demo_window *demo_window_win32_create(struct demo *demo, const cha
|
||||
if (!(window_win32 = malloc(sizeof(*window_win32))))
|
||||
return NULL;
|
||||
|
||||
#ifdef VKD3D_CROSSTEST
|
||||
if (!demo_window_init(&window_win32->w, demo, user_data))
|
||||
#else
|
||||
if (!demo_window_init(&window_win32->w, demo, user_data,
|
||||
demo_window_win32_create_vk_surface, demo_window_win32_destroy))
|
||||
#endif
|
||||
{
|
||||
free(window_win32);
|
||||
return NULL;
|
||||
@@ -89,7 +113,7 @@ static struct demo_window *demo_window_win32_create(struct demo *demo, const cha
|
||||
|
||||
static void demo_win32_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
||||
{
|
||||
struct demo_win32 *win32 = &demo->win32;
|
||||
struct demo_win32 *win32 = &demo->u.win32;
|
||||
|
||||
*dpi_x = *dpi_y = win32->GetDpiForSystem();
|
||||
}
|
||||
|
Reference in New Issue
Block a user