fs2open.github.com
fs2open.github.com copied to clipboard
[24.2.0] fails to build with vulkan 1.3.301
24.2.0 fails to build with vulkan 1.3.301 with:
[...]
/var/tmp/paludis/build/games-simulation-fs2_open-24.2.0/work/fs2_open-24.2.0/code/graphics/vulkan/VulkanRenderer.cpp: In member function 'bool graphics::vulkan::VulkanRenderer::initializeSurface()':
/var/tmp/paludis/build/games-simulation-fs2_open-24.2.0/work/fs2_open-24.2.0/code/graphics/vulkan/VulkanRenderer.cpp:460:19: error: 'ObjectDestroy' in namespace 'vk' does not name a template type
460 | const vk::ObjectDestroy<vk::Instance, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> deleter(*m_vkInstance,
| ^~~~~~~~~~~~~
/var/tmp/paludis/build/games-simulation-fs2_open-24.2.0/work/fs2_open-24.2.0/code/graphics/vulkan/VulkanRenderer.cpp:463:69: error: 'deleter' was not declared in this scope
463 | m_vkSurface = vk::UniqueSurfaceKHR(vk::SurfaceKHR(surface), deleter);
| ^~~~~~~
Complete build log: fs2_open-24.2.0_build.log
Confirmed on Windows on ARM64 with VulkanSDK v1.4.304 (MSYS2+Clang and MSVC+vcpkg as well):
[778/1285] Building CXX object code/CMakeFiles/code.dir/graphics/vulkan/VulkanRenderer.cpp.obj
FAILED: code/CMakeFiles/code.dir/graphics/vulkan/VulkanRenderer.cpp.obj
D:\msys64\clangarm64\bin\c++.exe -DANTLR4CPP_STATIC -DCMAKE_PCH -DFS_OPENXR -DNDEBUG -DNTDDI_VERSION=0x06000000 -DROCKET_STATIC_LIB -DUSE_OPENAL -DVK_NO_PROTOTYPES -DVULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 -DWIN32 -DWITH_DISCORD -DWITH_FFMPEG -DWITH_OPENGL -DWITH_VULKAN -D_WIN32_WINNT=0x0600 -D_WINDOWS -D__STDC_FORMAT_MACROS -IX:/CODE/fs2open.github.com/code -IX:/CODE/fs2open.github.com/freespace2 -IX:/CODE/fs2open.github.com/build/generated_source -IX:/CODE/fs2open.github.com/build/generated_source/code -IX:/CODE/fs2open.github.com/code/OpenXR::Headers -IX:/CODE/fs2open.github.com/build/code -IX:/CODE/fs2open.github.com/build/code/embedded_files -IX:/CODE/fs2open.github.com/lib/lua -IX:/CODE/fs2open.github.com/lib/libjpeg -IX:/CODE/fs2open.github.com/build/lib/prebuilt/sdl2/include -IX:/CODE/fs2open.github.com/lib/discord/src/../include -IX:/CODE/fs2open.github.com/lib/libRocket/Include -IX:/CODE/fs2open.github.com/build/lib/prebuilt/freetype/include -IX:/CODE/fs2open.github.com/parsers -IX:/CODE/fs2open.github.com/lib/antlr4-cpp-runtime/runtime/src -IX:/CODE/fs2open.github.com/lib/accidental-noise -IX:/CODE/fs2open.github.com/lib/hidapi/hidapi -IX:/CODE/fs2open.github.com/lib/hidapi/windows -IX:/CODE/fs2open.github.com/lib/openxr/include -IX:/CODE/fs2open.github.com/build/lib/openxr/include -isystem X:/CODE/fs2open.github.com/lib/opengl/gl/glad/include -isystem X:/CODE/fs2open.github.com/build/lib/prebuilt/openal/include -isystem X:/CODE/fs2open.github.com/lib/libpng -isystem X:/CODE/fs2open.github.com/lib/zlib -isystem X:/CODE/fs2open.github.com/lib/lz4 -isystem X:/CODE/fs2open.github.com/build/lib/prebuilt/ffmpeg/include -isystem X:/CODE/fs2open.github.com/lib/utfcpp -isystem X:/CODE/fs2open.github.com/lib/md5 -isystem X:/CODE/fs2open.github.com/lib/libpcp/include -isystem X:/CODE/fs2open.github.com/lib/mdns -isystem X:/CODE/fs2open.github.com/build/lib/jansson/include -isystem X:/CODE/fs2open.github.com/lib/variant -isystem X:/CODE/fs2open.github.com/lib/any -isystem X:/CODE/fs2open.github.com/lib/optional/include -isystem X:/CODE/fs2open.github.com/lib/imgui -isystem C:/Temp/VulkanSDK/1.4.304.0/Include -pipe -W -Wall -Wextra -fsigned-char -Wno-unknown-pragmas -fdiagnostics-color -Wformat-security -Wreturn-type -Wno-char-subscripts -Wno-shift-negative-value -O3 -Wno-unused-variable -Wno-unused-parameter -std=gnu++17 -flto=thin -Winvalid-pch -Xclang -include-pch -Xclang X:/CODE/fs2open.github.com/build/code/CMakeFiles/code.dir/cmake_pch.hxx.pch -Xclang -include -Xclang X:/CODE/fs2open.github.com/build/code/CMakeFiles/code.dir/cmake_pch.hxx -MD -MT code/CMakeFiles/code.dir/graphics/vulkan/VulkanRenderer.cpp.obj -MF code\CMakeFiles\code.dir\graphics\vulkan\VulkanRenderer.cpp.obj.d -o code/CMakeFiles/code.dir/graphics/vulkan/VulkanRenderer.cpp.obj -c X:/CODE/fs2open.github.com/code/graphics/vulkan/VulkanRenderer.cpp
X:/CODE/fs2open.github.com/code/graphics/vulkan/VulkanRenderer.cpp:416:41: error: assigning to 'vk::PFN_DebugReportCallbackEXT' (aka 'unsigned int (*)(Flags<DebugReportFlagBitsEXT>, vk::DebugReportObjectTypeEXT, unsigned long long, unsigned long long, int, const char *, const char *, void *)') from incompatible type 'VkBool32 (VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *) __attribute__((stdcall))' (aka 'unsigned int (unsigned int, VkDebugReportObjectTypeEXT, unsigned long long, unsigned long long, int, const char *, const char *, void *)'): type mismatch at 1st parameter ('vk::DebugReportFlagsEXT' (aka 'Flags<DebugReportFlagBitsEXT>') vs 'VkDebugReportFlagsEXT' (aka 'unsigned int'))
416 | createInstanceReportInfo.pfnCallback = debugReportCallback;
| ^~~~~~~~~~~~~~~~~~~
X:/CODE/fs2open.github.com/code/graphics/vulkan/VulkanRenderer.cpp:436:34: error: assigning to 'vk::PFN_DebugReportCallbackEXT' (aka 'unsigned int (*)(Flags<DebugReportFlagBitsEXT>, vk::DebugReportObjectTypeEXT, unsigned long long, unsigned long long, int, const char *, const char *, void *)') from incompatible type 'VkBool32 (VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *) __attribute__((stdcall))' (aka 'unsigned int (unsigned int, VkDebugReportObjectTypeEXT, unsigned long long, unsigned long long, int, const char *, const char *, void *)'): type mismatch at 1st parameter ('vk::DebugReportFlagsEXT' (aka 'Flags<DebugReportFlagBitsEXT>') vs 'VkDebugReportFlagsEXT' (aka 'unsigned int'))
436 | reportCreateInfo.pfnCallback = debugReportCallback;
| ^~~~~~~~~~~~~~~~~~~
X:/CODE/fs2open.github.com/code/graphics/vulkan/VulkanRenderer.cpp:460:8: error: no template named 'ObjectDestroy' in namespace 'vk'; did you mean 'vk::detail::ObjectDestroy'?
460 | const vk::ObjectDestroy<vk::Instance, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> deleter(*m_vkInstance,
| ^~~~~~~~~~~~~~~~~
| vk::detail::ObjectDestroy
C:/Temp/VulkanSDK/1.4.304.0/Include/vulkan/vulkan.hpp:6181:11: note: 'vk::detail::ObjectDestroy' declared here
6181 | class ObjectDestroy
| ^
3 errors generated.
[787/1285] Building CXX object code/CMakeFiles/code.dir/hud/hudlock.cpp.obj
ninja: build stopped: subcommand failed.
Should be fixed with #6709.
I assume it's fixed with gcc-13, but there seem to be type conversion errors with clang. I'm on OpenBSD with currently clang version 19.1.7, vulkan version 1.4.321.0, and I run into this error:
/usr/ports/pobj/fs2open-24.2.0/fs2open.github.com-release_24_2_0/code/graphics/vulkan/VulkanRenderer.cpp:416:41: error: assigning to 'vk::PFN_DebugReportCallbackEXT' (aka 'unsigned int (*)(Flags<DebugReportFlagBitsEXT>, vk::DebugReportObjectTypeEXT, unsigned long long, unsigned long, int, const char *, const char *, void *)') from incompatible type 'VkBool32 (VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *)' (aka 'unsigned int (unsigned int, VkDebugReportObjectTypeEXT, unsigned long long, unsigned long, int, const char *, const char *, void *)'): type mismatch at 1st parameter ('vk::DebugReportFlagsEXT' (aka 'Flags<DebugReportFlagBitsEXT>') vs 'VkDebugReportFlagsEXT' (aka 'unsigned int'))
416 | createInstanceReportInfo.pfnCallback = debugReportCallback;
| ^~~~~~~~~~~~~~~~~~~
/usr/ports/pobj/fs2open-24.2.0/fs2open.github.com-release_24_2_0/code/graphics/vulkan/VulkanRenderer.cpp:436:34: error: assigning to 'vk::PFN_DebugReportCallbackEXT' (aka 'unsigned int (*)(Flags<DebugReportFlagBitsEXT>, vk::DebugReportObjectTypeEXT, unsigned long long, unsigned long, int, const char *, const char *, void *)') from incompatible type 'VkBool32 (VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *)' (aka 'unsigned int (unsigned int, VkDebugReportObjectTypeEXT, unsigned long long, unsigned long, int, const char *, const char *, void *)'): type mismatch at 1st parameter ('vk::DebugReportFlagsEXT' (aka 'Flags<DebugReportFlagBitsEXT>') vs 'VkDebugReportFlagsEXT' (aka 'unsigned int'))
436 | reportCreateInfo.pfnCallback = debugReportCallback;
| ^~~~~~~~~~~~~~~~~~~
/usr/ports/pobj/fs2open-24.2.0/fs2open.github.com-release_24_2_0/code/graphics/vulkan/VulkanRenderer.cpp:460:8: error: no template named 'ObjectDestroy' in namespace 'vk'; did you mean 'vk::detail::ObjectDestroy'?
460 | const vk::ObjectDestroy<vk::Instance, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> deleter(*m_vkInstance,
| ^~~~~~~~~~~~~~~~~
| vk::detail::ObjectDestroy
/usr/local/include/vulkan/vulkan.hpp:6538:11: note: 'vk::detail::ObjectDestroy' declared here
6538 | class ObjectDestroy
| ^
3 errors generated.
Any hints? Those type conversions are a bit complex for me, but maybe I'm overthinking it...
Hmm. @vmedea , since you worked on #6709, do you have insight here?
Also @rfht , just for sanity's sake, are you compiling the latest source? Based on your log, it looks like you may be trying to compile the source as it existed for the stable 24.2 release. And that source checkout would predate the recent Vulkan fixes from #6709.
@Goober5000 I built 24.2 with the fixes from #6709 backported
These particular build issues don't look familiar to me!
type mismatch at 1st parameter ('vk::DebugReportFlagsEXT' (aka 'Flags<DebugReportFlagBitsEXT>') vs 'VkDebugReportFlagsEXT' (aka 'unsigned int'))
It looks like it's trying to pass the the C++'ized version vk::DebugReportFlagsEXT instead of the C Vulkan type VkDebugReportFlagsEXT that the function accepts.
As far as i could see, that was always the case! So i think it's just that clang is more strict here. This would be fixed by changing that handler to take vk::DebugReportFlagsEXT instead.
C:/Temp/VulkanSDK/1.4.304.0/Include/vulkan/vulkan.hpp:6181:11: note: 'vk::detail::ObjectDestroy' declared here 6181 | class ObjectDestroy
vk::ObjectDestroy was apparently moved into the vk::detail namespace in v1.3.301:
https://github.com/KhronosGroup/Vulkan-Hpp/commit/6e5489fcd96ba1e2cf994ebe3e4d1f5f4f690f4b
To handle newer versions of Vulkan SDK as well as the old ones, we would need some #ifdef logic based on VK_HEADER_VERSION. If we bump the minimum required Vulkan SDK version, that could be avoided.
@rfht Can you please try if this makes it compile?
diff --git a/code/graphics/vulkan/VulkanRenderer.cpp b/code/graphics/vulkan/VulkanRenderer.cpp
index 8de061e39db9bfec3f1ee71e40fbea5b4e7b6580..880783c41ce401096c7655c958d9905fc542dfa2 100644
--- a/code/graphics/vulkan/VulkanRenderer.cpp
+++ b/code/graphics/vulkan/VulkanRenderer.cpp
@@ -25,8 +25,8 @@ const char* EngineName = "FreeSpaceOpen";
const gameversion::version MinVulkanVersion(1, 1, 0, 0);
-VkBool32 VKAPI_PTR debugReportCallback(VkDebugReportFlagsEXT /*flags*/,
- VkDebugReportObjectTypeEXT /*objectType*/,
+VkBool32 VKAPI_PTR debugReportCallback(vk::DebugReportFlagsEXT /*flags*/,
+ vk::DebugReportObjectTypeEXT /*objectType*/,
uint64_t /*object*/,
size_t /*location*/,
int32_t /*messageCode*/,
@@ -457,7 +457,7 @@ bool VulkanRenderer::initializeSurface()
return false;
}
- const vk::ObjectDestroy<vk::Instance, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> deleter(*m_vkInstance,
+ const vk::detail::ObjectDestroy<vk::Instance, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> deleter(*m_vkInstance,
nullptr,
VULKAN_HPP_DEFAULT_DISPATCHER);
m_vkSurface = vk::UniqueSurfaceKHR(vk::SurfaceKHR(surface), deleter);
that fixes the build, thank you.
Great, that's for testing. i'll push a PR soon.