KhronosGroup / SPIRV-Cross

SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.
Apache License 2.0
1.96k stars 549 forks source link

Add option to enforce fragment execution with side effects in MSL #2323

Closed aitor-lunarg closed 1 month ago

aitor-lunarg commented 1 month ago

Metal will incorrectly discard fragments with side effects under certain circumstances prematurely. The conditions are the following:

However, Metal will also discard the fragment even if it has operations with side effects inside the fragment shader before the discard operation.

Vulkan states the graphics pipeline to execute in the following order:

Therefore, we need to enforce fragment shader execution and not let Metal discard the fragment before that for such cases. This change adds an option to provide such utility.

Fixes https://github.com/KhronosGroup/SPIRV-Cross/issues/2322

If there's a better approach to accomplish this, I'm happy to investigate!

aitor-lunarg commented 1 month ago

Closing in favor of a new upcoming PR