swr/rasterizer: Fix 3D resource copies.
authorJan Zielinski <jan.zielinski@intel.com>
Tue, 23 Jul 2019 10:47:28 +0000 (12:47 +0200)
committerJan Zielinski <jan.zielinski@intel.com>
Tue, 23 Jul 2019 19:55:09 +0000 (21:55 +0200)
Ensure constant attributes stay constant with barycentric interpolation.

Reviewed-by: Alok Hota <alok.hota@intel.com>
src/gallium/drivers/swr/rasterizer/common/simdintrin.h

index 4145ba8dcce0a804bcc7957f64c4164511877ed4..df5c3ac605651f189b4fc515ec75ef324b2e9228 100644 (file)
@@ -282,6 +282,13 @@ static SIMDINLINE simdscalar InterpolateComponent(simdscalar const& vI,
     const float* pInterpB = &pInterpBuffer[Attrib * 3 * numComponents + numComponents + Comp];
     const float* pInterpC = &pInterpBuffer[Attrib * 3 * numComponents + numComponents * 2 + Comp];
 
+    if ((pInterpA[0] == pInterpB[0]) && (pInterpA[0] == pInterpC[0]))
+    {
+        // Ensure constant attribs are constant.  Required for proper
+        // 3D resource copies.
+        return _simd_broadcast_ss(pInterpA);
+    }
+
     simdscalar vA = _simd_broadcast_ss(pInterpA);
     simdscalar vB = _simd_broadcast_ss(pInterpB);
     simdscalar vC = _simd_broadcast_ss(pInterpC);
@@ -332,6 +339,13 @@ static SIMDINLINE simd4scalar InterpolateComponent(simd4scalar const& vI,
     const float* pInterpB = &pInterpBuffer[Attrib * 3 * numComponents + numComponents + Comp];
     const float* pInterpC = &pInterpBuffer[Attrib * 3 * numComponents + numComponents * 2 + Comp];
 
+    if ((pInterpA[0] == pInterpB[0]) && (pInterpA[0] == pInterpC[0]))
+    {
+        // Ensure constant attribs are constant.  Required for proper
+        // 3D resource copies.
+        return SIMD128::broadcast_ss(pInterpA);
+    }
+
     simd4scalar vA = SIMD128::broadcast_ss(pInterpA);
     simd4scalar vB = SIMD128::broadcast_ss(pInterpB);
     simd4scalar vC = SIMD128::broadcast_ss(pInterpC);