softgpu: Simplify mask check.

This performs a bit better.
This commit is contained in:
Unknown W. Brackets 2022-01-16 23:40:57 -08:00
parent 89bc87a388
commit abef17caca

View File

@ -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) {