-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulkan header mismatch failures with statically linked (non-standalone) nvrhi library #45
Comments
We usually just rely on NVRHI's Vulkan-Headers to build the entire project, but I can see how you might want to use the system one or just a different version. So, I don't think it's a good idea to just rely on 1. Change the first snippet in your post into
This way, NVRHI won't use its headers when another version is available via a previously defined CMake target. 2. Add a cached variable like Let me know what you think is better. |
Thanks for your thoughts on this. I would like to test out your ideas first and come back with some feedback - And the conflict is not arising from the
As I mentioned above, if I remove DeviceManager_VK.cpp from the PCH list, then nvrhi's Vulkan-Headers and its version of Getting back to your solution options above:
Clearly anything you do here has to be pretty general and handle various build setups. However, philosophically I think that libraries which have versioned header dependencies should not impose those same dependencies on the calling application. For instance, RBDoom3BFG has dependencies on MoltenVK which in turn depends on specific versions of Vulkan which are more recent than nvrhi's Vulkan-Headers copy. You may have just updated the Vulkan-Headers version, but that will always fall behind in time or if the consuming project freezes on a particular nvrhi version. So the notion that nvrhi should determine or conflict with the Vulkan version an application uses is quite limiting. That is why I am suggesting that the scope of nvrhi's Vulkan-Headers copy be limited to the nvrhi library itself, and not pass those upwards to the calling application. Does this make sense? |
… including the headers submodule if the Vulkan-Headers target is already defined externally. NVIDIAGameWorks#45
… including the headers submodule if the Vulkan-Headers target is already defined externally. NVIDIAGameWorks#45
Thank you for the detailed explanation of options. I made the Vulkan-Headers dependency privately linked, as you suggested - see fe9e756; that doesn't seem to cause any issues with our usage of NVRHI, just need to add a dependency to Vulkan-Headers further up in the chain (donut_app specifically). |
Thanks very much for this. However, I just discovered something quite interesting - the solution works perfectly for Vulkan-Headers version 238, but fails for version 277 (independent of your fix) with:
which is caused by a conflict with this line (43) in Vulkan-Headers/CMakeLists.txt:
After some digging and experimentation, it turns out this error is caused by a subtle change in cmake policy starting with cmake policy version 3.18, where you can't override an existing target with an alias. Vulkan-Headers v238 used an old policy (v3.10.2 - allow override), while Vulkan-Headers v277 uses a newer policy (up to v3.25 - disallow override). However, this message points to something more important - an imported target called
Hopefully this solves the issue for good. It's debatable whether you now need the PRIVATE keyword vs. PUBLIC, but I believe PRIVATE may be a bit safer, e.g. handle the case when the app's CMakeLists.txt defines the location of Vulkan_SDK manually without using UPDATE: I added the Note I have taken my best guess regarding logic for I have verified these changes, except for |
…ed definition of this target. See NVIDIAGameWorks#45
Hi @SRSaunders, thank you for investigating and providing a solution. I've implemented these changes in a2e059a |
Thank you @apanteleev for your flexibility in making these changes. Everything is working fine now! |
Unless I disable precompiled headers in certain files (e.g. DeviceManager_VK.cpp), I experience Vulkan header mismatch failures when building RBDoom3BFG on linux. On Arch linux (manjaro) at least, Vulkan-Headers is installed by the package manager as a dependency for the Vulkan SDK. RBDoom3BFG pulls in the SDK which is ahead of the Vulkan-Headers version included with nvrhi. Up to this point I have been just living with this and disabling pch for files that require
vulkan.hpp
(i.e. DeviceManager_VK.cpp). However, today I decided to dive into the cmake processing to determine where things are going wrong. I found the following in nvrhi's main CMakeLists file:This seems to be pulling in nvrhi's version which may conflict with the application's own use of Vulkan, especially if a newer Vulkan-Headers is installed elsewhere for the SDK. I am wondering whether you should only pull in Vulkan-Headers as a linked library if nvrhi is being built for standalone use vs. static linking, i.e. should the
target_link_libraries
line be guarded byNVRHI_BUILD_SHARED
?The text was updated successfully, but these errors were encountered: