Call Vec::set_len()
after checking for Vulkan errors
#684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The entire reason for calling
unsafe
set_len()
after the Vulkan driver function call is to ensure theVec
never gives safe access to uninitialized values (as allocted viaVec::with_capacity()
). This contract is broken within the implementation of these functions by temporarily setting a nonzero length when the Vulkan driver may not have initialized the underlying data at all, and communicated this by returning an error code.Simply check the error code first, before jumping to a now-infallible codepath that calls
.set_len()
and always returnsOk()
.TODO
We have to see what should happen in
create_graphics_pipelines()
andcreate_compute_pipelines()
which always return the underlyingVec
even on errors... 馃槹. Only do this ifVK_PIPELINE_COMPILE_REQUIRED_EXT
is returned (in addition toVK_SUCCESS
), otherwise don't?