From 3e8964e181a4ec77b63f07cd8d23285ef6ac1abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Wed, 30 Mar 2016 12:18:19 +0200 Subject: [PATCH] Changed functions that could return eIncomplete to loop while incomplete and return the final result. --- VkCppGenerator.cpp | 186 ++++++++++++++++----------- vulkan/vk_cpp.h | 311 ++++++++++++++++++++++++++------------------- 2 files changed, 292 insertions(+), 205 deletions(-) diff --git a/VkCppGenerator.cpp b/VkCppGenerator.cpp index cf51cc2..fb6750e 100644 --- a/VkCppGenerator.cpp +++ b/VkCppGenerator.cpp @@ -510,7 +510,13 @@ std::string determineFunctionName(std::string const& name, CommandData const& co std::string determineReturnType(CommandData const& commandData, size_t returnIndex, bool isVector) { std::string returnType; - if ((returnIndex != ~0) && ((commandData.returnType == "void") || ((commandData.returnType == "Result") && (commandData.successCodes.size() < 2)))) + if ( (returnIndex != ~0) + && ( (commandData.returnType == "void") + || ( (commandData.returnType == "Result") + && ( (commandData.successCodes.size() == 1) + || ( (commandData.successCodes.size() == 2) + && (commandData.successCodes[1] == "eIncomplete") + && commandData.twoStep))))) { if (isVector) { @@ -1735,7 +1741,7 @@ void writeFunctionBody(std::ofstream & ofs, std::string const& indentation, std: } // write the local variable to hold a returned value - if ((returnIndex != ~0) && (((commandData.returnType == "Result") && (commandData.successCodes.size() < 2)) || (commandData.returnType == "void"))) + if ((returnIndex != ~0) && (commandData.returnType != returnType)) { ofs << indentation << " " << returnType << " " << reduceName(commandData.arguments[returnIndex].name); @@ -1782,12 +1788,23 @@ void writeFunctionBody(std::ofstream & ofs, std::string const& indentation, std: // write the function call ofs << indentation << " "; + std::string localIndentation = " "; if (commandData.returnType == "Result") { - ofs << "Result result = static_cast( "; + ofs << "Result result"; + if (commandData.twoStep && (1 < commandData.successCodes.size())) + { + ofs << ";" << std::endl + << indentation << " do" << std::endl + << indentation << " {" << std::endl + << indentation << " result"; + localIndentation += " "; + } + ofs << " = static_cast( "; } else if (commandData.returnType != "void") { + assert(!commandData.twoStep); ofs << "return "; } writeCall(ofs, dependencyData.name, templateIndex, commandData, vkTypes, vectorParameters, returnIndex, true); @@ -1797,24 +1814,32 @@ void writeFunctionBody(std::ofstream & ofs, std::string const& indentation, std: } ofs << ";" << std::endl; - // add an exception check - if ((commandData.returnType == "Result") || !commandData.successCodes.empty()) - { - writeExceptionCheck(ofs, indentation, className, functionName, commandData.successCodes); - } - if (commandData.twoStep) { std::map::const_iterator returnit = vectorParameters.find(returnIndex); - // resize the vector to hold the data according to the result from the first call - ofs << indentation << " " << reduceName(commandData.arguments[returnit->first].name) << ".resize( " << reduceName(commandData.arguments[returnit->second].name) << " );" << std::endl; - - // write the function call a second time - ofs << indentation << " "; if (commandData.returnType == "Result") { - ofs << "result = static_cast( "; + ofs << indentation << localIndentation << "if ( ( result == Result::eSuccess ) && " << reduceName(commandData.arguments[returnit->second].name) << " )" << std::endl + << indentation << localIndentation << "{" << std::endl + << indentation << localIndentation << " "; + } + else + { + ofs << indentation << " "; + } + + // resize the vector to hold the data according to the result from the first call + ofs << reduceName(commandData.arguments[returnit->first].name) << ".resize( " << reduceName(commandData.arguments[returnit->second].name) << " );" << std::endl; + + // write the function call a second time + if (commandData.returnType == "Result") + { + ofs << indentation << localIndentation << " result = static_cast( "; + } + else + { + ofs << indentation << " "; } writeCall(ofs, dependencyData.name, templateIndex, commandData, vkTypes, vectorParameters, returnIndex, false); if (commandData.returnType == "Result") @@ -1822,16 +1847,23 @@ void writeFunctionBody(std::ofstream & ofs, std::string const& indentation, std: ofs << " )"; } ofs << ";" << std::endl; - - // add a second exception check - if ((commandData.returnType == "Result") || !commandData.successCodes.empty()) + if (commandData.returnType == "Result") { - writeExceptionCheck(ofs, indentation, className, functionName, commandData.successCodes); + ofs << indentation << localIndentation << "}" << std::endl; + if (1 < commandData.successCodes.size()) + { + ofs << indentation << " } while ( result == Result::eIncomplete );" << std::endl; + } + writeExceptionCheck(ofs, indentation, className, functionName, {"eSuccess"}); } } + else if ((commandData.returnType == "Result") || !commandData.successCodes.empty()) + { + writeExceptionCheck(ofs, indentation, className, functionName, commandData.successCodes); + } // return the returned value - if ((returnIndex != ~0) && (((commandData.returnType == "Result") && (commandData.successCodes.size() < 2)) || (commandData.returnType == "void"))) + if ((returnIndex != ~0) && (commandData.returnType != returnType)) { ofs << indentation << " return " << reduceName(commandData.arguments[returnIndex].name) << ";" << std::endl; } @@ -1848,7 +1880,10 @@ void writeFunctionHeader(std::ofstream & ofs, std::string const& indentation, st std::set skippedArguments; for (std::map::const_iterator it = vectorParameters.begin(); it != vectorParameters.end(); ++it) { - skippedArguments.insert(it->second); + if (it->second != ~0) + { + skippedArguments.insert(it->second); + } } if ((vectorParameters.size() == 1) && ((commandData.arguments[vectorParameters.begin()->first].len == "dataSize/4") || (commandData.arguments[vectorParameters.begin()->first].len == "latexmath:[$dataSize \\over 4$]"))) @@ -1856,7 +1891,7 @@ void writeFunctionHeader(std::ofstream & ofs, std::string const& indentation, st assert(commandData.arguments[3].name == "dataSize"); skippedArguments.insert(3); } - if ((returnIndex != ~0) && (((commandData.returnType == "Result") && (commandData.successCodes.size() < 2)) || (commandData.returnType == "void"))) + if ((returnIndex != ~0) && (commandData.returnType != returnType)) { skippedArguments.insert(returnIndex); } @@ -1871,80 +1906,85 @@ void writeFunctionHeader(std::ofstream & ofs, std::string const& indentation, st { ofs << "inline "; } - ofs << returnType << " " << name << "( "; - bool argEncountered = false; - for (size_t i = commandData.handleCommand ? 1 : 0; i < commandData.arguments.size(); i++) + ofs << returnType << " " << name << "("; + if (skippedArguments.size() + (commandData.handleCommand ? 1 : 0) < commandData.arguments.size()) { - if (skippedArguments.find(i) == skippedArguments.end()) + ofs << " "; + bool argEncountered = false; + for (size_t i = commandData.handleCommand ? 1 : 0; i < commandData.arguments.size(); i++) { - if (argEncountered) + if (skippedArguments.find(i) == skippedArguments.end()) { - ofs << ", "; - } + if (argEncountered) + { + ofs << ", "; + } - std::map::const_iterator it = vectorParameters.find(i); - size_t pos = commandData.arguments[i].type.find('*'); - if ((it == vectorParameters.end()) && (pos == std::string::npos)) - { - ofs << commandData.arguments[i].type << " " << commandData.arguments[i].name; - if (!commandData.arguments[i].arraySize.empty()) + std::map::const_iterator it = vectorParameters.find(i); + size_t pos = commandData.arguments[i].type.find('*'); + if ((it == vectorParameters.end()) && (pos == std::string::npos)) { - ofs << "[" << commandData.arguments[i].arraySize << "]"; - } - } - else - { - bool optional = commandData.arguments[i].optional && ((it == vectorParameters.end()) || (it->second == ~0)); - if (optional) - { - ofs << "vk::Optional<"; - } - if (vectorParameters.find(i) == vectorParameters.end()) - { - assert(pos != std::string::npos); - if (commandData.arguments[i].type.find("char") != std::string::npos) + ofs << commandData.arguments[i].type << " " << commandData.arguments[i].name; + if (!commandData.arguments[i].arraySize.empty()) { - ofs << "std::string const"; - } - else - { - assert(commandData.arguments[i].type[pos] == '*'); - ofs << trimEnd(commandData.arguments[i].type.substr(0, pos)); + ofs << "[" << commandData.arguments[i].arraySize << "]"; } } else { - if (templateIndex == i) + bool optional = commandData.arguments[i].optional && ((it == vectorParameters.end()) || (it->second == ~0)); + if (optional) { - ofs << "std::vector"; + ofs << "vk::Optional<"; } - else if (commandData.arguments[i].pureType == "char") + if (vectorParameters.find(i) == vectorParameters.end()) { - ofs << "std::string"; - } - else if (commandData.arguments[i].pureType == "void") - { - ofs << "std::vector"; + assert(pos != std::string::npos); + if (commandData.arguments[i].type.find("char") != std::string::npos) + { + ofs << "std::string const"; + } + else + { + assert(commandData.arguments[i].type[pos] == '*'); + ofs << trimEnd(commandData.arguments[i].type.substr(0, pos)); + } } else { - ofs << "std::vector<" << commandData.arguments[i].pureType << ">"; + if (templateIndex == i) + { + ofs << "std::vector"; + } + else if (commandData.arguments[i].pureType == "char") + { + ofs << "std::string"; + } + else if (commandData.arguments[i].pureType == "void") + { + ofs << "std::vector"; + } + else + { + ofs << "std::vector<" << commandData.arguments[i].pureType << ">"; + } + if (commandData.arguments[i].type.find("const") != std::string::npos) + { + ofs << " const"; + } } - if (commandData.arguments[i].type.find("const") != std::string::npos) + if (optional) { - ofs << " const"; + ofs << "> const"; } + ofs << " & " << reduceName(commandData.arguments[i].name); } - if (optional) - { - ofs << "> const"; - } - ofs << " & " << reduceName(commandData.arguments[i].name); + argEncountered = true; } - argEncountered = true; } + ofs << " "; } - ofs << " )"; + ofs << ")"; if (commandData.handleCommand) { ofs << " const"; diff --git a/vulkan/vk_cpp.h b/vulkan/vk_cpp.h index 16b4d56..66c5222 100644 --- a/vulkan/vk_cpp.h +++ b/vulkan/vk_cpp.h @@ -17602,7 +17602,7 @@ namespace vk #endif /*!VKCPP_ENHANCED_MODE*/ #ifdef VKCPP_ENHANCED_MODE - void end( ) const + void end() const { Result result = static_cast( vkEndCommandBuffer( m_commandBuffer ) ); if ( result != Result::eSuccess ) @@ -18196,7 +18196,7 @@ namespace vk #endif /*!VKCPP_ENHANCED_MODE*/ #ifdef VKCPP_ENHANCED_MODE - void endRenderPass( ) const + void endRenderPass() const { vkCmdEndRenderPass( m_commandBuffer ); } @@ -18801,7 +18801,7 @@ namespace vk #endif /*!VKCPP_ENHANCED_MODE*/ #ifdef VKCPP_ENHANCED_MODE - void waitIdle( ) const + void waitIdle() const { Result result = static_cast( vkQueueWaitIdle( m_queue ) ); if ( result != Result::eSuccess ) @@ -20139,7 +20139,7 @@ namespace vk #endif /*!VKCPP_ENHANCED_MODE*/ #ifdef VKCPP_ENHANCED_MODE - void waitIdle( ) const + void waitIdle() const { Result result = static_cast( vkDeviceWaitIdle( m_device ) ); if ( result != Result::eSuccess ) @@ -20790,12 +20790,11 @@ namespace vk std::vector data; size_t dataSize; Result result = static_cast( vkGetPipelineCacheData( m_device, static_cast( pipelineCache ), &dataSize, nullptr ) ); - if ( result != Result::eSuccess ) + if ( ( result == Result::eSuccess ) && dataSize ) { - throw std::system_error( result, "vk::Device::getPipelineCacheData" ); + data.resize( dataSize ); + result = static_cast( vkGetPipelineCacheData( m_device, static_cast( pipelineCache ), &dataSize, reinterpret_cast( data.data() ) ) ); } - data.resize( dataSize ); - result = static_cast( vkGetPipelineCacheData( m_device, static_cast( pipelineCache ), &dataSize, reinterpret_cast( data.data() ) ) ); if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::Device::getPipelineCacheData" ); @@ -21258,21 +21257,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getSwapchainImagesKHR( SwapchainKHR swapchain, std::vector & swapchainImages ) const + std::vector getSwapchainImagesKHR( SwapchainKHR swapchain ) const { + std::vector swapchainImages; uint32_t swapchainImageCount; - Result result = static_cast( vkGetSwapchainImagesKHR( m_device, static_cast( swapchain ), &swapchainImageCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetSwapchainImagesKHR( m_device, static_cast( swapchain ), &swapchainImageCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && swapchainImageCount ) + { + swapchainImages.resize( swapchainImageCount ); + result = static_cast( vkGetSwapchainImagesKHR( m_device, static_cast( swapchain ), &swapchainImageCount, reinterpret_cast( swapchainImages.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::Device::getSwapchainImagesKHR" ); } - swapchainImages.resize( swapchainImageCount ); - result = static_cast( vkGetSwapchainImagesKHR( m_device, static_cast( swapchain ), &swapchainImageCount, reinterpret_cast( swapchainImages.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::Device::getSwapchainImagesKHR" ); - } - return result; + return swapchainImages; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21341,7 +21344,7 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - PhysicalDeviceProperties getProperties( ) const + PhysicalDeviceProperties getProperties() const { PhysicalDeviceProperties properties; vkGetPhysicalDeviceProperties( m_physicalDevice, reinterpret_cast( &properties ) ); @@ -21355,7 +21358,7 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - std::vector getQueueFamilyProperties( ) const + std::vector getQueueFamilyProperties() const { std::vector queueFamilyProperties; uint32_t queueFamilyPropertyCount; @@ -21372,7 +21375,7 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - PhysicalDeviceMemoryProperties getMemoryProperties( ) const + PhysicalDeviceMemoryProperties getMemoryProperties() const { PhysicalDeviceMemoryProperties memoryProperties; vkGetPhysicalDeviceMemoryProperties( m_physicalDevice, reinterpret_cast( &memoryProperties ) ); @@ -21386,7 +21389,7 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - PhysicalDeviceFeatures getFeatures( ) const + PhysicalDeviceFeatures getFeatures() const { PhysicalDeviceFeatures features; vkGetPhysicalDeviceFeatures( m_physicalDevice, reinterpret_cast( &features ) ); @@ -21450,21 +21453,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result enumerateDeviceLayerProperties( std::vector & properties ) const + std::vector enumerateDeviceLayerProperties() const { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkEnumerateDeviceLayerProperties( m_physicalDevice, &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkEnumerateDeviceLayerProperties( m_physicalDevice, &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkEnumerateDeviceLayerProperties( m_physicalDevice, &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::enumerateDeviceLayerProperties" ); } - properties.resize( propertyCount ); - result = static_cast( vkEnumerateDeviceLayerProperties( m_physicalDevice, &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::enumerateDeviceLayerProperties" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21474,21 +21481,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result enumerateDeviceExtensionProperties( vk::Optional const & layerName, std::vector & properties ) const + std::vector enumerateDeviceExtensionProperties( vk::Optional const & layerName ) const { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkEnumerateDeviceExtensionProperties( m_physicalDevice, layerName ? layerName->c_str() : nullptr, &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkEnumerateDeviceExtensionProperties( m_physicalDevice, layerName ? layerName->c_str() : nullptr, &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkEnumerateDeviceExtensionProperties( m_physicalDevice, layerName ? layerName->c_str() : nullptr, &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::enumerateDeviceExtensionProperties" ); } - properties.resize( propertyCount ); - result = static_cast( vkEnumerateDeviceExtensionProperties( m_physicalDevice, layerName ? layerName->c_str() : nullptr, &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::enumerateDeviceExtensionProperties" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21515,21 +21526,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getDisplayPropertiesKHR( std::vector & properties ) const + std::vector getDisplayPropertiesKHR() const { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkGetPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkGetPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::getDisplayPropertiesKHR" ); } - properties.resize( propertyCount ); - result = static_cast( vkGetPhysicalDeviceDisplayPropertiesKHR( m_physicalDevice, &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::getDisplayPropertiesKHR" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21539,21 +21554,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getDisplayPlanePropertiesKHR( std::vector & properties ) const + std::vector getDisplayPlanePropertiesKHR() const { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkGetPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkGetPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::getDisplayPlanePropertiesKHR" ); } - properties.resize( propertyCount ); - result = static_cast( vkGetPhysicalDeviceDisplayPlanePropertiesKHR( m_physicalDevice, &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::getDisplayPlanePropertiesKHR" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21563,21 +21582,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getDisplayPlaneSupportedDisplaysKHR( uint32_t planeIndex, std::vector & displays ) const + std::vector getDisplayPlaneSupportedDisplaysKHR( uint32_t planeIndex ) const { + std::vector displays; uint32_t displayCount; - Result result = static_cast( vkGetDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, planeIndex, &displayCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, planeIndex, &displayCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && displayCount ) + { + displays.resize( displayCount ); + result = static_cast( vkGetDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, planeIndex, &displayCount, reinterpret_cast( displays.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::getDisplayPlaneSupportedDisplaysKHR" ); } - displays.resize( displayCount ); - result = static_cast( vkGetDisplayPlaneSupportedDisplaysKHR( m_physicalDevice, planeIndex, &displayCount, reinterpret_cast( displays.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::getDisplayPlaneSupportedDisplaysKHR" ); - } - return result; + return displays; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21587,21 +21610,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getDisplayModePropertiesKHR( DisplayKHR display, std::vector & properties ) const + std::vector getDisplayModePropertiesKHR( DisplayKHR display ) const { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkGetDisplayModePropertiesKHR( m_physicalDevice, static_cast( display ), &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetDisplayModePropertiesKHR( m_physicalDevice, static_cast( display ), &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkGetDisplayModePropertiesKHR( m_physicalDevice, static_cast( display ), &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::getDisplayModePropertiesKHR" ); } - properties.resize( propertyCount ); - result = static_cast( vkGetDisplayModePropertiesKHR( m_physicalDevice, static_cast( display ), &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::getDisplayModePropertiesKHR" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21698,21 +21725,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getSurfaceFormatsKHR( SurfaceKHR surface, std::vector & surfaceFormats ) const + std::vector getSurfaceFormatsKHR( SurfaceKHR surface ) const { + std::vector surfaceFormats; uint32_t surfaceFormatCount; - Result result = static_cast( vkGetPhysicalDeviceSurfaceFormatsKHR( m_physicalDevice, static_cast( surface ), &surfaceFormatCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetPhysicalDeviceSurfaceFormatsKHR( m_physicalDevice, static_cast( surface ), &surfaceFormatCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && surfaceFormatCount ) + { + surfaceFormats.resize( surfaceFormatCount ); + result = static_cast( vkGetPhysicalDeviceSurfaceFormatsKHR( m_physicalDevice, static_cast( surface ), &surfaceFormatCount, reinterpret_cast( surfaceFormats.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::getSurfaceFormatsKHR" ); } - surfaceFormats.resize( surfaceFormatCount ); - result = static_cast( vkGetPhysicalDeviceSurfaceFormatsKHR( m_physicalDevice, static_cast( surface ), &surfaceFormatCount, reinterpret_cast( surfaceFormats.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::getSurfaceFormatsKHR" ); - } - return result; + return surfaceFormats; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -21722,21 +21753,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result getSurfacePresentModesKHR( SurfaceKHR surface, std::vector & presentModes ) const + std::vector getSurfacePresentModesKHR( SurfaceKHR surface ) const { + std::vector presentModes; uint32_t presentModeCount; - Result result = static_cast( vkGetPhysicalDeviceSurfacePresentModesKHR( m_physicalDevice, static_cast( surface ), &presentModeCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkGetPhysicalDeviceSurfacePresentModesKHR( m_physicalDevice, static_cast( surface ), &presentModeCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && presentModeCount ) + { + presentModes.resize( presentModeCount ); + result = static_cast( vkGetPhysicalDeviceSurfacePresentModesKHR( m_physicalDevice, static_cast( surface ), &presentModeCount, reinterpret_cast( presentModes.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::PhysicalDevice::getSurfacePresentModesKHR" ); } - presentModes.resize( presentModeCount ); - result = static_cast( vkGetPhysicalDeviceSurfacePresentModesKHR( m_physicalDevice, static_cast( surface ), &presentModeCount, reinterpret_cast( presentModes.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::PhysicalDevice::getSurfacePresentModesKHR" ); - } - return result; + return presentModes; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -22028,21 +22063,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - Result enumeratePhysicalDevices( std::vector & physicalDevices ) const + std::vector enumeratePhysicalDevices() const { + std::vector physicalDevices; uint32_t physicalDeviceCount; - Result result = static_cast( vkEnumeratePhysicalDevices( m_instance, &physicalDeviceCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkEnumeratePhysicalDevices( m_instance, &physicalDeviceCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && physicalDeviceCount ) + { + physicalDevices.resize( physicalDeviceCount ); + result = static_cast( vkEnumeratePhysicalDevices( m_instance, &physicalDeviceCount, reinterpret_cast( physicalDevices.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::Instance::enumeratePhysicalDevices" ); } - physicalDevices.resize( physicalDeviceCount ); - result = static_cast( vkEnumeratePhysicalDevices( m_instance, &physicalDeviceCount, reinterpret_cast( physicalDevices.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::Instance::enumeratePhysicalDevices" ); - } - return result; + return physicalDevices; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -22315,21 +22354,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - inline Result enumerateInstanceLayerProperties( std::vector & properties ) + inline std::vector enumerateInstanceLayerProperties() { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkEnumerateInstanceLayerProperties( &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkEnumerateInstanceLayerProperties( &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkEnumerateInstanceLayerProperties( &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::enumerateInstanceLayerProperties" ); } - properties.resize( propertyCount ); - result = static_cast( vkEnumerateInstanceLayerProperties( &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::enumerateInstanceLayerProperties" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/ @@ -22339,21 +22382,25 @@ namespace vk } #ifdef VKCPP_ENHANCED_MODE - inline Result enumerateInstanceExtensionProperties( vk::Optional const & layerName, std::vector & properties ) + inline std::vector enumerateInstanceExtensionProperties( vk::Optional const & layerName ) { + std::vector properties; uint32_t propertyCount; - Result result = static_cast( vkEnumerateInstanceExtensionProperties( layerName ? layerName->c_str() : nullptr, &propertyCount, nullptr ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) + Result result; + do + { + result = static_cast( vkEnumerateInstanceExtensionProperties( layerName ? layerName->c_str() : nullptr, &propertyCount, nullptr ) ); + if ( ( result == Result::eSuccess ) && propertyCount ) + { + properties.resize( propertyCount ); + result = static_cast( vkEnumerateInstanceExtensionProperties( layerName ? layerName->c_str() : nullptr, &propertyCount, reinterpret_cast( properties.data() ) ) ); + } + } while ( result == Result::eIncomplete ); + if ( result != Result::eSuccess ) { throw std::system_error( result, "vk::enumerateInstanceExtensionProperties" ); } - properties.resize( propertyCount ); - result = static_cast( vkEnumerateInstanceExtensionProperties( layerName ? layerName->c_str() : nullptr, &propertyCount, reinterpret_cast( properties.data() ) ) ); - if ( ( result != Result::eSuccess ) && ( result != Result::eIncomplete ) ) - { - throw std::system_error( result, "vk::enumerateInstanceExtensionProperties" ); - } - return result; + return properties; } #endif /*VKCPP_ENHANCED_MODE*/