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

Add function pointer check when using DispatchLoaderDynamic. #1769

Merged
merged 1 commit into from
Jan 8, 2024
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
10 changes: 7 additions & 3 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,9 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
${nodiscard}VULKAN_HPP_INLINE ${decoratedReturnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
#if (VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
${functionPointerCheck}
#endif
${vectorSizeCheck}
${dataSizeChecks}
${dataDeclarations}
Expand All @@ -3482,6 +3485,7 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
{ "dataPreparation", dataPreparation },
{ "dataSizeChecks", dataSizeChecks },
{ "decoratedReturnType", decoratedReturnType },
{ "functionPointerCheck", generateFunctionPointerCheck( name, commandData.requiredBy, false ) },
{ "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "resultCheck", resultCheck },
Expand Down Expand Up @@ -7507,7 +7511,7 @@ std::string VulkanHppGenerator::generateFormatTraits() const
{ "texelsPerBlockCases", texelsPerBlockCases } } );
}

std::string VulkanHppGenerator::generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy ) const
std::string VulkanHppGenerator::generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy, bool raii ) const
{
std::string functionPointerCheck;
if ( !requiredBy.empty() )
Expand All @@ -7518,7 +7522,7 @@ std::string VulkanHppGenerator::generateFunctionPointerCheck( std::string const
message += " or <" + *it + ">";
}

functionPointerCheck = "VULKAN_HPP_ASSERT( getDispatcher()->" + function + " && \"" + message + "\" );";
functionPointerCheck = std::string( "VULKAN_HPP_ASSERT( " ) + ( raii ? "getDispatcher()->" : "d." ) + function + " && \"" + message + "\" );";
}
return functionPointerCheck;
}
Expand Down Expand Up @@ -8672,7 +8676,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::string c
{ "dataDeclarations", dataDeclarations },
{ "dataPreparation", dataPreparation },
{ "dataSizeChecks", dataSizeChecks },
{ "functionPointerCheck", generateFunctionPointerCheck( name, commandData.requiredBy ) },
{ "functionPointerCheck", generateFunctionPointerCheck( name, commandData.requiredBy, true ) },
{ "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "resultCheck", resultCheck },
Expand Down
2 changes: 1 addition & 1 deletion VulkanHppGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class VulkanHppGenerator
std::string generateExtensionsList( std::string const & type ) const;
std::string generateExtensionTypeTest( std::string const & type ) const;
std::string generateFormatTraits() const;
std::string generateFunctionPointerCheck( std::string const & function, std::set<std::string> const & requiredBy ) 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;
std::string generateHandleDependencies( std::pair<std::string, HandleData> const & handle, std::set<std::string> & listedHandles ) const;
Expand Down
Loading
Loading