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

Emulate sampler lod bias #2163

Open aitor-lunarg opened 9 months ago

aitor-lunarg commented 9 months ago

2142 tries to tackle this issue exposing internal Metal SPIs. Unfortunately, even with MVK_USE_METAL_PRIVATE_API enabled, there are still CTS tests failing in the M3 chip family. Proposed solution is to emulate as pointed out in https://github.com/KhronosGroup/MoltenVK/pull/2142#issuecomment-1913173117

Failing CTS tests:

dEQP-VK.pipeline.monolithic.sampler.max_sampler_lod_bias.sampler_bias
aitor-lunarg commented 5 months ago

I think it would be beneficial to rework how samplers are passed to Metal so that we pass the following data per sampler:

Then modify the shader to add bias (since bias is implemented in shader for Metal) and handle opaque black and as a nice side effect support custom border color (unsure if MoltenVK has support for this, I think not).

Refer to https://github.com/KhronosGroup/Vulkan-Portability/issues/37#issuecomment-2154637160 for the custom border color.

Mentioning this because it could be a unified effort to support bias and border color since both require similar changes.