Optimize usage of "prepare for use" in draw and dispatch commands. #91989
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.
Prepare for use is a command that got added due to the D3D12 driver requiring a step to transition resources to their required states, meaning the function needed to be called no matter what.
Due to how the function was written to share the loop used for validation (which does not get compiled into release games), this means that command was added and serialized into the render graph for every draw call even if the API did not require it at all.
Upon testing Nuku Warriors I found the command being called 72K times per frame on the Vulkan backend despite being a noop in that API. Furthermore, this path will also be skipped when #91769 is merged and the driver reports support for enhanced barriers.
I've not measured the performance differential but it is likely the CPU times can only improve with this change as it goes from doing something that was unnecessary to doing nothing.