Skip to content

Commit

Permalink
Add some special handling debug code for vk::raii::DescriptorPool (#1978
Browse files Browse the repository at this point in the history
)
  • Loading branch information
asuessenbach authored Oct 24, 2024
1 parent eacba56 commit eecf79d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
28 changes: 18 additions & 10 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9274,8 +9274,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co

if ( definition )
{
std::string callSequence =
generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, {}, {}, flavourFlags, true, true );
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "Context";
std::vector<std::string> dataTypes = determineDataTypes( commandData.params, vectorParams, returnParams, {} );
std::string dataType = combineDataTypes( vectorParams, returnParams, enumerating, dataTypes, flavourFlags, true );
Expand All @@ -9290,17 +9288,27 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
{
vulkanType = commandData.params[returnParams.back()].type.type;
}
std::string returnStatements =
generateRAIIFactoryReturnStatements( commandData.params, commandData.successCodes, vulkanType, enumerating, returnType, returnVariable, singular );

// some special handling for vkCreateDescriptorPool: not to have this flag set!
std::string specialAssertion;
if ( name == "vkCreateDescriptorPool" )
{
specialAssertion =
"VULKAN_HPP_ASSERT( createInfo.flags & vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet && \"createInfo.flags need to have vk::DescriptorPoolCreateFlagBits::eFreeDesriptors set in order to allow destruction of VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::DescriptorSet which requires to return individual allocations to the pool\" );";
}
std::string dataDeclarations =
generateDataDeclarations( commandData, returnParams, vectorParams, {}, flavourFlags, true, dataTypes, dataType, returnType, returnVariable );
std::string vkType = commandData.params[returnParams.back()].type.type;
std::string callSequence =
generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, {}, {}, flavourFlags, true, true );
std::string resultCheck = generateResultCheckExpected( commandData.successCodes, className, commandName );
std::string returnStatements =
generateRAIIFactoryReturnStatements( commandData.params, commandData.successCodes, vulkanType, enumerating, returnType, returnVariable, singular );

std::string const definitionTemplate =
R"(
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::CreateReturnType<${returnType}>::Type ${className}::${commandName}( ${argumentList} ) const ${noexcept}
{
${specialAssertion}
${dataDeclarations}
${callSequence}
${resultCheck}
Expand All @@ -9317,7 +9325,8 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
{ "noexcept", noexceptString },
{ "resultCheck", resultCheck },
{ "returnStatements", returnStatements },
{ "returnType", returnType } } );
{ "returnType", returnType },
{ "specialAssertion", specialAssertion } } );
}
else
{
Expand Down Expand Up @@ -14793,7 +14802,7 @@ VulkanHppGenerator::RequireFeature VulkanHppGenerator::readRequireFeature( tinyx
checkElements( line, getChildElements( element ), {} );

std::vector<std::string> name;
std::string structure;
std::string structure;
for ( auto const & attribute : attributes )
{
if ( attribute.first == "name" )
Expand Down Expand Up @@ -14827,10 +14836,9 @@ VulkanHppGenerator::RequireFeature VulkanHppGenerator::readRequireFeature( tinyx
structIt = m_structs.find( aliasIt->second.name );
assert( structIt != m_structs.end() );
}
for (auto const& n : name)
for ( auto const & n : name )
{
auto memberIt =
std::find_if( structIt->second.members.begin(), structIt->second.members.end(), [&n]( MemberData const & md ) { return md.name == n; } );
auto memberIt = std::find_if( structIt->second.members.begin(), structIt->second.members.end(), [&n]( MemberData const & md ) { return md.name == n; } );
checkForError(
memberIt != structIt->second.members.end(), line, "required feature name <" + n + "> not part of the required feature struct <" + structure + ">" );
checkForError( ( memberIt->type.isValue() && ( memberIt->type.type == "VkBool32" ) ),
Expand Down
3 changes: 3 additions & 0 deletions vulkan/vulkan_raii.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13548,6 +13548,9 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE::Optional<const VULKAN_HPP_NAMESPACE::AllocationCallbacks> allocator ) const
VULKAN_HPP_RAII_CREATE_NOEXCEPT
{
VULKAN_HPP_ASSERT(
createInfo.flags & vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet &&
"createInfo.flags need to have vk::DescriptorPoolCreateFlagBits::eFreeDesriptors set in order to allow destruction of VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE::DescriptorSet which requires to return individual allocations to the pool" );
VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool;
VULKAN_HPP_NAMESPACE::Result result = static_cast<VULKAN_HPP_NAMESPACE::Result>( getDispatcher()->vkCreateDescriptorPool(
static_cast<VkDevice>( m_device ),
Expand Down

0 comments on commit eecf79d

Please sign in to comment.