Skip to content

Commit

Permalink
Add funcpointer types to vulkan.cppm. (#2022)
Browse files Browse the repository at this point in the history
  • Loading branch information
asuessenbach authored Dec 12, 2024
1 parent d5a18dc commit 1055cb5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
38 changes: 38 additions & 0 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5493,6 +5493,43 @@ std::string VulkanHppGenerator::generateConstexprUsings() const
return constexprUsings;
}

std::string VulkanHppGenerator::generateCppModuleFuncpointerUsings() const
{
std::string funcpointerUsings = R"(
//====================
//=== FUNCPOINTERs ===
//====================
)";

auto const generateUsingsAndProtection = [this]( std::vector<RequireData> const & requireData, std::string const & title )
{
auto usings = std::string{};
for ( auto const & require : requireData )
{
for ( auto const & type : require.types )
{
if ( auto const & funcpointerIt = m_funcPointers.find( type.name ); funcpointerIt != m_funcPointers.end() )
{
usings += " using VULKAN_HPP_NAMESPACE::PFN_" + stripPrefix( funcpointerIt->first, "PFN_vk" ) + ";\n";
}
}
}
return addTitleAndProtection( title, usings );
};

for ( auto const & feature : m_features )
{
funcpointerUsings += generateUsingsAndProtection( feature.requireData, feature.name );
}

for ( auto const & extension : m_extensions )
{
funcpointerUsings += generateUsingsAndProtection( extension.requireData, extension.name );
}

return funcpointerUsings;
}

std::string VulkanHppGenerator::generateCppModuleHandleUsings() const
{
auto const usingTemplate = std::string{ R"( using VULKAN_HPP_NAMESPACE::${className};
Expand Down Expand Up @@ -5980,6 +6017,7 @@ std::string VulkanHppGenerator::generateCppModuleUsings() const
usings += "\n" + generateConstexprUsings() + "\n";

// structs, handles, UniqueHandles, etc
usings += generateCppModuleFuncpointerUsings();
usings += generateCppModuleStructUsings();
usings += generateCppModuleHandleUsings();
usings += generateCppModuleUniqueHandleUsings();
Expand Down
1 change: 1 addition & 0 deletions VulkanHppGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ class VulkanHppGenerator
std::string generateConstexprString( std::string const & structName ) const;
std::string generateConstexprDefines() const;
std::string generateConstexprUsings() const;
std::string generateCppModuleFuncpointerUsings() const;
std::string generateCppModuleHandleUsings() const;
std::string generateCppModuleStructUsings() const;
std::string generateCppModuleUniqueHandleUsings() const;
Expand Down
24 changes: 24 additions & 0 deletions vulkan/vulkan.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -2688,6 +2688,30 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::ApiVersion14;
using VULKAN_HPP_NAMESPACE::HeaderVersionComplete;

//====================
//=== FUNCPOINTERs ===
//====================

//=== VK_VERSION_1_0 ===
using VULKAN_HPP_NAMESPACE::PFN_AllocationFunction;
using VULKAN_HPP_NAMESPACE::PFN_FreeFunction;
using VULKAN_HPP_NAMESPACE::PFN_InternalAllocationNotification;
using VULKAN_HPP_NAMESPACE::PFN_InternalFreeNotification;
using VULKAN_HPP_NAMESPACE::PFN_ReallocationFunction;
using VULKAN_HPP_NAMESPACE::PFN_VoidFunction;

//=== VK_EXT_debug_report ===
using VULKAN_HPP_NAMESPACE::PFN_DebugReportCallbackEXT;

//=== VK_EXT_debug_utils ===
using VULKAN_HPP_NAMESPACE::PFN_DebugUtilsMessengerCallbackEXT;

//=== VK_EXT_device_memory_report ===
using VULKAN_HPP_NAMESPACE::PFN_DeviceMemoryReportCallbackEXT;

//=== VK_LUNARG_direct_driver_loading ===
using VULKAN_HPP_NAMESPACE::PFN_GetInstanceProcAddrLUNARG;

//===============
//=== STRUCTs ===
//===============
Expand Down

0 comments on commit 1055cb5

Please sign in to comment.