Skip to content
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

Fails to build when using VULKAN_HPP_TYPESAFE_CONVERSION=0 #2036

Open
M2-TE opened this issue Jan 8, 2025 · 4 comments
Open

Fails to build when using VULKAN_HPP_TYPESAFE_CONVERSION=0 #2036

M2-TE opened this issue Jan 8, 2025 · 4 comments

Comments

@M2-TE
Copy link

M2-TE commented Jan 8, 2025

Using vulkan-hpp v1.4.303 alongside vulkan-headers v1.4.303 and disabling typesafe conversion via VULKAN_HPP_TYPESAFE_CONVERSION=0 seems to break some comparison operators (among other things). Issue #2028 might be related to this, if it happens due to 64/32 bit shenanigans

Here is an excerpt:

In file included from [...]/vulkan-hpp-src/vulkan/vulkan.hpp:8864:
[...]/vulkan-hpp-src/vulkan/vulkan_structs.hpp:8469:74: error: invalid operands to binary expression ('const vk::Image' and 'const vk::Image')
 8469 |       return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( image == rhs.image ) && ( memory == rhs.memory ) && ( memoryOffset == rhs.memoryOffset );
      |                                                                    ~~~~~ ^  ~~~~~~~~~
[...]/vulkan-hpp-src/vulkan/vulkan.hpp:203:8: note: candidate template ignored: could not match 'const ArrayWrapper1D<char, N>' against 'const vk::Image'
  203 |   bool operator==( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
      |        ^
[...]/vulkan-hpp-src/vulkan/vulkan.hpp:248:8: note: candidate template ignored: could not match 'const ArrayWrapper1D<char, N>' against 'const vk::Image'
  248 |   bool operator==( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
      |        ^
[...]/vulkan-hpp-src/vulkan/vulkan_enums.hpp:166:29: note: candidate template ignored: could not match 'const Flags<BitType>' against 'const vk::Image'
  166 |   VULKAN_HPP_CONSTEXPR bool operator==( BitType bit, Flags<BitType> const & flags ) VULKAN_HPP_NOEXCEPT

In case its of interest, my flags are the following:

VK_NO_PROTOTYPES
VULKAN_HPP_NO_SETTERS
VULKAN_HPP_NO_TO_STRING
VULKAN_HPP_NO_CONSTRUCTORS
VULKAN_HPP_NO_SMART_HANDLE
VULKAN_HPP_NO_SPACESHIP_OPERATOR
VULKAN_HPP_NO_PROTOTYPES
VULKAN_HPP_TYPESAFE_CONVERSION=0
VULKAN_HPP_DISPATCH_LOADER_DYNAMIC

Compiled with Clang 18.1.8 and c++23, similar errors with GCC 14.2.1

@asuessenbach
Copy link
Contributor

Up to now, I can't repro this issue.
But thanks to your list of flags, I realized that two flags are named wrong in the documentation: VULKAN_HPP_NO_CONSTRUCTORS should be VULKAN_HPP_NO_STRUCT_CONSTRUCTORS, and VULKAN_HPP_NO_SETTERS should be VULKAN_HPP_NO_STRUCT_SETTERS.
Will adjust the readme right now.

@asuessenbach
Copy link
Contributor

asuessenbach commented Jan 9, 2025

@M2-TE As said above, I can't repro this issue.
Therefore, could you please try to add this operator to the class vk::Image in vulkan_handles.hpp (should be located around line 4000 in that file):

    bool operator==(VULKAN_HPP_NAMESPACE::Image const& rhs) const VULKAN_HPP_NOEXCEPT
    {
      return m_image == rhs.m_image;
    }

Does that help (at least with that part of the list of error messages)?

@M2-TE
Copy link
Author

M2-TE commented Jan 9, 2025

Adding that operator fixed the issue for vk::Image, although the same has to probably be done with a ton of other classes. If you need, I could provide names of some of these other classes with the exact same errors. In the meantime, I will try to create a minimal example that can reproduce the issue

@M2-TE
Copy link
Author

M2-TE commented Jan 9, 2025

Here is a short example to reproduce the issue. Same compiler setup as mentioned before.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.28)
project(vk_test LANGUAGES CXX)

add_executable(${PROJECT_NAME} "main.cpp")

include(FetchContent)
FetchContent_Declare(vulkan-headers
    GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Headers.git"
    GIT_TAG "v1.4.303"
    GIT_SHALLOW ON
    OVERRIDE_FIND_PACKAGE
    EXCLUDE_FROM_ALL
    SYSTEM)
FetchContent_Declare(vulkan-hpp
    GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Hpp.git"
    GIT_TAG "v1.4.303"
    GIT_SHALLOW ON
    GIT_SUBMODULES ""
    SOURCE_SUBDIR "disabled"
    OVERRIDE_FIND_PACKAGE
    EXCLUDE_FROM_ALL
    SYSTEM)
FetchContent_MakeAvailable(vulkan-headers vulkan-hpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Headers)
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE "${vulkan-hpp_SOURCE_DIR}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "VULKAN_HPP_TYPESAFE_CONVERSION=0")

main.cpp:

#include <vulkan/vulkan.hpp>
int main() {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants