mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2025-09-09 03:47:23 -04:00
Minor cleanup work.
This commit is contained in:
parent
159ef75b21
commit
a790cfecf2
@ -365,61 +365,36 @@ ${deviceCommandAssignments}
|
|||||||
|
|
||||||
std::string VulkanHppGenerator::generateDispatchLoaderStatic()
|
std::string VulkanHppGenerator::generateDispatchLoaderStatic()
|
||||||
{
|
{
|
||||||
std::string str = R"(
|
const std::string dispatchLoaderStaticTemplate = R"(
|
||||||
#if !defined( VK_NO_PROTOTYPES )
|
#if !defined( VK_NO_PROTOTYPES )
|
||||||
class DispatchLoaderStatic
|
class DispatchLoaderStatic
|
||||||
{
|
{
|
||||||
public:)";
|
public:
|
||||||
|
${commands}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
)";
|
||||||
|
|
||||||
|
std::string commands;
|
||||||
std::set<std::string> listedCommands;
|
std::set<std::string> listedCommands;
|
||||||
for ( auto const & feature : m_features )
|
for ( auto const & feature : m_features )
|
||||||
{
|
{
|
||||||
str += "\n //=== " + feature.first + " ===\n";
|
std::string header = "\n //=== " + feature.first + " ===\n";
|
||||||
for ( auto const & command : feature.second.commands )
|
commands += generateDispatchLoaderStaticCommands( feature.second.commands, listedCommands, header, "" );
|
||||||
{
|
|
||||||
assert( listedCommands.find( command ) == listedCommands.end() );
|
|
||||||
listedCommands.insert( command );
|
|
||||||
|
|
||||||
auto commandIt = m_commands.find( command );
|
|
||||||
assert( commandIt != m_commands.end() );
|
|
||||||
str += "\n";
|
|
||||||
appendStaticCommand( str, *commandIt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto const & extIt : m_extensionsByNumber )
|
for ( auto const & extIt : m_extensionsByNumber )
|
||||||
{
|
{
|
||||||
if ( !extIt.second->second.commands.empty() )
|
if ( !extIt.second->second.commands.empty() )
|
||||||
{
|
{
|
||||||
std::string firstCommandName = *extIt.second->second.commands.begin();
|
|
||||||
auto commandIt = m_commands.find( firstCommandName );
|
|
||||||
assert( commandIt != m_commands.end() );
|
|
||||||
std::string referencedIn = commandIt->second.referencedIn;
|
|
||||||
|
|
||||||
std::string enter, leave;
|
std::string enter, leave;
|
||||||
std::tie( enter, leave ) = generateProtection( referencedIn, std::string() );
|
std::tie( enter, leave ) = generateProtection( extIt.second->first, std::string() );
|
||||||
str += "\n" + enter + " //=== " + extIt.second->first + " ===\n";
|
std::string header = "\n" + enter + " //=== " + extIt.second->first + " ===\n";
|
||||||
for ( auto const & commandName : extIt.second->second.commands )
|
commands += generateDispatchLoaderStaticCommands( extIt.second->second.commands, listedCommands, header, leave );
|
||||||
{
|
|
||||||
// some commands are listed for multiple extensions !
|
|
||||||
if ( listedCommands.find( commandName ) == listedCommands.end() )
|
|
||||||
{
|
|
||||||
listedCommands.insert( commandName );
|
|
||||||
|
|
||||||
commandIt = m_commands.find( commandName );
|
|
||||||
assert( commandIt != m_commands.end() );
|
|
||||||
assert( commandIt->second.referencedIn == referencedIn );
|
|
||||||
|
|
||||||
str += "\n";
|
|
||||||
appendStaticCommand( str, *commandIt );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
str += leave;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str += " };\n#endif\n";
|
return replaceWithMap( dispatchLoaderStaticTemplate, { { "commands", commands } } );
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateEnums() const
|
std::string VulkanHppGenerator::generateEnums() const
|
||||||
@ -2694,35 +2669,6 @@ ${memberFunctionDeclarations}
|
|||||||
{ { "memberFunctionDeclarations", constructRAIIHandleMemberFunctionDeclarations( handle, specialFunctions ) } } );
|
{ { "memberFunctionDeclarations", constructRAIIHandleMemberFunctionDeclarations( handle, specialFunctions ) } } );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, std::string>
|
|
||||||
VulkanHppGenerator::appendStaticCommand( std::string & str, std::pair<std::string, CommandData> const & command )
|
|
||||||
{
|
|
||||||
std::string parameterList, parameters;
|
|
||||||
bool firstParam = true;
|
|
||||||
for ( auto param : command.second.params )
|
|
||||||
{
|
|
||||||
if ( !firstParam )
|
|
||||||
{
|
|
||||||
parameterList += ", ";
|
|
||||||
parameters += ", ";
|
|
||||||
}
|
|
||||||
parameterList += param.type.prefix + ( param.type.prefix.empty() ? "" : " " ) + param.type.type +
|
|
||||||
param.type.postfix + " " + param.name + generateCArraySizes( param.arraySizes );
|
|
||||||
parameters += param.name;
|
|
||||||
firstParam = false;
|
|
||||||
}
|
|
||||||
std::string commandName = stripPrefix( command.first, "vk" );
|
|
||||||
|
|
||||||
str += " " + command.second.returnType + " vk" + commandName + "( " + parameterList +
|
|
||||||
" ) const VULKAN_HPP_NOEXCEPT\n"
|
|
||||||
" {\n"
|
|
||||||
" return ::vk" +
|
|
||||||
commandName + "( " + parameters +
|
|
||||||
" );\n"
|
|
||||||
" }\n";
|
|
||||||
return std::make_pair( parameterList, parameters );
|
|
||||||
}
|
|
||||||
|
|
||||||
void VulkanHppGenerator::appendStruct( std::string & str, std::pair<std::string, StructureData> const & structure )
|
void VulkanHppGenerator::appendStruct( std::string & str, std::pair<std::string, StructureData> const & structure )
|
||||||
{
|
{
|
||||||
assert( m_listingTypes.find( structure.first ) == m_listingTypes.end() );
|
assert( m_listingTypes.find( structure.first ) == m_listingTypes.end() );
|
||||||
@ -11779,6 +11725,53 @@ std::string VulkanHppGenerator::generateDispatchLoaderDynamicCommandAssignment(
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VulkanHppGenerator::generateDispatchLoaderStaticCommands( std::vector<std::string> const & commands,
|
||||||
|
std::set<std::string> & listedCommands,
|
||||||
|
std::string const & header,
|
||||||
|
std::string const & leave ) const
|
||||||
|
{
|
||||||
|
std::string str;
|
||||||
|
for ( auto const & command : commands )
|
||||||
|
{
|
||||||
|
// some commands are listed for multiple extensions !
|
||||||
|
if ( listedCommands.find( command ) == listedCommands.end() )
|
||||||
|
{
|
||||||
|
listedCommands.insert( command );
|
||||||
|
|
||||||
|
auto commandIt = m_commands.find( command );
|
||||||
|
assert( commandIt != m_commands.end() );
|
||||||
|
|
||||||
|
str += "\n";
|
||||||
|
std::string parameterList, parameters;
|
||||||
|
assert( !commandIt->second.params.empty() );
|
||||||
|
for ( auto param : commandIt->second.params )
|
||||||
|
{
|
||||||
|
parameterList += param.type.prefix + ( param.type.prefix.empty() ? "" : " " ) + param.type.type +
|
||||||
|
param.type.postfix + " " + param.name + generateCArraySizes( param.arraySizes ) + ", ";
|
||||||
|
parameters += param.name + ", ";
|
||||||
|
}
|
||||||
|
assert( endsWith( parameterList, ", " ) && endsWith( parameters, ", " ) );
|
||||||
|
parameterList.resize( parameterList.size() - 2 );
|
||||||
|
parameters.resize( parameters.size() - 2 );
|
||||||
|
|
||||||
|
const std::string commandTemplate = R"(
|
||||||
|
${returnType} ${commandName}( ${parameterList} ) const VULKAN_HPP_NOEXCEPT
|
||||||
|
{
|
||||||
|
return ::${commandName}( ${parameters} );
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
str += replaceWithMap( commandTemplate,
|
||||||
|
{ { "commandName", commandIt->first },
|
||||||
|
{ "parameterList", parameterList },
|
||||||
|
{ "parameters", parameters },
|
||||||
|
{ "returnType", commandIt->second.returnType } } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert( !str.empty() );
|
||||||
|
return header + str + leave;
|
||||||
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateFunctionCall( std::string const & name,
|
std::string VulkanHppGenerator::generateFunctionCall( std::string const & name,
|
||||||
CommandData const & commandData,
|
CommandData const & commandData,
|
||||||
size_t returnParamIndex,
|
size_t returnParamIndex,
|
||||||
|
@ -381,8 +381,6 @@ private:
|
|||||||
void appendRAIIHandleContext( std::string & str,
|
void appendRAIIHandleContext( std::string & str,
|
||||||
std::pair<std::string, HandleData> const & handle,
|
std::pair<std::string, HandleData> const & handle,
|
||||||
std::set<std::string> const & specialFunctions ) const;
|
std::set<std::string> const & specialFunctions ) const;
|
||||||
std::pair<std::string, std::string> appendStaticCommand( std::string & str,
|
|
||||||
std::pair<std::string, CommandData> const & command );
|
|
||||||
void appendStruct( std::string & str, std::pair<std::string, StructureData> const & structure );
|
void appendStruct( std::string & str, std::pair<std::string, StructureData> const & structure );
|
||||||
void appendStructAssignmentOperators( std::string & str,
|
void appendStructAssignmentOperators( std::string & str,
|
||||||
std::pair<std::string, StructureData> const & structure,
|
std::pair<std::string, StructureData> const & structure,
|
||||||
@ -1061,6 +1059,10 @@ private:
|
|||||||
std::string generateDispatchLoaderDynamicCommandAssignment( std::string const & commandName,
|
std::string generateDispatchLoaderDynamicCommandAssignment( std::string const & commandName,
|
||||||
CommandData const & commandData,
|
CommandData const & commandData,
|
||||||
std::string const & firstArg ) const;
|
std::string const & firstArg ) const;
|
||||||
|
std::string generateDispatchLoaderStaticCommands( std::vector<std::string> const & commands,
|
||||||
|
std::set<std::string> & listedCommands,
|
||||||
|
std::string const & header,
|
||||||
|
std::string const & leave ) const;
|
||||||
std::string generateFunctionCall( std::string const & name,
|
std::string generateFunctionCall( std::string const & name,
|
||||||
CommandData const & commandData,
|
CommandData const & commandData,
|
||||||
size_t returnParamIndex,
|
size_t returnParamIndex,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user