mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Merge pull request #754 from asuessenbach/refactor
Refactor generation of simple commands with up to one vector parameter
This commit is contained in:
commit
2c1050518a
@ -1258,11 +1258,11 @@ void VulkanHppGenerator::appendCommand( std::string & str,
|
||||
appendCommandSimpleVoid( str, name, commandData, definition, vectorParamIndices );
|
||||
appendedFunction = true;
|
||||
}
|
||||
else if ( vectorParamIndices.empty() && ( commandData.returnType == "VkResult" ) &&
|
||||
( commandData.successCodes.size() == 1 ) )
|
||||
else if ( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) &&
|
||||
( vectorParamIndices.size() < 2 ) )
|
||||
{
|
||||
// returns VkResult, but there's just one success code
|
||||
appendCommandSimple( str, name, commandData, definition );
|
||||
appendCommandSimple( str, name, commandData, definition, vectorParamIndices );
|
||||
appendedFunction = true;
|
||||
}
|
||||
else if ( ( vectorParamIndices.size() == 2 ) && ( vectorParamIndices.begin()->second != INVALID_INDEX ) &&
|
||||
@ -1705,7 +1705,8 @@ ${leave})";
|
||||
void VulkanHppGenerator::appendCommandSimple( std::string & str,
|
||||
std::string const & name,
|
||||
CommandData const & commandData,
|
||||
bool definition ) const
|
||||
bool definition,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const
|
||||
{
|
||||
const std::string functionTemplate = R"(
|
||||
${enter}${commandStandard}${newlineOnDefinition}
|
||||
@ -1717,9 +1718,10 @@ ${leave})";
|
||||
std::string enter, leave;
|
||||
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
|
||||
|
||||
str += replaceWithMap( functionTemplate,
|
||||
str += replaceWithMap(
|
||||
functionTemplate,
|
||||
std::map<std::string, std::string>(
|
||||
{ { "commandEnhanced", constructCommandSimple( name, commandData, definition ) },
|
||||
{ { "commandEnhanced", constructCommandSimple( name, commandData, definition, vectorParamIndices ) },
|
||||
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
|
||||
{ "enter", enter },
|
||||
{ "leave", leave },
|
||||
@ -1771,7 +1773,7 @@ ${leave}
|
||||
|
||||
str += replaceWithMap( functionTemplate,
|
||||
std::map<std::string, std::string>(
|
||||
{ { "commandEnhanced", constructCommandSimple( name, commandData, definition ) },
|
||||
{ { "commandEnhanced", constructCommandSimple( name, commandData, definition, {} ) },
|
||||
{ "commandStandard", constructCommandStandard( name, commandData, definition ) },
|
||||
{ "enter", enter },
|
||||
{ "leave", leave } } ) );
|
||||
@ -3910,16 +3912,6 @@ std::string VulkanHppGenerator::constructCallArgument( ParamData const & param,
|
||||
return argument;
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::constructCallArguments( std::vector<ParamData> const & params, bool enhanced ) const
|
||||
{
|
||||
std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
|
||||
for ( size_t i = 1; i < params.size(); i++ )
|
||||
{
|
||||
arguments += ", " + constructCallArgument( params[i], enhanced );
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
std::string
|
||||
VulkanHppGenerator::constructCallArgumentsEnumerateVectors( std::vector<ParamData> const & params,
|
||||
std::map<size_t, size_t> const & vectorParamIndices,
|
||||
@ -4002,6 +3994,16 @@ std::string VulkanHppGenerator::constructCallArgumentsGetVector( std::vector<Par
|
||||
return arguments;
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::constructCallArgumentsStandard( std::vector<ParamData> const & params ) const
|
||||
{
|
||||
std::string arguments = "m_" + startLowerCase( stripPrefix( params[0].type.type, "Vk" ) );
|
||||
for ( size_t i = 1; i < params.size(); i++ )
|
||||
{
|
||||
arguments += ", " + constructCallArgument( params[i], false );
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
std::string
|
||||
VulkanHppGenerator::constructCallArgumentsVectors( std::vector<ParamData> const & params,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const
|
||||
@ -4498,11 +4500,21 @@ std::string VulkanHppGenerator::constructCommandGetVectorSingular( std::string c
|
||||
|
||||
std::string VulkanHppGenerator::constructCommandSimple( std::string const & name,
|
||||
CommandData const & commandData,
|
||||
bool definition ) const
|
||||
bool definition,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const
|
||||
{
|
||||
std::string str;
|
||||
|
||||
std::string argumentList = constructArgumentListEnhanced( commandData.params, { 0 }, definition, false );
|
||||
std::set<size_t> skippedParameters = { 0 };
|
||||
for ( auto const & vpi : vectorParamIndices )
|
||||
{
|
||||
if ( vpi.second != INVALID_INDEX )
|
||||
{
|
||||
skippedParameters.insert( vpi.second );
|
||||
}
|
||||
}
|
||||
|
||||
std::string argumentList = constructArgumentListEnhanced( commandData.params, skippedParameters, definition, false );
|
||||
std::string commandName = determineCommandName( name, commandData.params[0].type.type );
|
||||
std::string nodiscard = constructNoDiscardEnhanced( commandData );
|
||||
std::string returnType = constructReturnType( commandData, "void" );
|
||||
@ -4517,10 +4529,11 @@ std::string VulkanHppGenerator::constructCommandSimple( std::string const & name
|
||||
return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}" );
|
||||
})";
|
||||
|
||||
str = replaceWithMap(
|
||||
functionTemplate,
|
||||
std::map<std::string, std::string>( { { "argumentList", argumentList },
|
||||
{ "callArguments", constructCallArguments( commandData.params, true ) },
|
||||
str =
|
||||
replaceWithMap( functionTemplate,
|
||||
std::map<std::string, std::string>(
|
||||
{ { "argumentList", argumentList },
|
||||
{ "callArguments", constructCallArgumentsVectors( commandData.params, vectorParamIndices ) },
|
||||
{ "className", stripPrefix( commandData.handle, "Vk" ) },
|
||||
{ "commandName", commandName },
|
||||
{ "nodiscard", nodiscard },
|
||||
@ -4614,7 +4627,7 @@ std::string VulkanHppGenerator::constructCommandStandard( std::string const & na
|
||||
|
||||
if ( definition )
|
||||
{
|
||||
std::string functionBody = "d." + name + "( " + constructCallArguments( commandData.params, false ) + " )";
|
||||
std::string functionBody = "d." + name + "( " + constructCallArgumentsStandard( commandData.params ) + " )";
|
||||
if ( returnType != "void" )
|
||||
{
|
||||
functionBody = "return static_cast<" + returnType + ">( " + functionBody + " )";
|
||||
@ -4672,7 +4685,7 @@ std::string VulkanHppGenerator::constructCommandStandardVoid( std::string const
|
||||
str = replaceWithMap( functionTemplate,
|
||||
std::map<std::string, std::string>( {
|
||||
{ "argumentList", argumentList },
|
||||
{ "callArguments", constructCallArguments( commandData.params, false ) },
|
||||
{ "callArguments", constructCallArgumentsStandard( commandData.params ) },
|
||||
{ "className", stripPrefix( commandData.handle, "Vk" ) },
|
||||
{ "commandName", commandName },
|
||||
{ "vkCommand", name },
|
||||
|
@ -334,7 +334,8 @@ private:
|
||||
void appendCommandSimple( std::string & str,
|
||||
std::string const & name,
|
||||
CommandData const & commandData,
|
||||
bool definition ) const;
|
||||
bool definition,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const;
|
||||
void appendCommandSimpleVoid( std::string & str,
|
||||
std::string const & name,
|
||||
CommandData const & commandData,
|
||||
@ -539,13 +540,13 @@ private:
|
||||
std::set<size_t> const & skippedParams,
|
||||
bool definition ) const;
|
||||
std::string constructCallArgument( ParamData const & param, bool enhanced ) const;
|
||||
std::string constructCallArguments( std::vector<ParamData> const & params, bool enhanced ) const;
|
||||
std::string constructCallArgumentsEnumerateVectors( std::vector<ParamData> const & params,
|
||||
std::map<size_t, size_t> const & vectorParamIndices,
|
||||
bool vectorAsNullptr ) const;
|
||||
std::string constructCallArgumentsGetVector( std::vector<ParamData> const & params,
|
||||
std::pair<size_t, size_t> const & vectorParamIndices,
|
||||
bool singular ) const;
|
||||
std::string constructCallArgumentsStandard( std::vector<ParamData> const & params ) const;
|
||||
std::string constructCallArgumentsVectors( std::vector<ParamData> const & params,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const;
|
||||
std::string constructCommandEnumerateTwoVectors( std::string const & name,
|
||||
@ -575,8 +576,10 @@ private:
|
||||
CommandData const & commandData,
|
||||
std::map<size_t, size_t> const & vectorParamIndices,
|
||||
bool definition ) const;
|
||||
std::string
|
||||
constructCommandSimple( std::string const & name, CommandData const & commandData, bool definition ) const;
|
||||
std::string constructCommandSimple( std::string const & name,
|
||||
CommandData const & commandData,
|
||||
bool definition,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const;
|
||||
std::string constructCommandSimpleVoid( std::string const & name,
|
||||
CommandData const & commandData,
|
||||
bool definition,
|
||||
|
@ -47752,13 +47752,13 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
VULKAN_HPP_NODISCARD Result
|
||||
bindSparse( uint32_t bindInfoCount,
|
||||
const VULKAN_HPP_NAMESPACE::BindSparseInfo * pBindInfo,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
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>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<void>::type
|
||||
bindSparse( ArrayProxy<const VULKAN_HPP_NAMESPACE::BindSparseInfo> const & bindInfo,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
@ -47802,13 +47802,13 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
VULKAN_HPP_NODISCARD Result
|
||||
submit( uint32_t submitCount,
|
||||
const VULKAN_HPP_NAMESPACE::SubmitInfo * pSubmits,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
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>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<void>::type
|
||||
submit( ArrayProxy<const VULKAN_HPP_NAMESPACE::SubmitInfo> const & submits,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence,
|
||||
VULKAN_HPP_NAMESPACE::Fence fence VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
@ -55410,7 +55410,8 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
Result resetFences( uint32_t fenceCount,
|
||||
VULKAN_HPP_NODISCARD Result
|
||||
resetFences( uint32_t fenceCount,
|
||||
const VULKAN_HPP_NAMESPACE::Fence * pFences,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
@ -92216,6 +92217,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkBindAccelerationStructureMemoryKHR(
|
||||
m_device, bindInfoCount, reinterpret_cast<const VkBindAccelerationStructureMemoryInfoKHR *>( pBindInfos ) ) );
|
||||
}
|
||||
|
||||
# ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -92241,6 +92243,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkBindAccelerationStructureMemoryNV(
|
||||
m_device, bindInfoCount, reinterpret_cast<const VkBindAccelerationStructureMemoryInfoKHR *>( pBindInfos ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -92293,6 +92296,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkBindBufferMemory2(
|
||||
m_device, bindInfoCount, reinterpret_cast<const VkBindBufferMemoryInfo *>( pBindInfos ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -92314,6 +92318,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkBindBufferMemory2KHR(
|
||||
m_device, bindInfoCount, reinterpret_cast<const VkBindBufferMemoryInfo *>( pBindInfos ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -92363,6 +92368,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>(
|
||||
d.vkBindImageMemory2( m_device, bindInfoCount, reinterpret_cast<const VkBindImageMemoryInfo *>( pBindInfos ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -92384,6 +92390,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkBindImageMemory2KHR(
|
||||
m_device, bindInfoCount, reinterpret_cast<const VkBindImageMemoryInfo *>( pBindInfos ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -96389,6 +96396,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkFlushMappedMemoryRanges(
|
||||
m_device, memoryRangeCount, reinterpret_cast<const VkMappedMemoryRange *>( pMemoryRanges ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -96464,6 +96472,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
descriptorSetCount,
|
||||
reinterpret_cast<const VkDescriptorSet *>( pDescriptorSets ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -96492,6 +96501,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
descriptorSetCount,
|
||||
reinterpret_cast<const VkDescriptorSet *>( pDescriptorSets ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -99403,6 +99413,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkInvalidateMappedMemoryRanges(
|
||||
m_device, memoryRangeCount, reinterpret_cast<const VkMappedMemoryRange *>( pMemoryRanges ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -99462,6 +99473,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
srcCacheCount,
|
||||
reinterpret_cast<const VkPipelineCache *>( pSrcCaches ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -99491,6 +99503,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
srcCacheCount,
|
||||
reinterpret_cast<const VkValidationCacheEXT *>( pSrcCaches ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -99720,12 +99733,13 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_INLINE Result Device::resetFences( uint32_t fenceCount,
|
||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result Device::resetFences( uint32_t fenceCount,
|
||||
const VULKAN_HPP_NAMESPACE::Fence * pFences,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return static_cast<Result>( d.vkResetFences( m_device, fenceCount, reinterpret_cast<const VkFence *>( pFences ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -104657,6 +104671,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
reinterpret_cast<const VkBindSparseInfo *>( pBindInfo ),
|
||||
static_cast<VkFence>( fence ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
@ -104743,6 +104758,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return static_cast<Result>( d.vkQueueSubmit(
|
||||
m_queue, submitCount, reinterpret_cast<const VkSubmitInfo *>( pSubmits ), static_cast<VkFence>( fence ) ) );
|
||||
}
|
||||
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch>
|
||||
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type
|
||||
|
Loading…
Reference in New Issue
Block a user