Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Guidance re MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS option #2146

Closed
SRSaunders opened this issue Jan 28, 2024 · 5 comments
Closed

Question: Guidance re MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS option #2146

SRSaunders opened this issue Jan 28, 2024 · 5 comments
Labels
Answered A question was answered Question

Comments

@SRSaunders
Copy link
Contributor

SRSaunders commented Jan 28, 2024

Are there any docs that provide performance guidance on the use of the MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS option?

Up to this point I have been using the setting MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_DESCRIPTOR_INDEXING based on the assumption that performance will be improved. However, empirical evidence shows that I get slightly better performance (~5%) with it set to MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER, especially on my Apple Silicon M1 Air. On my x86 + AMD GPU machine, improvements are also observable with the setting off (i.e. never) but perhaps less pronounced (<5%) than on the M1.

And using MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_ALWAYS gives the same results as MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_DESCRIPTOR_INDEXING. This is expected since VK_EXT_descriptor_indexing is enabled for my application.

I am inclined to turn this setting off, but are there any hints or advice on how I should set this option? Note that I am using push constants almost exclusively for my app so I am not sure how this plays into it.

@billhollings billhollings added Question Answered A question was answered labels Jan 29, 2024
@billhollings
Copy link
Contributor

For now, the big differentiator is how many resources you need. If you can get away with the very small number (31/128) of descriptor resources that are available to Metal without argument buffers, then you can leave MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS disabled.

BTW, the next round of development on this in the next couple of months, should see us move to argument buffers being used by default, particularly when Metal 3 is available.

@SRSaunders
Copy link
Contributor Author

Thanks for the info and heads-up re new developments coming down the pipe.

@DUOLabs333
Copy link

BTW, the next round of development on this in the next couple of months, should see us move to argument buffers being used by default

How would this affect maxSamplerAllocationCount? With MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0, this is 1073741824, but with MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1, this is 1024. With MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1, this breaks gzdoom (a shader was not able to be successfully compile). This does seem to be fixed in 1.2.11 though.

@billhollings
Copy link
Contributor

BTW, the next round of development on this in the next couple of months, should see us move to argument buffers being used by default

How would this affect maxSamplerAllocationCount? With MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0, this is 1073741824, but with MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1, this is 1024. With MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1

When Metal Argument Buffers are not in use, Metal doesn't formally limit the number of samplers that can be created, hence the essentially infinite value returned in maxSamplerAllocationCount.

However, Metal does limit the number of samplers that can be used in Metal argument buffers. Therefore, when Metal argument buffers are in use, MoltenVK returns the limit in maxSamplerAllocationCount.

this breaks gzdoom (a shader was not able to be successfully compile). This does seem to be fixed in 1.2.11 though.

Can you provide more info on what is/was breaking?

@DUOLabs333
Copy link

On 1.2.9 (the current version packaged by nixpkgs), when starting, a SPIR-V to MSL conversion fails if MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1 --- this error goes away on 1.2.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Answered A question was answered Question
Projects
None yet
Development

No branches or pull requests

3 participants