From f268c57a296c53f3bdd239911cc5569ac08ae70f Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 4 Apr 2011 14:41:28 +0000 Subject: [PATCH] added simple affine check to accelerate texture fetches on 2D art git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11017 d7cf8633-e32d-0410-b094-e92efae38249 --- dpsoftrast.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dpsoftrast.c b/dpsoftrast.c index a784374e..b0a5a3ad 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -2626,6 +2626,7 @@ void DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(DPSOFTRAST_State_Thread *thread, __m128i subtc, substep, endsubtc; int filter; int mip; + int affine; // LordHavoc: optimized affine texturing case unsigned int * RESTRICT outi = (unsigned int *)out4ub; const unsigned char * RESTRICT pixelbase; DPSOFTRAST_Texture *texture = thread->texbound[texunitindex]; @@ -2645,6 +2646,7 @@ void DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(DPSOFTRAST_State_Thread *thread, outi[x] = k; return; } + affine = zf[startx] == zf[endx-1]; filter = texture->filter & DPSOFTRAST_TEXTURE_FILTER_LINEAR; DPSOFTRAST_CALCATTRIB(triangle, span, data, slope, arrayindex); flags = texture->flags; @@ -2663,7 +2665,7 @@ void DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(DPSOFTRAST_State_Thread *thread, { int nextsub = x + DPSOFTRAST_DRAW_MAXSUBSPAN, endsub = nextsub - 1; __m128 subscale = _mm_set1_ps(65536.0f/DPSOFTRAST_DRAW_MAXSUBSPAN); - if (nextsub >= endx) + if (nextsub >= endx || affine) { nextsub = endsub = endx-1; if (x < nextsub) subscale = _mm_set1_ps(65536.0f / (nextsub - x)); -- 2.39.2