Hi all, I'd like to propose a new Mesa vendor SPIR-V extension, SPV_MESA_fragment_coverage_mask (spec attached).
Problem When a fragment shader runs in per-sample mode, the existing SampleMask built-in is masked to only the samples being processed by the current invocation. This means there is no way for the shader to obtain the full set of samples covered by the fragment. This is a problem for D3D translation layers: D3D10's input coverage mask always provides the complete coverage regardless of execution mode, and there is currently no SPIR-V equivalent. The problem is compounded when per-sample shading is triggered via a sample shading rate (e.g. minSampleShading) rather than through SampleId/SamplePosition, since in that case those built-ins are not present and SampleMask cannot be reverse-engineered into the full mask. Proposal The extension adds a single new built-in decoration, FragmentCoverageMaskMESA, which always contains the complete coverage mask of the fragment regardless of the shading mode. It introduces one new capability (FragmentCoverageMESA) and no new instructions. When PostDepthCoverage is declared, FragmentCoverageMaskMESA reflects the results of early fragment tests, consistent with SampleMask behaviour. Motivation This is primarily needed for accurate D3D10+ shader translation, where the input coverage mask semantic does not have a direct SPIR-V counterpart today. The full spec is attached. Feedback and comments welcome.
SPV_MESA_fragment_coverage_mask.asciidoc
Description: Binary data
