From 4733f91a6a998751921de511e543633f26e23589 Mon Sep 17 00:00:00 2001 From: hamsham Date: Wed, 2 Jan 2019 15:30:51 -0800 Subject: [PATCH] Fixing broken depth test. --- soft_render/src/SR_FragmentProcessor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/soft_render/src/SR_FragmentProcessor.cpp b/soft_render/src/SR_FragmentProcessor.cpp index ef9c9a31..246d03b8 100644 --- a/soft_render/src/SR_FragmentProcessor.cpp +++ b/soft_render/src/SR_FragmentProcessor.cpp @@ -15,7 +15,7 @@ /*----------------------------------------------------------------------------- * Rendering setup -----------------------------------------------------------------------------*/ -//#define SR_RENDER_4_PIXELS +#define SR_RENDER_4_PIXELS @@ -458,11 +458,11 @@ void SR_FragmentProcessor::render_triangle(const uint_fast64_t binId, const SR_T // depth texture lookup will always be slow const math::vec4 z = depth * bcF; const __m128 depthTexels = depthBuffer->texel4(x, y).simd; - const math::vec4 depthTest {_mm_cmplt_ps(z.simd, depthTexels)}; + const math::vec4 depthTest {_mm_sub_ps(z.simd, depthTexels)}; for (int32_t i = 0; i < 4; ++i) { - if (depthTest[i] > 0.f || _mm_movemask_ps(bcF[i].simd)) + if (depthTest[i] < 0.f || _mm_movemask_ps(bcF[i].simd)) { continue; }