Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 +- demos/demo_xcb.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index e760a66b8..3e113dc7c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -322,7 +322,7 @@ endif EXTRA_DIST += $(vkd3d_shader_tests)
if BUILD_DEMOS -DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @DEMO_LIBS@ @VULKAN_LIBS@ +DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @DL_LIBS@ @DEMO_LIBS@ DEMOS_CFLAGS = $(AM_CFLAGS) @DEMO_CFLAGS@ bin_PROGRAMS += $(vkd3d_demos)
diff --git a/demos/demo_xcb.h b/demos/demo_xcb.h index d8be00f03..bb43d8a48 100644 --- a/demos/demo_xcb.h +++ b/demos/demo_xcb.h @@ -17,18 +17,65 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define VK_NO_PROTOTYPES #define VK_USE_PLATFORM_XCB_KHR #define VKD3D_UTILS_API_VERSION VKD3D_API_VERSION_1_3 +#include "config.h" #include <vkd3d.h> #include <vkd3d_utils.h> #include <xcb/xcb_event.h> #include <xcb/xcb_icccm.h> #include <xcb/xcb_keysyms.h> #include <sys/stat.h> +#include <dlfcn.h> #include <limits.h> #include <unistd.h> #include <fcntl.h> #include <stdbool.h> +#include <stdio.h> + +#define DECLARE_VK_PFN(name) PFN_##name name; +DECLARE_VK_PFN(vkAcquireNextImageKHR) +DECLARE_VK_PFN(vkCreateFence) +DECLARE_VK_PFN(vkCreateSwapchainKHR) +DECLARE_VK_PFN(vkCreateXcbSurfaceKHR) +DECLARE_VK_PFN(vkDestroyFence) +DECLARE_VK_PFN(vkDestroySurfaceKHR) +DECLARE_VK_PFN(vkDestroySwapchainKHR) +DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) +DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR) +DECLARE_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR) +DECLARE_VK_PFN(vkGetSwapchainImagesKHR) +DECLARE_VK_PFN(vkQueuePresentKHR) +DECLARE_VK_PFN(vkResetFences) +DECLARE_VK_PFN(vkWaitForFences) + +static void load_vulkan_procs(void) +{ + void *libvulkan; + + if (!(libvulkan = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) + { + fprintf(stderr, "Failed to load %s: %s.\n", SONAME_LIBVULKAN, dlerror()); + exit(1); + } + +#define LOAD_VK_PFN(name) name = (void *)dlsym(libvulkan, #name); + LOAD_VK_PFN(vkAcquireNextImageKHR) + LOAD_VK_PFN(vkCreateFence) + LOAD_VK_PFN(vkCreateSwapchainKHR) + LOAD_VK_PFN(vkCreateXcbSurfaceKHR) + LOAD_VK_PFN(vkDestroyFence) + LOAD_VK_PFN(vkDestroySurfaceKHR) + LOAD_VK_PFN(vkDestroySwapchainKHR) + LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) + LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceFormatsKHR) + LOAD_VK_PFN(vkGetPhysicalDeviceSurfaceSupportKHR) + LOAD_VK_PFN(vkGetSwapchainImagesKHR) + LOAD_VK_PFN(vkQueuePresentKHR) + LOAD_VK_PFN(vkResetFences) + LOAD_VK_PFN(vkWaitForFences) +}
struct demo { @@ -330,6 +377,8 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c VkImage *vk_images; VkFormat format;
+ load_vulkan_procs(); + if ((format = vkd3d_get_vk_format(desc->format)) == VK_FORMAT_UNDEFINED) return NULL;