APPLE: ICB for multidrawindirect on macOS #1945
Merged
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.
Description of Change(s)
Implementation of Indirect Command Buffers (ICBs) to improve performance of multidraw indirect on the Metal implementation of the Storm renderer.
This brings significant savings on CPU time for complex scenes.
ICBs are encoded in a transform-feedback shader which is run as part of the Prepare phase of the PipelineDrawBatch. This generates a command state, held in the HgiMetalIndirectCommands structure, which contains the ICB, argument buffers, graphics pipeline and resource bindings necessary to execute the commands in the ExecuteDraw phase of the draw batch.
The implementation add a manager to HGI, the IndirectCommandEncoder. This is responsible for the lifetime of the transform feedback shaders, interfacing with the underlying Metal API and holding a pool of buffers to optimise the creation of the ICBs.
Known Issues(s)
On Apple Silicon machines running macOS before 12.3, a driver issue causes validation failure when the supportIndirectCommandBuffers flag is set. Therefore ICBs are not supported on these versions of macOS on Apple Silicon.
Fixes Issue(s)
CPU performance on Metal for complex scenes.
[X] I have submitted a signed Contributor License Agreement