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;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- configure.ac | 1 - m4/check-vulkan.m4 | 16 ++++++---------- 2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac index 15ec60de5..1885edffb 100644 --- a/configure.ac +++ b/configure.ac @@ -113,7 +113,6 @@ case $host_os in ;; esac
-AC_ARG_VAR([VULKAN_LIBS], [linker flags for the Vulkan library]) VKD3D_CHECK_VULKAN
AS_IF([test "x$with_ncurses" != "xno"], diff --git a/m4/check-vulkan.m4 b/m4/check-vulkan.m4 index 756f61a0e..b2c3f8a12 100644 --- a/m4/check-vulkan.m4 +++ b/m4/check-vulkan.m4 @@ -1,16 +1,12 @@ dnl VKD3D_CHECK_VULKAN AC_DEFUN([VKD3D_CHECK_VULKAN],[ -VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr], - [VULKAN_LIBS="$VULKAN_LIBS -lvulkan"], +VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr],, [VKD3D_CHECK_SONAME([vulkan-1], [vkGetInstanceProcAddr], - [VULKAN_LIBS="$VULKAN_LIBS -lvulkan-1" - AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN], ["$ac_cv_lib_soname_vulkan_1"])], + [AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN], ["$ac_cv_lib_soname_vulkan_1"])], [VKD3D_CHECK_SONAME([MoltenVK], [vkGetInstanceProcAddr], - [VULKAN_LIBS="$VULKAN_LIBS -lMoltenVK" - AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN], + [AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN], ["$ac_cv_lib_soname_MoltenVK"])], - [AC_MSG_ERROR([libvulkan and libMoltenVK not found.])], - [$VULKAN_LIBS])], - [$VULKAN_LIBS])], - [$VULKAN_LIBS]) + [AC_MSG_ERROR([libvulkan and libMoltenVK not found.])]) + ]) + ]) ])
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 1885edffb..6f774f94c 100644 --- a/configure.ac +++ b/configure.ac @@ -113,7 +113,10 @@ case $host_os in ;; esac
-VKD3D_CHECK_VULKAN +AC_ARG_VAR([SONAME_LIBVULKAN], [shared object name for the Vulkan library]) +AS_IF([test "x$SONAME_LIBVULKAN" = "x"], + [VKD3D_CHECK_VULKAN], + [AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN],["$SONAME_LIBVULKAN"],[Define to the shared object name of the Vulkan library.])])
AS_IF([test "x$with_ncurses" != "xno"], [PKG_CHECK_MODULES([NCURSES], [ncurses],
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com