Skip to content

WIP: Initial implementation of Metal argument buffers for Vulkan descriptor sets. #1186

Open
@billhollings

Description

@billhollings

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:

  1. 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.
  2. 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.
  3. The Metal argument buffer implementation passes the same 20K+ CTS descriptor set tests that MoltenVK passes when not using Metal argument buffers.
  4. 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.
  5. 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 a MTLBuffer 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 large MTLBuffer 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 separate MTLBuffer 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, because MTLBuffers are performance-expensive to create and destroy. Another alternative might be to manage a pool of smaller MTLBuffers.
  6. I will continue to do further improvements, optimizations, and testing on the argument-buffers branch before rolling it into master.

@cdavis5e I wouldn't mind getting your thoughts on item 5 above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions