mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-10 06:30:08 +00:00
Extend functions returning a std::vector<vk::StructureChain> to use an additional local vector for getting the information, and then copy the heads of the StructureChains over to the return vector (#432)
Fixes #400
This commit is contained in:
parent
661d2a9a7c
commit
e850963599
@ -1479,6 +1479,10 @@ void VulkanHppGenerator::appendFunctionBodyEnhanced(std::string & str, std::stri
|
||||
{
|
||||
appendFunctionBodyEnhancedVectorOfUniqueHandles(str, indentation, commandName, commandData, returnParamIndex, templateParamIndex, vectorParamIndices, twoStep, singular, withAllocator);
|
||||
}
|
||||
else if (isStructureChain && (vectorParamIndices.find(returnParamIndex) != vectorParamIndices.end()))
|
||||
{
|
||||
appendFunctionBodyEnhancedVectorOfStructureChain(str, indentation, commandData, returnParamIndex, vectorParamIndices, withAllocator);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (1 < vectorParamIndices.size())
|
||||
@ -1775,6 +1779,46 @@ ${i} ${call2};
|
||||
});
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::appendFunctionBodyEnhancedVectorOfStructureChain(std::string & str, std::string const& indentation, std::pair<std::string,CommandData> const& commandData, size_t returnParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool withAllocator) const
|
||||
{
|
||||
std::string const stringTemplate =
|
||||
R"(${i} std::vector<StructureChain,Allocator> ${returnName}${vectorAllocator};
|
||||
${i} uint32_t ${sizeName};
|
||||
${i} d.${commandName}( m_${handleName}, &${sizeName}, nullptr );
|
||||
${i} ${returnName}.resize( ${sizeName} );
|
||||
${i} std::vector<vk::${returnType}> localVector( ${sizeName} );
|
||||
${i} for ( uint32_t i = 0; i < ${sizeName} ; i++ )
|
||||
${i} {
|
||||
${i} localVector[i].pNext = ${returnName}[i].template get<vk::${returnType}>().pNext;
|
||||
${i} }
|
||||
${i} d.${commandName}( m_${handleName}, &${sizeName}, reinterpret_cast<${VkReturnType}*>( localVector.data() ) );
|
||||
${i} for ( uint32_t i = 0; i < ${sizeName} ; i++ )
|
||||
${i} {
|
||||
${i} ${returnName}[i].template get<vk::${returnType}>() = localVector[i];
|
||||
${i} }
|
||||
${i} return ${returnName};
|
||||
)";
|
||||
|
||||
// local count variable to hold the size of the vector to fill
|
||||
std::map<size_t, size_t>::const_iterator returnit = vectorParamIndices.find(returnParamIndex);
|
||||
assert(returnit != vectorParamIndices.end() && (returnit->second != INVALID_INDEX));
|
||||
|
||||
assert(m_commandToHandle.find(commandData.first)->second == commandData.second.params[0].type.type); // make sure, the first argument is the handle
|
||||
assert(commandData.second.params.size() == 3); // make sure, there are three args: the handle, the pointer to size, and the data pointer
|
||||
|
||||
str += replaceWithMap(stringTemplate,
|
||||
{
|
||||
{ "commandName", commandData.first},
|
||||
{ "handleName", startLowerCase(stripPrefix(commandData.second.params[0].type.type, "Vk")) },
|
||||
{ "i", indentation },
|
||||
{ "returnName", startLowerCase(stripPrefix(commandData.second.params[returnParamIndex].name, "p")) },
|
||||
{ "returnType", stripPrefix(commandData.second.params[returnParamIndex].type.type, "Vk")},
|
||||
{ "sizeName", startLowerCase(stripPrefix(commandData.second.params[returnit->second].name, "p"))},
|
||||
{ "vectorAllocator", withAllocator ? "( vectorAllocator )" : "" },
|
||||
{ "VkReturnType", commandData.second.params[returnParamIndex].type.type}
|
||||
});
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::appendFunctionBodyEnhancedVectorOfUniqueHandles(std::string & str, std::string const& indentation, std::string const& commandName, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool twoStep, bool singular, bool withAllocator) const
|
||||
{
|
||||
std::string const stringTemplate =
|
||||
|
@ -176,6 +176,7 @@ class VulkanHppGenerator
|
||||
void appendFunctionBodyEnhancedReturnResultValue(std::string & str, std::string const& indentation, std::string const& returnName, std::string const& commandName, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, bool twoStep, bool singular, bool unique) const;
|
||||
void appendFunctionBodyEnhancedSingleStep(std::string & str, std::string const& indentation, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool singular) const;
|
||||
void appendFunctionBodyEnhancedTwoStep(std::string & str, std::string const& indentation, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool singular, std::string const& returnName) const;
|
||||
void appendFunctionBodyEnhancedVectorOfStructureChain(std::string & str, std::string const& indentation, std::pair<std::string,CommandData> const& commandData, size_t returnParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool withAllocator) const;
|
||||
void appendFunctionBodyEnhancedVectorOfUniqueHandles(std::string & str, std::string const& indentation, std::string const& commandName, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool twoStep, bool singular, bool withAllocator) const;
|
||||
void appendFunctionBodyStandard(std::string & str, std::string const& indentation, std::pair<std::string, CommandData> const& commandData) const;
|
||||
void appendFunctionBodyStandardArgument(std::string & str, TypeData const& typeData, std::string const& name) const;
|
||||
|
@ -24,8 +24,6 @@
|
||||
static char const* AppName = "PhysicalDeviceQueueFamilyProperties";
|
||||
static char const* EngineName = "Vulkan.hpp";
|
||||
|
||||
#define USE_WORKAROUND 1
|
||||
|
||||
int main(int /*argc*/, char ** /*argv*/)
|
||||
{
|
||||
try
|
||||
@ -48,29 +46,13 @@ int main(int /*argc*/, char ** /*argv*/)
|
||||
|
||||
std::cout << "PhysicalDevice " << i << "\n";
|
||||
|
||||
#if USE_WORKAROUND
|
||||
uint32_t queueFamilyPropertyCount;
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.vkGetPhysicalDeviceQueueFamilyProperties2(physicalDevices[i], &queueFamilyPropertyCount, nullptr);
|
||||
std::vector<vk::QueueFamilyProperties2> queueFamilyProperties2(queueFamilyPropertyCount);
|
||||
std::vector<vk::QueueFamilyCheckpointPropertiesNV> queueFamilyCheckpointProperties(queueFamilyPropertyCount);
|
||||
for (uint32_t j=0 ; j<queueFamilyPropertyCount ; j++)
|
||||
{
|
||||
queueFamilyProperties2[j].pNext = &queueFamilyCheckpointProperties[j];
|
||||
}
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.vkGetPhysicalDeviceQueueFamilyProperties2(physicalDevices[i], &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>(queueFamilyProperties2.data()));
|
||||
#else
|
||||
// need to explicitly specify all the template arguments for getQueueFamilyProperties2 to make the compiler happy
|
||||
using Chain = vk::StructureChain<vk::QueueFamilyProperties2, vk::QueueFamilyCheckpointPropertiesNV>;
|
||||
auto queueFamilyProperties2 = physicalDevices[i].getQueueFamilyProperties2<Chain, std::allocator<Chain>, vk::DispatchLoaderDynamic>();
|
||||
#endif
|
||||
for (size_t j = 0; j < queueFamilyProperties2.size(); j++)
|
||||
{
|
||||
std::cout << "\t" << "QueueFamily " << j << "\n";
|
||||
#if USE_WORKAROUND
|
||||
vk::QueueFamilyProperties const& properties = queueFamilyProperties2[j].queueFamilyProperties;
|
||||
#else
|
||||
vk::QueueFamilyProperties const& properties = queueFamilyProperties2[j].get<vk::QueueFamilyProperties2>().queueFamilyProperties;
|
||||
#endif
|
||||
std::cout << "\t\t" << "QueueFamilyProperties:\n";
|
||||
std::cout << "\t\t\t" << "queueFlags = " << vk::to_string(properties.queueFlags) << "\n";
|
||||
std::cout << "\t\t\t" << "queueCount = " << properties.queueCount << "\n";
|
||||
@ -80,17 +62,9 @@ int main(int /*argc*/, char ** /*argv*/)
|
||||
|
||||
if (vk::su::contains(extensionProperties, "VK_NV_device_diagnostic_checkpoints"))
|
||||
{
|
||||
#if USE_WORKAROUND
|
||||
vk::QueueFamilyCheckpointPropertiesNV const* checkpointProperties = static_cast<vk::QueueFamilyCheckpointPropertiesNV const*>(queueFamilyProperties2[j].pNext);
|
||||
#else
|
||||
vk::QueueFamilyCheckpointPropertiesNV const& checkpointProperties = queueFamilyProperties2[j].get<vk::QueueFamilyCheckpointPropertiesNV>();
|
||||
#endif
|
||||
std::cout << "\t\t" << "CheckPointPropertiesNV:\n";
|
||||
#if USE_WORKAROUND
|
||||
std::cout << "\t\t\t" << "checkpointExecutionStageMask = " << vk::to_string(checkpointProperties->checkpointExecutionStageMask) << "\n";
|
||||
#else
|
||||
std::cout << "\t\t\t" << "checkpointExecutionStageMask = " << vk::to_string(checkpointProperties.checkpointExecutionStageMask) << "\n";
|
||||
#endif
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -65829,7 +65829,16 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
uint32_t queueFamilyPropertyCount;
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2( m_physicalDevice, &queueFamilyPropertyCount, nullptr );
|
||||
queueFamilyProperties.resize( queueFamilyPropertyCount );
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( queueFamilyProperties.data() ) );
|
||||
std::vector<vk::QueueFamilyProperties2> localVector( queueFamilyPropertyCount );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
localVector[i].pNext = queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>().pNext;
|
||||
}
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( localVector.data() ) );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>() = localVector[i];
|
||||
}
|
||||
return queueFamilyProperties;
|
||||
}
|
||||
template<typename StructureChain, typename Allocator, typename Dispatch>
|
||||
@ -65839,7 +65848,16 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
uint32_t queueFamilyPropertyCount;
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2( m_physicalDevice, &queueFamilyPropertyCount, nullptr );
|
||||
queueFamilyProperties.resize( queueFamilyPropertyCount );
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( queueFamilyProperties.data() ) );
|
||||
std::vector<vk::QueueFamilyProperties2> localVector( queueFamilyPropertyCount );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
localVector[i].pNext = queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>().pNext;
|
||||
}
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( localVector.data() ) );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>() = localVector[i];
|
||||
}
|
||||
return queueFamilyProperties;
|
||||
}
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
@ -65877,7 +65895,16 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
uint32_t queueFamilyPropertyCount;
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2KHR( m_physicalDevice, &queueFamilyPropertyCount, nullptr );
|
||||
queueFamilyProperties.resize( queueFamilyPropertyCount );
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2KHR( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( queueFamilyProperties.data() ) );
|
||||
std::vector<vk::QueueFamilyProperties2> localVector( queueFamilyPropertyCount );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
localVector[i].pNext = queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>().pNext;
|
||||
}
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2KHR( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( localVector.data() ) );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>() = localVector[i];
|
||||
}
|
||||
return queueFamilyProperties;
|
||||
}
|
||||
template<typename StructureChain, typename Allocator, typename Dispatch>
|
||||
@ -65887,7 +65914,16 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
uint32_t queueFamilyPropertyCount;
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2KHR( m_physicalDevice, &queueFamilyPropertyCount, nullptr );
|
||||
queueFamilyProperties.resize( queueFamilyPropertyCount );
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2KHR( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( queueFamilyProperties.data() ) );
|
||||
std::vector<vk::QueueFamilyProperties2> localVector( queueFamilyPropertyCount );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
localVector[i].pNext = queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>().pNext;
|
||||
}
|
||||
d.vkGetPhysicalDeviceQueueFamilyProperties2KHR( m_physicalDevice, &queueFamilyPropertyCount, reinterpret_cast<VkQueueFamilyProperties2*>( localVector.data() ) );
|
||||
for ( uint32_t i = 0; i < queueFamilyPropertyCount ; i++ )
|
||||
{
|
||||
queueFamilyProperties[i].template get<vk::QueueFamilyProperties2>() = localVector[i];
|
||||
}
|
||||
return queueFamilyProperties;
|
||||
}
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
Loading…
Reference in New Issue
Block a user