Only process active fragment samples This change refactors the handling of which samples we should iterate over, by putting their indices into a container object. This enables the use of range-based for loops to have a more elegant syntax and avoid the confusion around sampleId -1 having special meaning and the begin and end iteration markers still requiring checking the sample mask on each loop. Bug: b/194521425 Change-Id: Ib6fbbb3e89c3a5501311ebd81859608df44d1bd0 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/56008 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Sean Risser <srisser@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/PixelRoutine.hpp b/src/Pipeline/PixelRoutine.hpp index fd2f9a1..edb7eb4 100644 --- a/src/Pipeline/PixelRoutine.hpp +++ b/src/Pipeline/PixelRoutine.hpp
@@ -17,6 +17,8 @@ #include "Device/QuadRasterizer.hpp" +#include <vector> + namespace sw { class PixelShader; @@ -33,6 +35,8 @@ virtual ~PixelRoutine(); protected: + using SampleSet = std::vector<int>; + Float4 z[4]; // Multisampled z Float4 w; // Used as is Float4 rhw; // Reciprocal w @@ -45,15 +49,15 @@ // Depth output Float4 oDepth; - virtual void setBuiltins(Int &x, Int &y, Float4 (&z)[4], Float4 &w, Int cMask[4], int sampleId) = 0; - virtual void applyShader(Int cMask[4], Int sMask[4], Int zMask[4], int sampleId) = 0; - virtual Bool alphaTest(Int cMask[4], int sampleId) = 0; - virtual void rasterOperation(Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4], int sampleId) = 0; + virtual void setBuiltins(Int &x, Int &y, Float4 (&z)[4], Float4 &w, Int cMask[4], const SampleSet &samples) = 0; + virtual void executeShader(Int cMask[4], Int sMask[4], Int zMask[4], const SampleSet &samples) = 0; + virtual Bool alphaTest(Int cMask[4], const SampleSet &samples) = 0; + virtual void rasterOperation(Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4], const SampleSet &samples) = 0; void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) override; void alphaTest(Int &aMask, const Short4 &alpha); - void alphaToCoverage(Int cMask[4], const Float4 &alpha, int sampleId); + void alphaToCoverage(Int cMask[4], const Float4 &alpha, const SampleSet &samples); // Raster operations void alphaBlend(int index, const Pointer<Byte> &cBuffer, Vector4s ¤t, const Int &x); @@ -102,6 +106,8 @@ const bool shaderContainsSampleQualifier; const bool perSampleShading; const int invocationCount; + + SampleSet getSampleSet(int invocation) const; }; } // namespace sw