swr/rast: revert clip distance precision
authorGeorge Kyriazis <george.kyriazis@intel.com>
Tue, 20 Feb 2018 06:07:57 +0000 (00:07 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 28 Feb 2018 17:42:50 +0000 (11:42 -0600)
Fixes piglit tests that broke with 8a64593bde

Reviewed-By: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/backend_impl.h
src/gallium/drivers/swr/rasterizer/core/binner.cpp

index 454f473b47eee8ada810dea8e0688af2575d3a01..2cfd52e829d29f53c46877d2e2aecbc736c5cc2f 100644 (file)
@@ -62,10 +62,8 @@ static INLINE simdmask ComputeUserClipMask(uint8_t clipMask, float* pUserClipBuf
         simdscalar vB = _simd_broadcast_ss(pUserClipBuffer++);
         simdscalar vC = _simd_broadcast_ss(pUserClipBuffer++);
 
-        simdscalar vK = _simd_sub_ps(_simd_sub_ps(_simd_set1_ps(1.0f), vI), vJ);
-
         // interpolate
-        simdscalar vInterp = vplaneps(vA, vB, _simd_mul_ps(vK, vC), vI, vJ);
+        simdscalar vInterp = vplaneps(vA, vB, vC, vI, vJ);
 
         // clip if interpolated clip distance is < 0 || NAN
         simdscalar vCull = _simd_cmp_ps(_simd_setzero_ps(), vInterp, _CMP_NLE_UQ);
index 3b093cefc04f5a41c1584fdf97409124d7d492af..c9a37cb17aea0263802c1dc2ffc2aa77da072d03 100644 (file)
@@ -256,12 +256,27 @@ void ProcessUserClipDist(const SWR_BACKEND_STATE& state, PA_STATE& pa, uint32_t
         simd4scalar primClipDist[3];
         pa.AssembleSingle(clipAttribSlot, primIndex, primClipDist);
 
+        float vertClipDist[NumVerts];
         for (uint32_t e = 0; e < NumVerts; ++e)
         {
             OSALIGNSIMD(float) aVertClipDist[4];
             SIMD128::store_ps(aVertClipDist, primClipDist[e]);
-            *(pUserClipBuffer++) = aVertClipDist[clipComp];
+            vertClipDist[e] = aVertClipDist[clipComp];
         };
+
+        // setup plane equations for barycentric interpolation in the backend
+        float baryCoeff[NumVerts];
+        float last = vertClipDist[NumVerts - 1] * pRecipW[NumVerts - 1];
+        for (uint32_t e = 0; e < NumVerts - 1; ++e)
+        {
+            baryCoeff[e] = vertClipDist[e] * pRecipW[e] - last;
+        }
+        baryCoeff[NumVerts - 1] = last;
+
+        for (uint32_t e = 0; e < NumVerts; ++e)
+        {
+            *(pUserClipBuffer++) = baryCoeff[e];
+        }
     }
 }