Disable tests in this case, and do not attempt to load libvulkan from within vkd3d itself.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Should libvulkan support be explicitly disabled with a configure argument instead?
configure.ac | 15 ++++++++------ include/vkd3d.h | 5 ++++- libs/vkd3d/device.c | 6 ++++++ m4/check-vulkan.m4 | 3 +-- m4/notice.m4 | 49 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 m4/notice.m4
diff --git a/configure.ac b/configure.ac index a58e453f3..33098951a 100644 --- a/configure.ac +++ b/configure.ac @@ -13,11 +13,9 @@ AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools], [Build with SPIRV-Tools library (default: disabled)])) AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)])) AC_ARG_ENABLE([demos], - AS_HELP_STRING([--enable-demos], [Build demo programs (default: disabled)]),, - [enable_demos=no]) + AS_HELP_STRING([--enable-demos], [Build demo programs (default: disabled)])) AC_ARG_ENABLE([tests], - AS_HELP_STRING([--enable-tests], [Build tests (default: enabled)]),, - [enable_tests=yes]) + AS_HELP_STRING([--enable-tests], [Build tests (default: enabled)]))
AC_USE_SYSTEM_EXTENSIONS
@@ -114,6 +112,9 @@ esac
AC_ARG_VAR([VULKAN_LIBS], [linker flags for the Vulkan library]) VKD3D_CHECK_VULKAN +AS_IF([test "x$VULKAN_LIBS" = "x" -a "x$enable_demos" = "xyes"], + [AC_MSG_ERROR([No Vulkan library found. This is an error since --enable-demos was requested.])]) +VKD3D_WARNING_ENABLE(tests,[test "x$VULKAN_LIBS" = "x"],[No Vulkan library found, tests will be disabled.],[enable_tests])
AS_IF([test "x$with_ncurses" != "xno"], [PKG_CHECK_MODULES([NCURSES], [ncurses], @@ -176,8 +177,8 @@ AS_ECHO([" Have SPIRV-Tools: ${with_spirv_tools} Have xcb: ${HAVE_XCB}
- Building demos: ${enable_demos} - Building tests: ${enable_tests} + Building demos: ${enable_demos:-no} + Building tests: ${enable_tests:-yes} Building documentation: ${HAVE_DOCS} "])
@@ -186,3 +187,5 @@ AS_IF([test "x$enable_tests" != "xno"], [AS_ECHO([" Cross-compiling tests: ${HA AS_IF([test "x$CROSSTARGET32" != "xno"], [AS_ECHO([" Using 32-bit cross compiler: $CROSSCC32"])]) AS_IF([test "x$CROSSTARGET64" != "xno"], [AS_ECHO([" Using 64-bit cross compiler: $CROSSCC64"])]) AS_ECHO([]) + +VKD3D_PRINT_MESSAGES diff --git a/include/vkd3d.h b/include/vkd3d.h index bce3c6e4b..b7f49835b 100644 --- a/include/vkd3d.h +++ b/include/vkd3d.h @@ -81,7 +81,10 @@ struct vkd3d_instance_create_info PFN_vkd3d_join_thread pfn_join_thread; size_t wchar_size;
- /* If set to NULL, libvkd3d loads libvulkan. */ + /** + * If set to NULL, and libvulkan was available at build time, libvkd3d will + * attempt to load libvulkan. + */ PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr;
const char * const *instance_extensions; diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index d23062d09..985fb3f80 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -477,6 +477,7 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance,
if (!vkGetInstanceProcAddr) { +#ifdef SONAME_LIBVULKAN if (!(instance->libvulkan = vkd3d_dlopen(SONAME_LIBVULKAN))) { ERR("Failed to load libvulkan: %s.\n", vkd3d_dlerror()); @@ -490,6 +491,11 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance, instance->libvulkan = NULL; return E_FAIL; } +#else + ERR("No function pointer for vkGetInstanceProcAddr was provided,\n"); + ERR("and libvulkan was not available at build time.\n"); + return E_FAIL; +#endif } else { diff --git a/m4/check-vulkan.m4 b/m4/check-vulkan.m4 index 756f61a0e..fa6f9dbc3 100644 --- a/m4/check-vulkan.m4 +++ b/m4/check-vulkan.m4 @@ -8,8 +8,7 @@ VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr], [VKD3D_CHECK_SONAME([MoltenVK], [vkGetInstanceProcAddr], [VULKAN_LIBS="$VULKAN_LIBS -lMoltenVK" AC_DEFINE_UNQUOTED([SONAME_LIBVULKAN], - ["$ac_cv_lib_soname_MoltenVK"])], - [AC_MSG_ERROR([libvulkan and libMoltenVK not found.])], + ["$ac_cv_lib_soname_MoltenVK"])],, [$VULKAN_LIBS])], [$VULKAN_LIBS])], [$VULKAN_LIBS]) diff --git a/m4/notice.m4 b/m4/notice.m4 new file mode 100644 index 000000000..4e788902b --- /dev/null +++ b/m4/notice.m4 @@ -0,0 +1,49 @@ +dnl +dnl Copyright 2002 Alexandre Julliard +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +dnl +dnl As a special exception to the GNU Lesser General Public License, +dnl if you distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it +dnl under the same distribution terms that you use for the rest of +dnl that program. + + + +dnl **** Add a message to the list displayed at the end **** +dnl +dnl Usage: VKD3D_WARNING(warning) +dnl Usage: VKD3D_WARNING_ENABLE(enable_flag, test, warning, enable) +dnl Usage: VKD3D_PRINT_MESSAGES +dnl +AC_DEFUN([VKD3D_WARNING],[AS_VAR_APPEND([vkd3d_warnings],["|$1"])]) + +AC_DEFUN([VKD3D_WARNING_ENABLE],[AS_IF([$2],[case "x$enable_$1" in + x) VKD3D_WARNING([$3]) ;; + xno) ;; + *) AC_MSG_ERROR([$3 +This is an error since --enable-$1 was requested.]) ;; +esac +m4_ifval([$4],[$4=${$4:-no}])])]) + +AC_DEFUN([VKD3D_PRINT_MESSAGES],[ac_save_IFS="$IFS" +IFS="|" +for msg in $vkd3d_warnings; do + IFS="$ac_save_IFS" + AS_VAR_IF([msg],[],,[echo >&2 + AC_MSG_WARN([$msg])]) +done +IFS="$ac_save_IFS"])