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

Build failure, unless I add 'VULKAN_HPP_DEFAULT_DISPATCHER' as third argument in 'this->mInstance->enumeratePhysicalDevices' #259

Open
JesseVanDis opened this issue Jan 12, 2022 · 3 comments

Comments

@JesseVanDis
Copy link

Hi

I am experiencing a build error when I run CMake and make on it.

The error is as follows:

[1/2] Building CXX object src/CMakeFiles/kompute.dir/Manager.cpp.o
FAILED: src/CMakeFiles/kompute.dir/Manager.cpp.o 
/usr/bin/c++ -DFMT_LOCALE -I/home/jesse/kompute/kompute/src/include -I/home/jesse/kompute/kompute/single_include -O3 -DNDEBUG -DRELEASE=1  -std=gnu++14 -MD -MT src/CMakeFiles/kompute.dir/Manager.cpp.o -MF src/CMakeFiles/kompute.dir/Manager.cpp.o.d -o src/CMakeFiles/kompute.dir/Manager.cpp.o -c /home/jesse/kompute/kompute/src/Manager.cpp
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/vulkan/vulkan.hpp:51,
                 from /home/jesse/kompute/kompute/src/include/kompute/Core.hpp:14,
                 from /home/jesse/kompute/kompute/src/include/kompute/Manager.hpp:7,
                 from /home/jesse/kompute/kompute/src/Manager.cpp:8:
/usr/include/c++/11/bits/stl_vector.h: In instantiation of ‘struct std::_Vector_base<vk::PhysicalDevice, unsigned int*>’:
/usr/include/c++/11/bits/stl_vector.h:389:11:   required from ‘class std::vector<vk::PhysicalDevice, unsigned int*>’
/home/jesse/kompute/kompute/src/Manager.cpp:294:46:   required from here
/usr/include/c++/11/bits/stl_vector.h:87:28: error: ‘unsigned int*’ is not a class, struct, or union type
   87 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:89:9: error: ‘unsigned int*’ is not a class, struct, or union type
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/11/bits/stl_vector.h: In instantiation of ‘class std::vector<vk::PhysicalDevice, unsigned int*>’:
/home/jesse/kompute/kompute/src/Manager.cpp:294:46:   required from here
/usr/include/c++/11/bits/stl_vector.h:474:20: error: ‘_M_allocate’ has not been declared in ‘std::vector<vk::PhysicalDevice, unsigned int*>::_Base’
  474 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:475:20: error: ‘_M_deallocate’ has not been declared in ‘std::vector<vk::PhysicalDevice, unsigned int*>::_Base’
  475 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:477:20: error: ‘_M_get_Tp_allocator’ has not been declared in ‘std::vector<vk::PhysicalDevice, unsigned int*>::_Base’
  477 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
In file included from /home/jesse/kompute/kompute/src/include/kompute/Core.hpp:14,
                 from /home/jesse/kompute/kompute/src/include/kompute/Manager.hpp:7,
                 from /home/jesse/kompute/kompute/src/Manager.cpp:8:
/usr/include/vulkan/vulkan.hpp: In instantiation of ‘typename vk::ResultValueType<std::vector<vk::PhysicalDevice, Allocator> >::type vk::Instance::enumeratePhysicalDevices(const Allocator&, const Dispatch&) const [with Allocator = unsigned int*; Dispatch = std::nullptr_t; typename vk::ResultValueType<std::vector<vk::PhysicalDevice, Allocator> >::type = std::vector<vk::PhysicalDevice, unsigned int*>]’:
/home/jesse/kompute/kompute/src/Manager.cpp:294:46:   required from here
/usr/include/vulkan/vulkan.hpp:67583:39: error: request for member ‘vkEnumeratePhysicalDevices’ in ‘d’, which is of non-class type ‘std::nullptr_t67583 |       result = static_cast<Result>( d.vkEnumeratePhysicalDevices( m_instance, &physicalDeviceCount, nullptr ) );
      |                                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/vulkan/vulkan.hpp:67587:41: error: request for member ‘vkEnumeratePhysicalDevices’ in ‘d’, which is of non-class type ‘std::nullptr_t67587 |         result = static_cast<Result>( d.vkEnumeratePhysicalDevices( m_instance, &physicalDeviceCount, reinterpret_cast<VkPhysicalDevice*>( physicalDevices.data() ) ) );
      |                                       ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/vulkan/vulkan.hpp:51,
                 from /home/jesse/kompute/kompute/src/include/kompute/Core.hpp:14,
                 from /home/jesse/kompute/kompute/src/include/kompute/Manager.hpp:7,
                 from /home/jesse/kompute/kompute/src/Manager.cpp:8:
/usr/include/c++/11/bits/stl_vector.h: In instantiation of ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = vk::PhysicalDevice; _Alloc = unsigned int*]’:
/home/jesse/kompute/kompute/src/Manager.cpp:294:46:   required from here
/usr/include/c++/11/bits/stl_vector.h:680:37: error: ‘struct std::_Vector_base<vk::PhysicalDevice, unsigned int*>::_Vector_impl’ has no member named ‘_M_start’
  680 |         std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
      |                       ~~~~~~~~~~~~~~^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:680:61: error: ‘struct std::_Vector_base<vk::PhysicalDevice, unsigned int*>::_Vector_impl’ has no member named ‘_M_finish’
  680 |         std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
      |                                               ~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:681:42: error: ‘_M_get_Tp_allocator’ was not declared in this scope; did you mean ‘get_allocator’?
  681 |                       _M_get_Tp_allocator());
      |                       ~~~~~~~~~~~~~~~~~~~^~
      |                       get_allocator
