KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.76k stars 419 forks source link

MSAA with resolveMode=SAMPLE_ZERO uses a compute kernel, even on Apple silicon devices #2254

Closed stripe2933 closed 3 months ago

stripe2933 commented 3 months ago

Also, it requires non-transient attachment. Why this happened? Seems like resolveMode=AVERAGE uses tile based resolve.

billhollings commented 3 months ago

The decision to run the resolve compute kernel is not based on the resolveMode, but on whether Metal and your GPU support natively resolving the pixel format you are using.

Metal describes which combination of formats and GPUs support native MSAA in the back half of this document.

Which GPU and pixel format are you using?

For native MSAA on the GPU, Metal uses the equivalent of AVERAGE. For simplicity, MoltenVK uses SAMPLE_ZERO in the compute kernel when native MSAA is not supported.

If there is demand for it, as an enhancement, we could add support to the kernel function to resolve the other resolve modes. We could also run the compute kernel anytime a resolution mode other than AVERAGE is requested. I've created issue #2257 to track this.

Regarding the second question, MoltenVK does not yet support tiling shaders.

stripe2933 commented 3 months ago

I was using R32Uint for 4x MSAA to render gl_InstanceIndex (since the depth attachment was 4x MSAA, there were no other options). As you mentioned, the native resolve is not supported for this format. I decided to separate the instance index rendering pass, so it’s not a problem anymore. Anyway, thank you for your answer.