swr/rast: Cull prims when all verts have negative clip distances
authorGeorge Kyriazis <george.kyriazis@intel.com>
Thu, 1 Feb 2018 23:43:04 +0000 (17:43 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 16 Feb 2018 16:54:00 +0000 (10:54 -0600)
Performance optimization, and fixes some clipping issues.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/clip.h

index 1d336b6aff6225989dbc505d182d02fa6ce7839c..519367228eaf4df69bfc6dc0c13c9acf3841024c 100644 (file)
@@ -417,6 +417,7 @@ public:
             uint32_t slot = index >> 2;
             uint32_t component = index & 0x3;
 
+            typename SIMD_T::Float vCullMaskElem = SIMD_T::set1_ps(-1.0f);
             for (uint32_t e = 0; e < NumVertsPerPrim; ++e)
             {
                 typename SIMD_T::Float vClipComp;
@@ -430,8 +431,11 @@ public:
                 }
 
                 typename SIMD_T::Float vClip = SIMD_T::template cmp_ps<SIMD_T::CompareType::UNORD_Q>(vClipComp, vClipComp);
+                typename SIMD_T::Float vCull = SIMD_T::template cmp_ps<SIMD_T::CompareType::NLE_UQ>(SIMD_T::setzero_ps(), vClipComp);
+                vCullMaskElem = SIMD_T::and_ps(vCullMaskElem, vCull);
                 vClipCullMask = SIMD_T::or_ps(vClipCullMask, vClip);
             }
+            vClipCullMask = SIMD_T::or_ps(vClipCullMask, vCullMaskElem);
         }
 
         return SIMD_T::movemask_ps(vClipCullMask);