mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
demos: Print the GPU and platform we're running on.
This commit is contained in:
Notes:
Henri Verbeet
2025-06-11 20:38:15 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1562
@@ -71,6 +71,7 @@ struct demo_swapchain
|
|||||||
{
|
{
|
||||||
IDXGISwapChain3 *swapchain;
|
IDXGISwapChain3 *swapchain;
|
||||||
unsigned int buffer_count;
|
unsigned int buffer_count;
|
||||||
|
char device_name[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void demo_cleanup(struct demo *demo)
|
static inline void demo_cleanup(struct demo *demo)
|
||||||
@@ -98,6 +99,11 @@ static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
|||||||
demo_win32_get_dpi(demo, dpi_x, dpi_y);
|
demo_win32_get_dpi(demo, dpi_x, dpi_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const char *demo_get_platform_name(void)
|
||||||
|
{
|
||||||
|
return "Direct3D 12";
|
||||||
|
}
|
||||||
|
|
||||||
static inline void demo_process_events(struct demo *demo)
|
static inline void demo_process_events(struct demo *demo)
|
||||||
{
|
{
|
||||||
demo_win32_process_events(demo);
|
demo_win32_process_events(demo);
|
||||||
@@ -138,9 +144,14 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
|||||||
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
struct demo_window_win32 *window_win32 = CONTAINING_RECORD(window, struct demo_window_win32, w);
|
||||||
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
|
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
|
||||||
struct demo_swapchain *swapchain;
|
struct demo_swapchain *swapchain;
|
||||||
|
DXGI_ADAPTER_DESC adapter_desc;
|
||||||
IDXGISwapChain1 *swapchain1;
|
IDXGISwapChain1 *swapchain1;
|
||||||
IDXGIFactory2 *factory;
|
IDXGIFactory2 *factory;
|
||||||
|
IDXGIAdapter *adapter;
|
||||||
|
ID3D12Device *device;
|
||||||
|
unsigned int i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
LUID luid;
|
||||||
|
|
||||||
if (!(swapchain = malloc(sizeof(*swapchain))))
|
if (!(swapchain = malloc(sizeof(*swapchain))))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -148,6 +159,27 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
|||||||
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
|
if (FAILED(CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&factory)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
if (FAILED(ID3D12CommandQueue_GetDevice(command_queue, &IID_ID3D12Device, (void **)&device)))
|
||||||
|
goto fail;
|
||||||
|
luid = ID3D12Device_GetAdapterLuid(device);
|
||||||
|
ID3D12Device_Release(device);
|
||||||
|
|
||||||
|
sprintf(swapchain->device_name, "Unknown");
|
||||||
|
for (i = 0; IDXGIFactory2_EnumAdapters(factory, i, &adapter) == S_OK; ++i)
|
||||||
|
{
|
||||||
|
hr = IDXGIAdapter_GetDesc(adapter, &adapter_desc);
|
||||||
|
IDXGIAdapter_Release(adapter);
|
||||||
|
if (FAILED(hr))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (adapter_desc.AdapterLuid.LowPart == luid.LowPart
|
||||||
|
&& adapter_desc.AdapterLuid.HighPart == luid.HighPart)
|
||||||
|
{
|
||||||
|
snprintf(swapchain->device_name, ARRAY_SIZE(swapchain->device_name), "%ls", adapter_desc.Description);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
|
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
|
||||||
swapchain_desc.BufferCount = desc->buffer_count;
|
swapchain_desc.BufferCount = desc->buffer_count;
|
||||||
swapchain_desc.Width = desc->width;
|
swapchain_desc.Width = desc->width;
|
||||||
@@ -176,6 +208,11 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const char *demo_swapchain_get_device_name(struct demo_swapchain *swapchain)
|
||||||
|
{
|
||||||
|
return swapchain->device_name;
|
||||||
|
}
|
||||||
|
|
||||||
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
||||||
{
|
{
|
||||||
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
|
return IDXGISwapChain3_GetCurrentBackBufferIndex(swapchain->swapchain);
|
||||||
|
@@ -59,6 +59,7 @@ DECLARE_VK_PFN(vkCreateXcbSurfaceKHR)
|
|||||||
DECLARE_VK_PFN(vkDestroyFence)
|
DECLARE_VK_PFN(vkDestroyFence)
|
||||||
DECLARE_VK_PFN(vkDestroySurfaceKHR)
|
DECLARE_VK_PFN(vkDestroySurfaceKHR)
|
||||||
DECLARE_VK_PFN(vkDestroySwapchainKHR)
|
DECLARE_VK_PFN(vkDestroySwapchainKHR)
|
||||||
|
DECLARE_VK_PFN(vkGetPhysicalDeviceProperties)
|
||||||
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
||||||
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
||||||
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR)
|
DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR)
|
||||||
@@ -228,6 +229,7 @@ static void load_vulkan_procs(void)
|
|||||||
LOAD_VK_PFN(vkDestroyFence)
|
LOAD_VK_PFN(vkDestroyFence)
|
||||||
LOAD_VK_PFN(vkDestroySurfaceKHR)
|
LOAD_VK_PFN(vkDestroySurfaceKHR)
|
||||||
LOAD_VK_PFN(vkDestroySwapchainKHR)
|
LOAD_VK_PFN(vkDestroySwapchainKHR)
|
||||||
|
LOAD_VK_PFN(vkGetPhysicalDeviceProperties)
|
||||||
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
||||||
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
||||||
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR)
|
LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR)
|
||||||
@@ -239,6 +241,7 @@ static void load_vulkan_procs(void)
|
|||||||
|
|
||||||
struct demo_swapchain
|
struct demo_swapchain
|
||||||
{
|
{
|
||||||
|
VkPhysicalDeviceProperties vk_device_properties;
|
||||||
VkSurfaceKHR vk_surface;
|
VkSurfaceKHR vk_surface;
|
||||||
VkSwapchainKHR vk_swapchain;
|
VkSwapchainKHR vk_swapchain;
|
||||||
VkFence vk_fence;
|
VkFence vk_fence;
|
||||||
@@ -310,6 +313,11 @@ static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
|||||||
demo->get_dpi(demo, dpi_x, dpi_y);
|
demo->get_dpi(demo, dpi_x, dpi_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const char *demo_get_platform_name(void)
|
||||||
|
{
|
||||||
|
return "vkd3d";
|
||||||
|
}
|
||||||
|
|
||||||
static inline void demo_process_events(struct demo *demo)
|
static inline void demo_process_events(struct demo *demo)
|
||||||
{
|
{
|
||||||
demo->process_events(demo);
|
demo->process_events(demo);
|
||||||
@@ -475,6 +483,7 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
|||||||
free(vk_images);
|
free(vk_images);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
vkGetPhysicalDeviceProperties(vk_physical_device, &swapchain->vk_device_properties);
|
||||||
swapchain->vk_surface = vk_surface;
|
swapchain->vk_surface = vk_surface;
|
||||||
swapchain->vk_swapchain = vk_swapchain;
|
swapchain->vk_swapchain = vk_swapchain;
|
||||||
swapchain->vk_fence = vk_fence;
|
swapchain->vk_fence = vk_fence;
|
||||||
@@ -544,6 +553,11 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const char *demo_swapchain_get_device_name(struct demo_swapchain *swapchain)
|
||||||
|
{
|
||||||
|
return swapchain->vk_device_properties.deviceName;
|
||||||
|
}
|
||||||
|
|
||||||
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
static inline unsigned int demo_swapchain_get_current_back_buffer_index(struct demo_swapchain *swapchain)
|
||||||
{
|
{
|
||||||
return swapchain->current_buffer;
|
return swapchain->current_buffer;
|
||||||
|
@@ -891,6 +891,8 @@ static int cxg_main(void)
|
|||||||
cxg_populate_command_list(&cxg, i);
|
cxg_populate_command_list(&cxg, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("vkd3d-gears: Running on \"%s\" using %s.\n",
|
||||||
|
demo_swapchain_get_device_name(cxg.swapchain), demo_get_platform_name());
|
||||||
demo_process_events(&cxg.demo);
|
demo_process_events(&cxg.demo);
|
||||||
|
|
||||||
cxg_wait_for_previous_frame(&cxg);
|
cxg_wait_for_previous_frame(&cxg);
|
||||||
|
@@ -400,6 +400,8 @@ static int cxt_main(void)
|
|||||||
cxt_load_pipeline(&cxt);
|
cxt_load_pipeline(&cxt);
|
||||||
cxt_load_assets(&cxt);
|
cxt_load_assets(&cxt);
|
||||||
|
|
||||||
|
printf("vkd3d-triangle: Running on \"%s\" using %s.\n",
|
||||||
|
demo_swapchain_get_device_name(cxt.swapchain), demo_get_platform_name());
|
||||||
demo_process_events(&cxt.demo);
|
demo_process_events(&cxt.demo);
|
||||||
|
|
||||||
cxt_wait_for_previous_frame(&cxt);
|
cxt_wait_for_previous_frame(&cxt);
|
||||||
|
Reference in New Issue
Block a user