Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ namespace VULKAN_HPP_NAMESPACE
{
${structForwardDeclarations}
${handleForwardDeclarations}
${funcPointerReturns}
${uniqueHandles}
${handles}

Expand Down Expand Up @@ -289,6 +290,7 @@ namespace VULKAN_HPP_NAMESPACE

std::string str = replaceWithMap( vulkanHandlesHppTemplate,
{
{ "funcPointerReturns", generateFuncPointerReturns() },
{ "handles", generateHandles() },
{ "handleForwardDeclarations", generateHandleForwardDeclarations() },
{ "licenseHeader", m_vulkanLicenseHeader },
Expand Down Expand Up @@ -784,7 +786,7 @@ export namespace std

// This VkFlags type is used as part of a bitfield in some structure.
// As it that can't be mimiced by vk-data types, we need to export just that!!
using VkGeometryInstanceFlagsKHR;
export VkGeometryInstanceFlagsKHR;
)";

auto const str = replaceWithMap( vulkanCppmTemplate,
Expand Down Expand Up @@ -5505,7 +5507,7 @@ std::string VulkanHppGenerator::generateCppModuleFuncpointerUsings() const
//====================
)";

auto const generateUsingsAndProtection = [this]( std::vector<RequireData> const & requireData, std::string const & title )
auto const generateUsingsAndProtection = [this]( std::vector<RequireData> const & requireData, std::string const & title )
{
auto usings = std::string{};
for ( auto const & require : requireData )
Expand Down Expand Up @@ -6736,6 +6738,10 @@ std::string VulkanHppGenerator::generateDecoratedReturnType( CommandData const &
{
decoratedReturnType = generateNamespacedType( commandData.returnType );
}
else if ( commandData.returnType.starts_with( "PFN_vk" ) )
{
decoratedReturnType = "VULKAN_HPP_NAMESPACE::PFN_" + stripPrefix( commandData.returnType, "PFN_vk" );
}
else
{
decoratedReturnType = commandData.returnType;
Expand Down Expand Up @@ -8286,19 +8292,19 @@ std::string VulkanHppGenerator::generateFuncPointer( std::pair<std::string, Func
const auto [enter, leave] = generateProtection( getProtectFromType( funcPointer.first ) );

std::string funcPointerArguments;
for ( auto const & argument : funcPointer.second.arguments )
if ( !funcPointer.second.arguments.empty() )
{
funcPointerArguments += argument.type.compose( "VULKAN_HPP_NAMESPACE" ) + " " + argument.name + ", ";
for ( auto const & argument : funcPointer.second.arguments )
{
funcPointerArguments += argument.type.compose( "VULKAN_HPP_NAMESPACE" ) + " " + argument.name + ", ";
}
assert( !funcPointerArguments.empty() );
funcPointerArguments.pop_back();
funcPointerArguments.pop_back();
}
assert( !funcPointerArguments.empty() );
funcPointerArguments.pop_back();
funcPointerArguments.pop_back();

static const std::string funcPointerTemplate = R"(
typedef ${returnType} (VKAPI_PTR *PFN_${funcPointerName})
(
${funcPointerArguments}
);
typedef ${returnType} (VKAPI_PTR *PFN_${funcPointerName})( ${funcPointerArguments} );
)";

str += "\n" + enter +
Expand All @@ -8312,6 +8318,27 @@ std::string VulkanHppGenerator::generateFuncPointer( std::pair<std::string, Func
return str;
}

std::string VulkanHppGenerator::generateFuncPointerReturns() const
{
std::string str;
std::set<std::string> listedFuncPointers;
for ( auto const & handle : m_handles )
{
for ( auto const & command : handle.second.commands )
{
auto commandIt = findByNameOrAlias( m_commands, command );
assert( commandIt != m_commands.end() );
auto funcPointerIt = m_funcPointers.find( commandIt->second.returnType );
if ( ( funcPointerIt != m_funcPointers.end() ) && !listedFuncPointers.contains( commandIt->second.returnType ) )
{
assert( funcPointerIt->second.arguments.empty() );
str += generateFuncPointer( *funcPointerIt, listedFuncPointers );
}
}
}
return str;
}

std::string VulkanHppGenerator::generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy, bool raii ) const
{
std::string functionPointerCheck;
Expand Down
1 change: 1 addition & 0 deletions VulkanHppGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ class VulkanHppGenerator
std::string generateExtensionTypeTest( std::string const & type ) const;
std::string generateFormatTraits() const;
std::string generateFuncPointer( std::pair<std::string, FuncPointerData> const & funcPointer, std::set<std::string> & listedStructs ) const;
std::string generateFuncPointerReturns() const;
std::string generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy, bool raii ) const;
std::string generateHandle( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const;
std::string generateHandleCommandDeclarations( std::set<std::string> const & commands ) const;
Expand Down
2 changes: 1 addition & 1 deletion vulkan/vulkan.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -8249,4 +8249,4 @@ export namespace std

// This VkFlags type is used as part of a bitfield in some structure.
// As it that can't be mimiced by vk-data types, we need to export just that!!
using VkGeometryInstanceFlagsKHR;
export VkGeometryInstanceFlagsKHR;
4 changes: 2 additions & 2 deletions vulkan/vulkan_funcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ namespace VULKAN_HPP_NAMESPACE

#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch>
VULKAN_HPP_INLINE PFN_vkVoidFunction Instance::getProcAddr( const std::string & name, Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::PFN_VoidFunction Instance::getProcAddr( const std::string & name, Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
# if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
Expand All @@ -422,7 +422,7 @@ namespace VULKAN_HPP_NAMESPACE

#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch>
VULKAN_HPP_INLINE PFN_vkVoidFunction Device::getProcAddr( const std::string & name, Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::PFN_VoidFunction Device::getProcAddr( const std::string & name, Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
# if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
Expand Down
8 changes: 6 additions & 2 deletions vulkan/vulkan_handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,8 @@ namespace VULKAN_HPP_NAMESPACE
class IndirectCommandsLayoutEXT;
class IndirectExecutionSetEXT;

typedef void( VKAPI_PTR * PFN_VoidFunction )();

#ifndef VULKAN_HPP_NO_SMART_HANDLE
//======================
//=== UNIQUE HANDLEs ===
Expand Down Expand Up @@ -9722,7 +9724,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkVoidFunction getProcAddr( const char * pName, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
PFN_vkVoidFunction getProcAddr( const std::string & name, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
VULKAN_HPP_NAMESPACE::PFN_VoidFunction getProcAddr( const std::string & name,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */

template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
Expand Down Expand Up @@ -17032,7 +17035,8 @@ namespace VULKAN_HPP_NAMESPACE
PFN_vkVoidFunction getProcAddr( const char * pName, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
PFN_vkVoidFunction getProcAddr( const std::string & name, Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
VULKAN_HPP_NAMESPACE::PFN_VoidFunction getProcAddr( const std::string & name,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /* VULKAN_HPP_DISABLE_ENHANCED_MODE */

//=== VK_VERSION_1_1 ===
Expand Down
8 changes: 4 additions & 4 deletions vulkan/vulkan_raii.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@ namespace VULKAN_HPP_NAMESPACE
std::vector<VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::PhysicalDevice>>::Type
enumeratePhysicalDevices() const;

VULKAN_HPP_NODISCARD PFN_vkVoidFunction getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT;
VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::PFN_VoidFunction getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT;

//=== VK_VERSION_1_1 ===

Expand Down Expand Up @@ -3818,7 +3818,7 @@ namespace VULKAN_HPP_NAMESPACE

//=== VK_VERSION_1_0 ===

VULKAN_HPP_NODISCARD PFN_vkVoidFunction getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT;
VULKAN_HPP_NODISCARD VULKAN_HPP_NAMESPACE::PFN_VoidFunction getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT;

VULKAN_HPP_NODISCARD
VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::detail::CreateReturnType<VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::Queue>::Type
Expand Down Expand Up @@ -13176,7 +13176,7 @@ namespace VULKAN_HPP_NAMESPACE
return memoryProperties;
}

VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE PFN_vkVoidFunction Instance::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::PFN_VoidFunction Instance::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( getDispatcher()->vkGetInstanceProcAddr && "Function <vkGetInstanceProcAddr> requires <VK_VERSION_1_0>" );

Expand All @@ -13185,7 +13185,7 @@ namespace VULKAN_HPP_NAMESPACE
return result;
}

VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE PFN_vkVoidFunction Device::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::PFN_VoidFunction Device::getProcAddr( const std::string & name ) const VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( getDispatcher()->vkGetDeviceProcAddr && "Function <vkGetDeviceProcAddr> requires <VK_VERSION_1_0>" );

Expand Down