From 8aa6d5b5a9ef304880ec5d979fbb0a77ac65c262 Mon Sep 17 00:00:00 2001 From: eihrul Date: Mon, 4 Apr 2011 20:21:15 +0000 Subject: [PATCH] FinishBGRA8 optimization and fixes git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11021 d7cf8633-e32d-0410-b094-e92efae38249 --- dpsoftrast.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/dpsoftrast.c b/dpsoftrast.c index ece8be2f..3b0ec6e0 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -2100,11 +2100,17 @@ void DPSOFTRAST_Draw_Span_FinishBGRA8(DPSOFTRAST_State_Thread *thread, const DPS // the 4-item search must be aligned or else it stalls badly if ((x & 3) && !pixelmask[x]) { + if(pixelmask[x]) goto endmasked; x++; - if ((x & 3) && !pixelmask[x]) + if (x & 3) { + if(pixelmask[x]) goto endmasked; x++; - if ((x & 3) && !pixelmask[x]) x++; + if (x & 3) + { + if(pixelmask[x]) goto endmasked; + x++; + } } } while (*(unsigned int *)&pixelmask[x] == 0x00000000) @@ -2117,18 +2123,25 @@ void DPSOFTRAST_Draw_Span_FinishBGRA8(DPSOFTRAST_State_Thread *thread, const DPS if (x >= endx) break; } + endmasked: // find length of subspan subx = x + 1; #if 1 - if (x + 8 < endx) + if (subx + 8 < endx) { - if ((subx & 3) && pixelmask[subx]) + if (subx & 3) { + if(!pixelmask[subx]) goto endunmasked; subx++; - if ((subx & 3) && pixelmask[subx]) + if (subx & 3) { + if(!pixelmask[subx]) goto endunmasked; subx++; - if ((subx & 3) && pixelmask[subx]) subx++; + if (subx & 3) + { + if(!pixelmask[subx]) goto endunmasked; + subx++; + } } } while (*(unsigned int *)&pixelmask[subx] == 0x01010101) @@ -2140,6 +2153,7 @@ void DPSOFTRAST_Draw_Span_FinishBGRA8(DPSOFTRAST_State_Thread *thread, const DPS // the checks can overshoot, so make sure to clip it... if (subx > endx) subx = endx; + endunmasked: // now that we know the subspan length... process! switch(thread->fb_blendmode) { -- 2.39.2