You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation of an "enumerate" function as a simple "fetch the number, then populate the results with that number" is a common mistake in Vulkan code.
While rare, code must deal with possibility that the number returned by the first call won't be valid by the time of the second call, and that the second call will have populated the num value with a different number than the original (in this case, the function should also have returned VK_INCOMPLETE)
Consider the implementation of the C++ bindings vk::enumerateInstanceExtensionProperties method:
do
{
result = static_cast<Result>( d.vkEnumerateInstanceExtensionProperties( layerName ? layerName->c_str() : nullptr, &propertyCount, nullptr ) );
if ( ( result == Result::eSuccess ) && propertyCount )
{
properties.resize( propertyCount );
result = static_cast<Result>( d.vkEnumerateInstanceExtensionProperties( layerName ? layerName->c_str() : nullptr, &propertyCount, reinterpret_cast<VkExtensionProperties*>( properties.data() ) ) );
}
} while ( result == Result::eIncomplete );
This creates a loop that will almost invariably exit after the first pass, but which will still handle the case where the number of exposed extensions changes at runtime between the first and second calls. This same logic should be applied to all the other functions with potentially return VK_INCOMPLETE. Searching for Result::eIncomplete in this file gives a good list of them I believe.
The text was updated successfully, but these errors were encountered:
vulkano/vulkano/src/instance/extensions.rs
Lines 62 to 78 in 661f571
The implementation of an "enumerate" function as a simple "fetch the number, then populate the results with that number" is a common mistake in Vulkan code.
While rare, code must deal with possibility that the number returned by the first call won't be valid by the time of the second call, and that the second call will have populated the
num
value with a different number than the original (in this case, the function should also have returnedVK_INCOMPLETE
)Consider the implementation of the C++ bindings
vk::enumerateInstanceExtensionProperties
method:This creates a loop that will almost invariably exit after the first pass, but which will still handle the case where the number of exposed extensions changes at runtime between the first and second calls. This same logic should be applied to all the other functions with potentially return
VK_INCOMPLETE
. Searching forResult::eIncomplete
in this file gives a good list of them I believe.The text was updated successfully, but these errors were encountered: