Merge pull request #732 from asuessenbach/vkGetQueryPoolResults

correct enhanced version of vkGetQueryPoolResults
This commit is contained in:
Andreas Süßenbach 2020-09-03 16:01:08 +02:00 committed by GitHub
commit 8f09a023b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 191 additions and 75 deletions

View File

@ -1204,21 +1204,20 @@ void VulkanHppGenerator::appendCommand( std::string & str,
CommandData const & commandData,
bool definition ) const
{
if ( commandData.params.back().type.isNonConstPointer() && ( commandData.params.back().type.type == "void" ) &&
!commandData.params.back().len.empty() )
std::map<size_t, size_t> vectorParamIndices = determineVectorParamIndices( commandData.params );
if ( vectorParamIndices.size() == 1 )
{
std::string const & len = commandData.params.back().len;
auto lenIt = std::find_if(
commandData.params.begin(), commandData.params.end(), [&len]( ParamData const & pd ) { return pd.name == len; } );
if ( ( lenIt != commandData.params.end() ) && lenIt->type.isValue() )
auto vectorParamIndexIt = vectorParamIndices.begin();
if ( commandData.params[vectorParamIndexIt->first].type.isNonConstPointer() &&
( commandData.params[vectorParamIndexIt->first].type.type == "void" ) &&
commandData.params[vectorParamIndexIt->second].type.isValue() )
{
appendCommandFixedSizeVector( str, name, commandData, definition );
appendCommandFixedSizeVector( str, name, commandData, vectorParamIndices, definition );
return;
}
}
bool twoStep = isTwoStepAlgorithm( commandData.params );
std::map<size_t, size_t> vectorParamIndices = determineVectorParamIndices( commandData.params );
size_t returnParamIndex = determineReturnParamIndex( commandData, vectorParamIndices, twoStep );
bool isStructureChain =
@ -1468,21 +1467,29 @@ void VulkanHppGenerator::appendCommand( std::string & str,
void VulkanHppGenerator::appendCommandFixedSizeVector( std::string & str,
std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const
{
assert( commandData.returnType == "VkResult" );
assert( commandData.successCodes.size() == 1 );
assert( vectorParamIndices.size() == 1 );
std::map<size_t, size_t>::const_iterator vectorParamIndexIt = vectorParamIndices.begin();
std::map<size_t, size_t> vectorParamIndices = determineVectorParamIndices( commandData.params );
std::string enter, leave;
std::tie( enter, leave ) = generateProtection( commandData.feature, commandData.extensions );
size_t templateParamIndex = commandData.params.size() - 1;
assert( ( vectorParamIndices.size() == 1 ) &&
( vectorParamIndices.find( templateParamIndex ) != vectorParamIndices.end() ) );
std::string commandName = startLowerCase( stripPrefix( name, "vk" ) );
std::string commandNameSingular = stripPluralS( commandName );
std::string nodiscard =
( 1 < commandData.successCodes.size() )
? "VULKAN_HPP_NODISCARD "
: ( ( 1 < commandData.errorCodes.size() ) ? "VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS " : "" );
std::string returnType = ( 1 < commandData.successCodes.size() )
? "ResultValue<std::vector<T,Allocator>>"
: "typename ResultValueType<std::vector<T,Allocator>>::type";
std::string returnTypeDeprecated =
( 1 < commandData.successCodes.size() ) ? "Result" : "typename ResultValueType<void>::type";
std::string returnTypeSingular =
( 1 < commandData.successCodes.size() ) ? "ResultValue<T>" : "typename ResultValueType<T>::type";
if ( definition )
{
@ -1496,61 +1503,76 @@ ${enter} template <typename Dispatch>
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename T, typename Dispatch>
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it.")
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<void>::type ${className}::${commandName}( ${argumentListEnhancedDeprecated} ) const
${nodiscard}VULKAN_HPP_INLINE ${returnTypeDeprecated} ${className}::${commandName}( ${argumentListEnhancedDeprecated} ) const
{
${functionBodyEnhancedDeprecated}
}
template <typename T, typename Allocator, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<std::vector<T,Allocator>>::type ${className}::${commandName}( ${argumentListEnhanced} ) const
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentListEnhanced} ) const
{
VULKAN_HPP_ASSERT( ${dataSize} % sizeof( T ) == 0 );
std::vector<T,Allocator> ${dataName}( ${dataSize} / sizeof( T ) );
${functionCall}
return createResultValue( result, ${dataName}, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}" );
return createResultValue( result, ${dataName}, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}"${successCodeList} );
}
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<T>::type ${className}::${commandNameSingular}( ${argumentListEnhancedSingular} ) const
${nodiscard}VULKAN_HPP_INLINE ${returnTypeSingular} ${className}::${commandNameSingular}( ${argumentListEnhancedSingular} ) const
{
T ${dataName};
${functionCallSingular}
return createResultValue( result, ${dataName}, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}" );
return createResultValue( result, ${dataName}, VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}"${successCodeList} );
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave}
)";
std::string functionCall = constructFunctionBodyEnhancedSingleStep(
" ", name, commandData, templateParamIndex, templateParamIndex, vectorParamIndices, false );
" ", name, commandData, vectorParamIndexIt->first, vectorParamIndexIt->first, vectorParamIndices, false );
std::string functionCallSingular = constructFunctionBodyEnhancedSingleStep(
" ", name, commandData, templateParamIndex, templateParamIndex, vectorParamIndices, true );
" ", name, commandData, vectorParamIndexIt->first, vectorParamIndexIt->first, vectorParamIndices, true );
std::string successCodeList;
if ( 1 < commandData.successCodes.size() )
{
successCodeList = ", { Result::" + createSuccessCode( commandData.successCodes[0], m_tags );
for ( size_t i = 1; i < commandData.successCodes.size(); ++i )
{
successCodeList += ", Result::" + createSuccessCode( commandData.successCodes[i], m_tags );
}
successCodeList += " }";
}
str += replaceWithMap(
functionTemplate,
std::map<std::string, std::string>(
{ { "argumentListEnhanced",
constructFunctionHeaderArgumentsEnhanced(
commandData, templateParamIndex, templateParamIndex, {}, false, false, false ) },
commandData, vectorParamIndexIt->first, vectorParamIndexIt->first, {}, false, false, false ) },
{ "argumentListEnhancedDeprecated",
constructFunctionHeaderArgumentsEnhanced(
commandData, INVALID_INDEX, templateParamIndex, vectorParamIndices, false, false, false ) },
commandData, INVALID_INDEX, vectorParamIndexIt->first, vectorParamIndices, false, false, false ) },
{ "argumentListEnhancedSingular",
constructFunctionHeaderArgumentsEnhanced(
commandData, templateParamIndex, templateParamIndex, vectorParamIndices, true, false, false ) },
constructFunctionHeaderArgumentsEnhanced( commandData,
vectorParamIndexIt->first,
vectorParamIndexIt->first,
vectorParamIndices,
true,
false,
false ) },
{ "argumentListStandard", constructFunctionHeaderArgumentsStandard( commandData, false ) },
{ "className", stripPrefix( commandData.handle, "Vk" ) },
{ "commandName", commandName },
{ "commandNameSingular", commandNameSingular },
{ "dataName", startLowerCase( stripPrefix( commandData.params[templateParamIndex].name, "p" ) ) },
{ "dataSize", commandData.params[templateParamIndex].len },
{ "dataName", startLowerCase( stripPrefix( commandData.params[vectorParamIndexIt->first].name, "p" ) ) },
{ "dataSize", commandData.params[vectorParamIndexIt->first].len },
{ "enter", enter },
{ "functionBodyEnhancedDeprecated",
constructFunctionBodyEnhanced( " ",
name,
commandData,
INVALID_INDEX,
templateParamIndex,
vectorParamIndexIt->first,
vectorParamIndices,
false,
"void",
@ -1562,6 +1584,11 @@ ${leave}
{ "functionCall", functionCall },
{ "functionCallSingular", functionCallSingular },
{ "leave", leave },
{ "nodiscard", nodiscard },
{ "successCodeList", successCodeList },
{ "returnType", returnType },
{ "returnTypeDeprecated", returnTypeDeprecated },
{ "returnTypeSingular", returnTypeSingular },
{ "vkCommandName", name } } ) );
}
else
@ -1571,11 +1598,11 @@ ${enter} template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD Result ${commandName}( ${argumentListStandard} ) const VULKAN_HPP_NOEXCEPT;
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<void>::type ${commandName}( ${argumentListEnhancedDeprecated} ) const;
${nodiscard}${returnTypeDeprecated} ${commandName}( ${argumentListEnhancedDeprecated} ) const;
template <typename T, typename Allocator = std::allocator<T>, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<std::vector<T,Allocator>>::type ${commandName}( ${argumentListEnhanced} ) const;
${nodiscard}${returnType} ${commandName}( ${argumentListEnhanced} ) const;
template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<T>::type ${commandNameSingular}( ${argumentListEnhancedSingular} ) const;
${nodiscard}${returnTypeSingular} ${commandNameSingular}( ${argumentListEnhancedSingular} ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
${leave}
)";
@ -1585,18 +1612,27 @@ ${leave}
std::map<std::string, std::string>(
{ { "argumentListEnhanced",
constructFunctionHeaderArgumentsEnhanced(
commandData, templateParamIndex, templateParamIndex, {}, false, true, false ) },
commandData, vectorParamIndexIt->first, vectorParamIndexIt->first, {}, false, true, false ) },
{ "argumentListEnhancedDeprecated",
constructFunctionHeaderArgumentsEnhanced(
commandData, INVALID_INDEX, templateParamIndex, vectorParamIndices, false, true, false ) },
commandData, INVALID_INDEX, vectorParamIndexIt->first, vectorParamIndices, false, true, false ) },
{ "argumentListEnhancedSingular",
constructFunctionHeaderArgumentsEnhanced(
commandData, templateParamIndex, templateParamIndex, vectorParamIndices, true, true, false ) },
constructFunctionHeaderArgumentsEnhanced( commandData,
vectorParamIndexIt->first,
vectorParamIndexIt->first,
vectorParamIndices,
true,
true,
false ) },
{ "argumentListStandard", constructFunctionHeaderArgumentsStandard( commandData, true ) },
{ "commandName", commandName },
{ "commandNameSingular", commandNameSingular },
{ "enter", enter },
{ "leave", leave } } ) );
{ "leave", leave },
{ "nodiscard", nodiscard },
{ "returnType", returnType },
{ "returnTypeDeprecated", returnTypeDeprecated },
{ "returnTypeSingular", returnTypeSingular } } ) );
}
if ( !commandData.aliasData.empty() )
@ -1608,7 +1644,7 @@ ${leave}
aliasCommandData.extensions = ad.second.extensions;
aliasCommandData.feature = ad.second.feature;
aliasCommandData.xmlLine = ad.second.xmlLine;
appendCommandFixedSizeVector( str, ad.first, aliasCommandData, definition );
appendCommandFixedSizeVector( str, ad.first, aliasCommandData, vectorParamIndices, definition );
}
}
}

View File

@ -314,6 +314,7 @@ private:
void appendCommandFixedSizeVector( std::string & str,
std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
void appendDispatchLoaderDynamicCommand( std::string & str,
std::string & emptyFunctions,

View File

@ -202,14 +202,14 @@ int main( int /*argc*/, char ** /*argv*/ )
graphicsQueue.waitIdle();
uint64_t samplesPassed[2];
vk::Result result = device->getQueryPoolResults( queryPool.get(),
vk::ResultValue<std::vector<uint64_t>> rv =
device->getQueryPoolResults<uint64_t>( *queryPool,
0,
2,
vk::ArrayProxy<uint64_t>( 4, samplesPassed ),
2 * sizeof( uint64_t ),
sizeof( uint64_t ),
vk::QueryResultFlagBits::e64 | vk::QueryResultFlagBits::eWait );
switch ( result )
switch ( rv.result )
{
case vk::Result::eSuccess: break;
case vk::Result::eNotReady: std::cout << "vk::Device::getQueryPoolResults returned vk::Result::eNotReady !\n";
@ -217,8 +217,8 @@ int main( int /*argc*/, char ** /*argv*/ )
}
std::cout << "vkGetQueryPoolResults data\n";
std::cout << "samples_passed[0] = " << samplesPassed[0] << "\n";
std::cout << "samples_passed[1] = " << samplesPassed[1] << "\n";
std::cout << "samples_passed[0] = " << rv.value[0] << "\n";
std::cout << "samples_passed[1] = " << rv.value[1] << "\n";
/* Read back query result from buffer */
uint64_t * samplesPassedPtr = static_cast<uint64_t *>(
@ -233,7 +233,7 @@ int main( int /*argc*/, char ** /*argv*/ )
while ( vk::Result::eTimeout == device->waitForFences( drawFence.get(), VK_TRUE, vk::su::FenceTimeout ) )
;
result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, currentBuffer.value ) );
vk::Result result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, currentBuffer.value ) );
switch ( result )
{
case vk::Result::eSuccess: break;

View File

@ -53721,6 +53721,25 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE::DeviceSize stride,
VULKAN_HPP_NAMESPACE::QueryResultFlags flags,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename T,
typename Allocator = std::allocator<T>,
typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD ResultValue<std::vector<T, Allocator>>
getQueryPoolResults( VULKAN_HPP_NAMESPACE::QueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
VULKAN_HPP_NAMESPACE::DeviceSize stride,
VULKAN_HPP_NAMESPACE::QueryResultFlags flags,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
template <typename T, typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD ResultValue<T>
getQueryPoolResult( VULKAN_HPP_NAMESPACE::QueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount,
VULKAN_HPP_NAMESPACE::DeviceSize stride,
VULKAN_HPP_NAMESPACE::QueryResultFlags flags,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#ifdef VK_ENABLE_BETA_EXTENSIONS
@ -95606,7 +95625,7 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<T>::type
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<T>::type
Device::getAccelerationStructureHandleNV( VULKAN_HPP_NAMESPACE::AccelerationStructureKHR accelerationStructure,
Dispatch const & d ) const
{
@ -97519,10 +97538,12 @@ namespace VULKAN_HPP_NAMESPACE
static_cast<VkDeviceSize>( stride ),
static_cast<VkQueryResultFlags>( flags ) ) );
}
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result
Device::getQueryPoolResults( VULKAN_HPP_NAMESPACE::QueryPool queryPool,
VULKAN_HPP_DEPRECATED( "This function is deprecated. Use one of the other flavours of it." )
VULKAN_HPP_NODISCARD
VULKAN_HPP_INLINE Result Device::getQueryPoolResults( VULKAN_HPP_NAMESPACE::QueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount,
ArrayProxy<T> const & data,
@ -97541,6 +97562,58 @@ namespace VULKAN_HPP_NAMESPACE
return createResultValue(
result, VULKAN_HPP_NAMESPACE_STRING "::Device::getQueryPoolResults", { Result::eSuccess, Result::eNotReady } );
}
template <typename T, typename Allocator, typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ResultValue<std::vector<T, Allocator>>
Device::getQueryPoolResults( VULKAN_HPP_NAMESPACE::QueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
VULKAN_HPP_NAMESPACE::DeviceSize stride,
VULKAN_HPP_NAMESPACE::QueryResultFlags flags,
Dispatch const & d ) const
{
VULKAN_HPP_ASSERT( dataSize % sizeof( T ) == 0 );
std::vector<T, Allocator> data( dataSize / sizeof( T ) );
Result result = static_cast<Result>( d.vkGetQueryPoolResults( m_device,
static_cast<VkQueryPool>( queryPool ),
firstQuery,
queryCount,
data.size() * sizeof( T ),
reinterpret_cast<void *>( data.data() ),
static_cast<VkDeviceSize>( stride ),
static_cast<VkQueryResultFlags>( flags ) ) );
return createResultValue( result,
data,
VULKAN_HPP_NAMESPACE_STRING "::Device::getQueryPoolResults",
{ Result::eSuccess, Result::eNotReady } );
}
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ResultValue<T>
Device::getQueryPoolResult( VULKAN_HPP_NAMESPACE::QueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount,
VULKAN_HPP_NAMESPACE::DeviceSize stride,
VULKAN_HPP_NAMESPACE::QueryResultFlags flags,
Dispatch const & d ) const
{
T data;
Result result = static_cast<Result>( d.vkGetQueryPoolResults( m_device,
static_cast<VkQueryPool>( queryPool ),
firstQuery,
queryCount,
1 * sizeof( T ),
reinterpret_cast<void *>( &data ),
static_cast<VkDeviceSize>( stride ),
static_cast<VkQueryResultFlags>( flags ) ) );
return createResultValue( result,
data,
VULKAN_HPP_NAMESPACE_STRING "::Device::getQueryPoolResults",
{ Result::eSuccess, Result::eNotReady } );
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#ifdef VK_ENABLE_BETA_EXTENSIONS
@ -97602,7 +97675,7 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<T>::type
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<T>::type
Device::getRayTracingCaptureReplayShaderGroupHandleKHR( VULKAN_HPP_NAMESPACE::Pipeline pipeline,
uint32_t firstGroup,
uint32_t groupCount,
@ -97681,8 +97754,11 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<T>::type Device::getRayTracingShaderGroupHandleKHR(
VULKAN_HPP_NAMESPACE::Pipeline pipeline, uint32_t firstGroup, uint32_t groupCount, Dispatch const & d ) const
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<T>::type
Device::getRayTracingShaderGroupHandleKHR( VULKAN_HPP_NAMESPACE::Pipeline pipeline,
uint32_t firstGroup,
uint32_t groupCount,
Dispatch const & d ) const
{
T data;
Result result = static_cast<Result>( d.vkGetRayTracingShaderGroupHandlesKHR( m_device,
@ -97754,8 +97830,11 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename T, typename Dispatch>
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS typename ResultValueType<T>::type Device::getRayTracingShaderGroupHandleNV(
VULKAN_HPP_NAMESPACE::Pipeline pipeline, uint32_t firstGroup, uint32_t groupCount, Dispatch const & d ) const
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS VULKAN_HPP_INLINE typename ResultValueType<T>::type
Device::getRayTracingShaderGroupHandleNV( VULKAN_HPP_NAMESPACE::Pipeline pipeline,
uint32_t firstGroup,
uint32_t groupCount,
Dispatch const & d ) const
{
T data;
Result result = static_cast<Result>( d.vkGetRayTracingShaderGroupHandlesNV( m_device,