Fix early fragment tests
zMask and sMask need to be updated whenever cMask gets modified
during the shader's execution. cMask can be modified whenever the
shader contains a discard operation, which was taken into account.
cMask can also be modified when the shader contains outputs to the
SampleMask builtin, which was NOT taken into account, so this CL
adds a proper check to see when coverage information needs to be
updated.
Tests: dEQP-VK.fragment_operations.early_fragment.sample_count_early_fragment_tests_depth_samples_4
Bug: b/200826740
Change-Id: I9f5249dc43c83b88d25ffaa9a33c8f89590d6b8d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/66128
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index 7e4ff7a..a95a363 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -286,7 +286,7 @@
Bool alphaPass = alphaTest(cMask, samples);
- if((spirvShader && spirvShader->getAnalysis().ContainsDiscard) || state.alphaToCoverage)
+ if((spirvShader && spirvShader->coverageModified()) || state.alphaToCoverage)
{
for(unsigned int q : samples)
{
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index f1e60bb..e1d0295 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -680,6 +680,12 @@
return analysis;
}
+ bool coverageModified() const
+ {
+ return analysis.ContainsDiscard ||
+ (outputBuiltins.find(spv::BuiltInSampleMask) != outputBuiltins.end());
+ }
+
struct Capabilities
{
bool Matrix : 1;