From f4454d2e00f3b078007e9a25b7ede8aebc7f394b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Dec 2016 19:32:54 +0100 Subject: [PATCH] - minor, but very effective optimization for R_DrawSpanMasked: Do not store the texel value in a byte. Store it in a local int variable. This allows the compiler to read it with a zero extending instruction instead of using a byte reading instruction and then later having it to convert to an int anyway. This removes one instruction from the loop which results in a 10% performance increase on 32 bit. --- src/r_draw.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a48fc7195..fba01cbfe 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -1037,7 +1037,7 @@ void R_SetupSpanBits(FTexture *tex) { ds_xbits--; } - if ((1 << ds_ybits) > tex->GetHeight()) + if ((1 << ds_ybits) > tex->GetHeight()) { ds_ybits--; } @@ -1048,7 +1048,7 @@ void R_SetupSpanBits(FTexture *tex) // // Draws the actual span. -#ifndef X86_ASM +//#ifndef X86_ASM void R_DrawSpanP_C (void) { dsfixed_t xfrac; @@ -1147,7 +1147,7 @@ void R_DrawSpanMaskedP_C (void) // 64x64 is the most common case by far, so special case it. do { - BYTE texdata; + int texdata; spot = ((xfrac>>(32-6-6))&(63*64)) + (yfrac>>(32-6)); texdata = source[spot]; @@ -1167,7 +1167,7 @@ void R_DrawSpanMaskedP_C (void) int xmask = ((1 << ds_xbits) - 1) << ds_ybits; do { - BYTE texdata; + int texdata; spot = ((xfrac >> xshift) & xmask) + (yfrac >> yshift); texdata = source[spot]; @@ -1181,7 +1181,7 @@ void R_DrawSpanMaskedP_C (void) } while (--count); } } -#endif +//#endif void R_DrawSpanTranslucent (void) {