From 7e813f62149b9141d2f8970d35ab7ffbd0e0637c Mon Sep 17 00:00:00 2001 From: George Kyriazis Date: Wed, 7 Feb 2018 12:24:23 -0600 Subject: [PATCH] swr/rast: Faster frustum prim culling Fix clipper validMask setting. We don't need to run frustum rejected primitives through the clipper. Perform frustum culling with only frustum clip codes. Guardband clip codes cannot be used because they overlap frustum codes. Reviewed-By: Bruce Cherniak --- src/gallium/drivers/swr/rasterizer/core/clip.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/clip.h b/src/gallium/drivers/swr/rasterizer/core/clip.h index 8d2590a4981..0f8399c742c 100644 --- a/src/gallium/drivers/swr/rasterizer/core/clip.h +++ b/src/gallium/drivers/swr/rasterizer/core/clip.h @@ -60,6 +60,7 @@ enum SWR_CLIPCODES }; #define GUARDBAND_CLIP_MASK (FRUSTUM_NEAR|FRUSTUM_FAR|GUARDBAND_LEFT|GUARDBAND_TOP|GUARDBAND_RIGHT|GUARDBAND_BOTTOM|NEGW) +#define FRUSTUM_CLIP_MASK (FRUSTUM_NEAR|FRUSTUM_FAR|FRUSTUM_LEFT|FRUSTUM_RIGHT|FRUSTUM_TOP|FRUSTUM_BOTTOM) template void ComputeClipCodes(const API_STATE &state, const Vec4 &vertex, Float &clipCodes, Integer const &viewportIndexes) @@ -708,15 +709,18 @@ public: primMask &= ~ComputeUserClipCullMask(pa, prim); } - // cull prims outside view frustum Float clipIntersection = ComputeClipCodeIntersection(); + // Mask out non-frustum codes + clipIntersection = SIMD_T::and_ps(clipIntersection, SIMD_T::castsi_ps(SIMD_T::set1_epi32(FRUSTUM_CLIP_MASK))); + + // cull prims outside view frustum int validMask = primMask & SimdHelper::cmpeq_ps_mask(clipIntersection, SIMD_T::setzero_ps()); // skip clipping for points uint32_t clipMask = 0; if (NumVertsPerPrim != 1) { - clipMask = primMask & ComputeClipMask(); + clipMask = validMask & ComputeClipMask(); } AR_EVENT(ClipInfoEvent(numInvoc, validMask, clipMask)); @@ -726,7 +730,7 @@ public: RDTSC_BEGIN(FEGuardbandClip, pa.pDC->drawId); // we have to clip tris, execute the clipper, which will also // call the binner - ClipSimd(prim, SIMD_T::vmask_ps(primMask), SIMD_T::vmask_ps(clipMask), pa, primId, viewportIdx, rtIdx); + ClipSimd(prim, SIMD_T::vmask_ps(validMask), SIMD_T::vmask_ps(clipMask), pa, primId, viewportIdx, rtIdx); RDTSC_END(FEGuardbandClip, 1); } else if (validMask) -- 2.30.2