Forum

R_DrawSurfaceBlock8_mip c functions speed

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

R_DrawSurfaceBlock8_mip c functions speed

Postby qbism » Wed Dec 29, 2010 4:46 am

Can you tell if the following is faster or slower by visual inspection? I can't. Original is in r_surf.c, and there's a comment- "use delta like asm"?
Code: Select all
void R_DrawSurfaceBlock8_mip0 (void)
{
   int            v, i, b, lightdelta, light; //qbism - lightdelta
   unsigned char   pix, *psource, *prowdest;

   psource = pbasesource;
   prowdest = prowdestbase;

   for (v=0 ; v<r_numvblocks ; v++)
   {
   // FIXME: make these locals?
   // FIXME: use delta rather than both right and left, like ASM? //qbism- something like that
        lightleft = r_lightptr[0];
      lightright = r_lightptr[1];
      lightdelta = (lightleft - lightright)>> 4; //qbism
      r_lightptr += r_lightwidth;
      lightleftstep = (r_lightptr[0] - lightleft) >> 4;
      lightrightstep = (r_lightptr[1] - lightright) >> 4;

      for (i=0 ; i<16 ; i++)
      {
         light = lightright;

         for (b=15; b>=0; b--)
         {
            pix = psource[b];
            prowdest[b] = ((unsigned char *)vid.colormap)
                  [(light & 0xFF00) + pix];
            light += lightdelta; //qbism
         }

         psource += sourcetstep;
         lightright += lightrightstep;
         lightleft += lightleftstep;
         lightdelta += (lightleftstep-lightrightstep) >>4; //qbism
         prowdest += surfrowbytes;
      }

      if (psource >= r_sourcemax)
         psource -= r_stepback;
   }
}
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Postby qbism » Sat Jan 01, 2011 5:23 am

Nevermind, this is no faster, just robs Peter to pay Paul. Plus it creates some weird pixels with brightlight.
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest