From 1a7e754609cf0c1faa44911ab97ed3344074cb70 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Thu, 22 Oct 2020 13:27:02 +0200 Subject: [PATCH] Correct size and pointer arguments for singular versions of a command --- VulkanHppGenerator.cpp | 33 +++++++++++++++++++++------------ vulkan/vulkan.hpp | 4 ++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 5fed85a..74dfb06 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -3696,7 +3696,8 @@ std::string VulkanHppGenerator::constructCallArgument( ParamData const & param, } else if ( enhanced && ( ( param.type.type == "Display" ) || ( param.type.type == "IDirectFB" ) ) ) { - // very special handling for type "Display" and "IDirectFB", which originally gets in as a pointer, but is mapped to a reference + // very special handling for type "Display" and "IDirectFB", which originally gets in as a pointer, but is mapped to + // a reference argument = "&" + param.name; } else @@ -3830,6 +3831,12 @@ std::string VulkanHppGenerator::constructCallArgumentsGetVector( std::string con std::map const & vectorParamIndices, bool singular ) const { + assert( !singular || + ( returnParamIndices.size() == 1 ) ); // for singular cases, we always return just one parameter! + + auto singularReturnVectorParamIt = vectorParamIndices.find( returnParamIndices[0] ); + assert( singularReturnVectorParamIt != vectorParamIndices.end() ); + std::string arguments; size_t i = 0; if ( !handle.empty() ) @@ -3841,11 +3848,11 @@ std::string VulkanHppGenerator::constructCallArgumentsGetVector( std::string con for ( ; i < params.size(); i++ ) { arguments += ", "; - auto vpiIt = vectorParamIndices.find( i ); - if ( ( std::find_if( returnParamIndices.begin(), - returnParamIndices.end(), - [&i]( size_t rpi ) { return i == rpi; } ) != returnParamIndices.end() ) || - ( vpiIt != vectorParamIndices.end() ) ) + auto vpiIt = vectorParamIndices.find( i ); + bool isReturnParam = ( std::find_if( returnParamIndices.begin(), returnParamIndices.end(), [&i]( size_t rpi ) { + return i == rpi; + } ) != returnParamIndices.end() ); + if ( isReturnParam || ( vpiIt != vectorParamIndices.end() ) ) { if ( vpiIt == vectorParamIndices.end() ) { @@ -3854,7 +3861,7 @@ std::string VulkanHppGenerator::constructCallArgumentsGetVector( std::string con } else { - if ( singular ) + if ( singular && ( vpiIt->second == singularReturnVectorParamIt->second ) ) { arguments += "reinterpret_cast<" + params[i].type.compose( false ) + ">( &" + stripPluralS( startLowerCase( stripPrefix( params[i].name, "p" ) ) ) + " )"; @@ -3874,12 +3881,12 @@ std::string VulkanHppGenerator::constructCallArgumentsGetVector( std::string con { auto lenIt = std::find_if( vectorParamIndices.begin(), vectorParamIndices.end(), - [&i]( std::pair const & vpi ) { return vpi.second == i; } ); + [&i]( std::pair const & vpi ) { return i == vpi.second; } ); if ( lenIt != vectorParamIndices.end() ) { - if ( singular ) + if ( singular && ( i == singularReturnVectorParamIt->second ) ) { - arguments += ( params[lenIt->first].type.type == "void" ) ? "sizeof( T )" : "1"; + arguments += ( params[singularReturnVectorParamIt->first].type.type == "void" ) ? "sizeof( T )" : "1"; } else if ( params[lenIt->second].type.isValue() ) { @@ -7401,9 +7408,11 @@ std::vector VulkanHppGenerator::determineConstPointerParamIndices( std:: for ( size_t i = 0; i < params.size(); i++ ) { - // very special handling for type Display and IDirectFB, which come in as non-const pointers, but are meant as const-pointers + // very special handling for type Display and IDirectFB, which come in as non-const pointers, but are meant as + // const-pointers if ( params[i].type.isConstPointer() || - ( params[i].type.isNonConstPointer() && ( ( params[i].type.type == "Display" ) || ( params[i].type.type == "IDirectFB" ) ) ) ) + ( params[i].type.isNonConstPointer() && + ( ( params[i].type.type == "Display" ) || ( params[i].type.type == "IDirectFB" ) ) ) ) { constPointerParamIndices.push_back( i ); } diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 6527424..9f00bc8 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -101874,8 +101874,8 @@ namespace VULKAN_HPP_NAMESPACE T data; Result result = static_cast( d.vkWriteAccelerationStructuresPropertiesKHR( m_device, - 1, - reinterpret_cast( &accelerationStructure ), + accelerationStructures.size(), + reinterpret_cast( accelerationStructures.data() ), static_cast( queryType ), sizeof( T ), reinterpret_cast( &data ),