Open
Description
I've created a new argument-buffers
branch to support Metal argument buffers for use in descriptor sets, and have pushed the initial release of this implementation to that branch. Some notes on current status:
- The use of Metal argument buffers dramatically increases the available quantities of shader resources in most modern (Tier 2) GPU's, properly supporting the goals of the
VK_EXT_descriptor_indexing
extension. - The
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS
environment variable can be used to enable or disable the use of Metal argument buffers. It is enabled by default in this branch. - The Metal argument buffer implementation passes the same 20K+ CTS descriptor set tests that MoltenVK passes when not using Metal argument buffers.
- However, the current implementation does cause issues and crashes with some applications, and that is being tested and addressed. Please add comments to this issue to identify any problems encountered while testing.
- In order to streamline descriptor set allocations, this implementation allocates a single large
MTLBuffer
to use for all descriptors managed by a descriptor pool (as opposed to aMTLBuffer
per descriptor set stage). However, because Metal doesn't seem to allow arbitrary indexed access into Metal argument buffers, each descriptor layout stage requires a separate argument encoder. The result is that, in theory, each pipeline stage could use all descriptors, meaning that at pool allocation time, the size of the single largeMTLBuffer
is grossly over-allocated. For example, a graphics pipeline of 4 stages will have 4 separate argument encoders, and 4 sets of resources in the argument buffer. An alternative for this could include allocating a separateMTLBuffer
per descriptor set when the descriptor set is allocated, but in CTS testing, this causes significant performance degradation (50x) during descriptor set allocation and freeing, relative to not using Metal argument buffers, becauseMTLBuffers
are performance-expensive to create and destroy. Another alternative might be to manage a pool of smallerMTLBuffers
. - I will continue to do further improvements, optimizations, and testing on the
argument-buffers
branch before rolling it intomaster
.
@cdavis5e I wouldn't mind getting your thoughts on item 5 above.