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.84k stars 429 forks source link

Support for VK_KHR_fragment_shading_rate possible? #1710

Open oscarbg opened 2 years ago

oscarbg commented 2 years ago

Hi, seeing new Basemark benchmark announced as having VRS on mobile, was surprised to see no iOS support for VRS on that bench.. https://www.basemark.com/news/basemark-debuts-worlds-first-mobile-device-benchmark-with-variable-rate-shading/ specially remembering being announced by Apple for A13 something called rasterization rate maps: https://www.notebookcheck.net/Apple-offers-an-in-depth-look-at-the-A13-Bionic-GPU-s-Metal-Engine-enhancements.434691.0.html

metal docs: https://developer.apple.com/documentation/metal/render_passes/rendering_at_different_rasterization_rates https://developer.apple.com/documentation/metal/mtlrasterizationratemap https://developer.apple.com/documentation/metal/render_passes/rendering_with_a_rasterization_rate_map etc..

seeing this, I can't see any work in MoltenVK towards exposing VK_KHR_fragment_shading_rate using this functionality.. specially seems functionality vaguely similar to the optional: attachmentFragmentShadingRate feature.. so question is, it's possible to implement attachmentFragmentShadingRate cap of VK_KHR_fragment_shading_rate in Metal right now? or Metal API limitations..

thanks..

cdavis5e commented 2 years ago

Unfortunately, it's not that simple.

Metal's rasterization rate maps are initialized from data on the host, while Vulkan shading rate attachments are images that may be initialized in any of the usual ways. In particular, it's possible to use a device-local image as a shading rate attachment; needless to say, extracting the data from it to pass to Metal for the rasterization rate map is difficult.