/usr/include/c++/11/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::_Vector_base(const allocator_type&) [with _Tp = vk::PhysicalDevice; _Alloc = unsigned int*; std::_Vector_base<_Tp, _Alloc>::allocator_type = unsigned int*]’:
/usr/include/c++/11/bits/stl_vector.h:498:18:   required from ‘std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = vk::PhysicalDevice; _Alloc = unsigned int*; std::vector<_Tp, _Alloc>::allocator_type = unsigned int*]’
/usr/include/vulkan/vulkan.hpp:67578:43:   required from ‘typename vk::ResultValueType<std::vector<vk::PhysicalDevice, Allocator> >::type vk::Instance::enumeratePhysicalDevices(const Allocator&, const Dispatch&) const [with Allocator = unsigned int*; Dispatch = std::nullptr_t; typename vk::ResultValueType<std::vector<vk::PhysicalDevice, Allocator> >::type = std::vector<vk::PhysicalDevice, unsigned int*>]’
/home/jesse/kompute/kompute/src/Manager.cpp:294:46:   required from here
/usr/include/c++/11/bits/stl_vector.h:294:9: error: no matching function for call to ‘std::_Vector_base<vk::PhysicalDevice, unsigned int*>::_Vector_impl::_Vector_impl(unsigned int* const&)’
  294 |       : _M_impl(__a) { }
      |         ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:143:9: note: candidate: ‘std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl(std::_Vector_base<_Tp, _Alloc>::_Vector_impl&&) [with _Tp = vk::PhysicalDevice; _Alloc = unsigned int*]’
  143 |         _Vector_impl(_Vector_impl&& __x) noexcept
      |         ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:143:37: note:   no known conversion for argument 1 from ‘const allocator_type’ {aka ‘unsigned int* const’} to ‘std::_Vector_base<vk::PhysicalDevice, unsigned int*>::_Vector_impl&&’
  143 |         _Vector_impl(_Vector_impl&& __x) noexcept
      |                      ~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:131:9: note: candidate: ‘std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = vk::PhysicalDevice; _Alloc = unsigned int*]’
  131 |         _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
      |         ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:131:9: note:   candidate expects 0 arguments, 1 provided
ninja: build stopped: subcommand failed.

The problem lies in Manager.cpp at the following line:

this->mInstance->enumeratePhysicalDevices(&deviceCount, nullptr);

of which there are 3 definitions in my vulkan.hpp:

    template<typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
    Result enumeratePhysicalDevices( uint32_t* pPhysicalDeviceCount, VULKAN_HPP_NAMESPACE::PhysicalDevice* pPhysicalDevices, Dispatch const &d = VULKAN_HPP_DEFAULT_DISPATCHER ) const VULKAN_HPP_NOEXCEPT;

#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE

    template<typename Allocator = std::allocator<PhysicalDevice>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
    typename ResultValueType<std::vector<PhysicalDevice,Allocator>>::type enumeratePhysicalDevices(Dispatch const &d = VULKAN_HPP_DEFAULT_DISPATCHER ) const;

    template<typename Allocator = std::allocator<PhysicalDevice>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
    typename ResultValueType<std::vector<PhysicalDevice,Allocator>>::type enumeratePhysicalDevices(Allocator const& vectorAllocator, Dispatch const &d ) const;

#endif

My autocomplete shows both the first and the last function as a possible invocation, perhaps because both arguments are template types.
When I force the use of the first function by adding the 3rd default argument,
this->mInstance->enumeratePhysicalDevices(&deviceCount, nullptr, VULKAN_HPP_DEFAULT_DISPATCHER);
the build succeeds.

I am wondering myself if this is because of my compiler, or maybe I have a different vulkan header.
My vulkan header version is: 131
compiler: g++ 9.3

I also tried adding add_definitions(-DVULKAN_HPP_DISABLE_ENHANCED_MODE) to the CMakeLists.txt, but then I get even more errors elsewhere.

I put this up as an issue, because I'm not sure what the cause is yet, and perhaps you guys know more..
if the vulkan header version is relevant, than I am not sure from which header version this fix is required..

@axsaucedo
Copy link
Member

Thank you for reporting this @JesseVanDis - keen to have a deeper look at this.

Could you provide information about:

  • The exact version of vulkan headers? The repo uses v1.2.158
  • The version of your vulkan? This is tested with 1.2.148 and 1.2.189

based on this we can decide on whether adding this for backwards compatibility, or suggesting to upgrade.

@JesseVanDis
Copy link
Author

Hi axsaucedo,

my vulkan version is: 1.2.131

All version info I can find about the headers are in vulkan_core.h

// Version of this file
#define VK_HEADER_VERSION 131

Is this the one you need?
let me know

Cheers, Jesse

@axsaucedo
Copy link
Member

We currently don't have a "minimum supported version" in the docs, but we may need to introduce it as it indeed seems like an older version results in potential errors.

Would you be able to upgrade your version? We could look at adding backwards compatibility to older versions of Vulkan, but normally the best practice would be to upgrade to a latter version

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