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:
Andreas Süßenbach
2019-11-13 10:04:50 +01:00
committed by Markus Tavenrath
parent 661d2a9a7c
commit e850963599
4 changed files with 85 additions and 30 deletions

View File

@@ -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";
}
}