From abef17cacab6fb62fa9becc8f6ea4b64c4c3b536 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jan 2022 23:40:57 -0800 Subject: [PATCH] softgpu: Simplify mask check. This performs a bit better. --- GPU/Software/Clipper.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/GPU/Software/Clipper.cpp b/GPU/Software/Clipper.cpp index 2a2a53b28a..f07f64614e 100644 --- a/GPU/Software/Clipper.cpp +++ b/GPU/Software/Clipper.cpp @@ -31,17 +31,14 @@ namespace Clipper { enum { SKIP_FLAG = -1, - CLIP_POS_Z_BIT = 0x10, CLIP_NEG_Z_BIT = 0x20, }; -static inline int CalcClipMask(const ClipCoords& v) -{ - int mask = 0; +static inline int CalcClipMask(const ClipCoords &v) { // This checks `x / w` compared to 1 or -1, skipping the division. - if (v.z > v.w) mask |= CLIP_POS_Z_BIT; - if (v.z < -v.w) mask |= CLIP_NEG_Z_BIT; - return mask; + if (v.z < -v.w) + return -1; + return 0; } inline bool different_signs(float x, float y) {