diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea07dec7b..e62f4d412 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1045,9 +1045,8 @@ set( FASTMATH_PCH_SOURCES r_poly_intersection.cpp r_3dfloors.cpp r_bsp.cpp - r_draw.cpp + r_draw_tc.cpp r_draw_rgba.cpp - r_drawt.cpp r_drawt_rgba.cpp r_drawers.cpp r_thread.cpp diff --git a/src/asm_ia32/tmap.asm b/src/asm_ia32/tmap.asm index d9e689ee1..2096b9222 100644 --- a/src/asm_ia32/tmap.asm +++ b/src/asm_ia32/tmap.asm @@ -598,667 +598,6 @@ dmsdone add esp,8 -;*---------------------------------------------------------------------- -;* -;* R_DrawColumnP -;* -;*---------------------------------------------------------------------- - -GLOBAL @R_DrawColumnP_ASM@0 -GLOBAL _R_DrawColumnP_ASM -GLOBAL R_DrawColumnP_ASM - - align 16 - -R_DrawColumnP_ASM: -_R_DrawColumnP_ASM: -@R_DrawColumnP_ASM@0: - -; count = dc_yh - dc_yl; - - mov ecx,[dc_count] - test ecx,ecx - jle near rdcpret ; count <= 0: nothing to do, so leave - - push ebp ; save registers - push ebx - push edi - push esi - -; dest = ylookup[dc_yl] + dc_x + dc_destorg; - - mov edi,[dc_dest] - mov ebp,ecx - mov ebx,[dc_texturefrac] ; ebx = frac -rdcp1: sub edi,SPACEFILLER4 - mov ecx,ebx - shr ecx,16 - mov esi,[dc_source] - mov edx,[dc_iscale] - mov eax,[dc_colormap] - - cmp BYTE [CPU+66],byte 5 - jg rdcploop2 - - align 16 - -; The registers should now look like this: -; -; [31 .. 16][15 .. 8][7 .. 0] -; eax [colormap ] -; ebx [yi ][yf ] -; ecx [scratch ] -; edx [dyi ][dyf ] -; esi [source texture column ] -; edi [destination screen pointer ] -; ebp [counter ] -; - - -; Note the partial register stalls on anything better than a Pentium -; That's why there are two versions of this loop. - -rdcploop: - mov cl,[esi+ecx] ; Fetch texel - xor ch,ch - add ebx,edx ; increment frac -rdcp2: add edi,SPACEFILLER4 ; increment destination pointer - mov cl,[eax+ecx] ; colormap texel - mov [edi],cl ; Store texel - mov ecx,ebx - shr ecx,16 - dec ebp - jnz rdcploop ; loop - - pop esi - pop edi - pop ebx - pop ebp -rdcpret: - ret - - align 16 - -rdcploop2: - movzx ecx,byte [esi+ecx] ; Fetch texel - add ebx,edx ; increment frac - mov cl,[eax+ecx] ; colormap texel -rdcp3: add edi,SPACEFILLER4 ; increment destination pointer - mov [edi],cl ; Store texel - mov ecx,ebx - shr ecx,16 - dec ebp - jnz rdcploop2 ; loop - - pop esi - pop edi - pop ebx - pop ebp - ret - - - -;*---------------------------------------------------------------------- -;* -;* R_DrawFuzzColumnP -;* -;*---------------------------------------------------------------------- - -GLOBAL @R_DrawFuzzColumnP_ASM@0 -GLOBAL _R_DrawFuzzColumnP_ASM -GLOBAL R_DrawFuzzColumnP_ASM - - align 16 - -R_DrawFuzzColumnP_ASM: -_R_DrawFuzzColumnP_ASM: -@R_DrawFuzzColumnP_ASM@0: - -; Adjust borders. Low... - mov eax,[dc_yl] - push ebx - push esi - push edi - push ebp - - cmp eax,0 - jg .ylok - - mov eax,1 - nop - -; ...and high. -.ylok mov edx,[fuzzviewheight] - mov esi,[dc_yh] - cmp esi,edx - jle .yhok - - mov esi,edx - nop - -.yhok mov edx,[dc_x] - sub esi,eax ; esi = count - js near .dfcdone ; Zero length (or less) - - mov edi,[ylookup+eax*4] - mov ebx,edx - add edi,[dc_destorg] - mov eax,[NormalLight] - mov ecx,[fuzzpos] - add edi,ebx - add eax,256*6 - inc esi - mov ebp,[dc_pitch] - mov edx,FUZZTABLE - test ecx,ecx - je .fuzz0 - -; -; esi = count -; edi = dest -; ecx = fuzzpos -; eax = colormap 6 -; - -; first loop: end with fuzzpos or count 0, whichever happens first - - sub edx,ecx ; edx = # of entries left in fuzzoffset - mov ebx,esi - cmp esi,edx - jle .enuf - mov esi,edx -.enuf sub ebx,esi - mov edx,[fuzzoffset+ecx*4] - push ebx - xor ebx,ebx - -.loop1 inc ecx - mov bl,[edi+edx] - dec esi - mov bl,[eax+ebx] - mov [edi],bl - lea edi,[edi+ebp] - mov edx,[fuzzoffset+ecx*4] - jnz .loop1 - -; second loop: Chunk it into groups of FUZZTABLE-sized spans and do those - - pop esi - cmp ecx,FUZZTABLE - jl .savefuzzpos - xor ecx,ecx - nop -.fuzz0 cmp esi,FUZZTABLE - jl .chunked - -.oloop lea edx,[esi-FUZZTABLE] - mov esi,FUZZTABLE - push edx - mov edx,[fuzzoffset+ecx*4] - -.iloop inc ecx - mov bl,[edi+edx] - dec esi - mov bl,[eax+ebx] - mov [edi],bl - lea edi,[edi+ebp] - mov edx,[fuzzoffset+ecx*4] - jnz .iloop - - pop esi - xor ecx,ecx - cmp esi,FUZZTABLE - jge .oloop - -; third loop: Do whatever is left - -.chunked: - test esi,esi - jle .savefuzzpos - mov edx,[fuzzoffset+ecx*4] - nop - -.loop3 inc ecx - mov bl,[edi+edx] - dec esi - mov bl,[eax+ebx] - mov [edi],bl - lea edi,[edi+ebp] - mov edx,[fuzzoffset+ecx*4] - jnz .loop3 - -.savefuzzpos: - mov [fuzzpos],ecx -.dfcdone: - pop ebp - pop edi - pop esi - pop ebx - ret - - -;*---------------------------------------------------------------------- -;* -;* rt_copy1col_asm -;* -;* ecx = hx -;* edx = sx -;* [esp+4] = yl -;* [esp+8] = yh -;* -;*---------------------------------------------------------------------- - -GLOBAL @rt_copy1col_asm@16 -GLOBAL _rt_copy1col_asm -GLOBAL rt_copy1col_asm - - align 16 - -rt_copy1col_asm: -_rt_copy1col_asm: - pop eax - mov edx,[esp+4*3] - mov ecx,[esp+4*2] - push edx - push ecx - mov ecx,[esp+4*2] - mov edx,[esp+4*3] - push eax - -@rt_copy1col_asm@16: - mov eax, [esp+4] - push ebx - mov ebx, [esp+12] - push esi - sub ebx, eax - push edi - js .done - - lea esi,[eax*4] - inc ebx ; ebx = count - mov eax,edx - add ecx,esi - mov edi,[ylookup+esi] - add ecx,[dc_temp] ; ecx = source - mov esi,[dc_pitch] ; esi = pitch - add eax,edi ; eax = dest - add eax,[dc_destorg] - - shr ebx,1 - jnc .even - - mov dl,[ecx] - add ecx,4 - mov [eax],dl - add eax,esi - -.even and ebx,ebx - jz .done - -.loop mov dl,[ecx] - mov dh,[ecx+4] - mov [eax],dl - mov [eax+esi],dh - add ecx,8 - lea eax,[eax+esi*2] - dec ebx - jnz .loop - -.done pop edi - pop esi - pop ebx - ret 8 - -;*---------------------------------------------------------------------- -;* -;* rt_copy4cols_asm -;* -;* ecx = sx -;* edx = yl -;* [esp+4] = yh -;* -;*---------------------------------------------------------------------- - -GLOBAL @rt_copy4cols_asm@12 -GLOBAL _rt_copy4cols_asm -GLOBAL rt_copy4cols_asm - - align 16 - -rt_copy4cols_asm: -_rt_copy4cols_asm: - pop eax - mov ecx,[esp+8] - mov edx,[esp+4] - push ecx - mov ecx,[esp+4] - push eax - -@rt_copy4cols_asm@12: - push ebx - mov ebx,[esp+8] - push esi - sub ebx,edx - push edi - js .done - - inc ebx ; ebx = count - mov eax,ecx - mov esi,[ylookup+edx*4] - mov ecx,[dc_temp] - add eax,esi ; eax = dest - add eax,[dc_destorg] - lea ecx,[ecx+edx*4] ; ecx = source - mov edx,[dc_pitch] ; edx = pitch - - shr ebx,1 - jnc .even - - mov esi,[ecx] - add ecx,4 - mov [eax],esi - add eax,edx - -.even and ebx,ebx - jz .done - -.loop mov esi,[ecx] - mov edi,[ecx+4] - mov [eax],esi - mov [eax+edx],edi - add ecx,8 - lea eax,[eax+edx*2] - dec ebx - jnz .loop - -.done pop edi - pop esi - pop ebx - ret 4 - -;*---------------------------------------------------------------------- -;* -;* rt_map1col_asm -;* -;* ecx = hx -;* edx = sx -;* [esp+4] = yl -;* [esp+8] = yh -;* -;*---------------------------------------------------------------------- - -GLOBAL @rt_map1col_asm@16 -GLOBAL _rt_map1col_asm -GLOBAL rt_map1col_asm - - align 16 - -rt_map1col_asm: -_rt_map1col_asm: - pop eax - mov edx,[esp+4*3] - mov ecx,[esp+4*2] - push edx - push ecx - mov ecx,[esp+4*2] - mov edx,[esp+4*3] - push eax - -@rt_map1col_asm@16: - mov eax,[esp+4] - push ebx - mov ebx,[esp+12] - push ebp - push esi - sub ebx, eax - push edi - js .done - - lea edi,[eax*4] - mov esi,[dc_colormap] ; esi = colormap - inc ebx ; ebx = count - mov eax,edx - lea ebp,[ecx+edi] ; ebp = source - add ebp,[dc_temp] - mov ecx,[ylookup+edi] - mov edi,[dc_pitch] ; edi = pitch - add eax,ecx ; eax = dest - xor ecx,ecx - xor edx,edx - add eax,[dc_destorg] - - shr ebx,1 - jnc .even - - mov dl,[ebp] - add ebp,4 - mov dl,[esi+edx] - mov [eax],dl - add eax,edi - -.even and ebx,ebx - jz .done - -.loop mov dl,[ebp] - mov cl,[ebp+4] - add ebp,8 - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax],dl - mov [eax+edi],cl - dec ebx - lea eax,[eax+edi*2] - jnz .loop - -.done pop edi - pop esi - pop ebp - pop ebx - ret 8 - -;*---------------------------------------------------------------------- -;* -;* rt_map4cols_asm -;* -;* rt_map4cols_asm1 is for PPro and above -;* rt_map4cols_asm2 is for Pentium and below -;* -;* ecx = sx -;* edx = yl -;* [esp+4] = yh -;* -;*---------------------------------------------------------------------- - -GLOBAL @rt_map4cols_asm1@12 -GLOBAL _rt_map4cols_asm1 -GLOBAL rt_map4cols_asm1 - - align 16 - -rt_map4cols_asm1: -_rt_map4cols_asm1: - pop eax - mov ecx,[esp+8] - mov edx,[esp+4] - push ecx - mov ecx,[esp+4] - push eax - -@rt_map4cols_asm1@12: - push ebx - mov ebx,[esp+8] - push ebp - push esi - sub ebx,edx - push edi - js near .done - - mov esi,[dc_colormap] ; esi = colormap - shl edx,2 - mov eax,ecx - inc ebx ; ebx = count - mov edi,[ylookup+edx] - mov ebp,[dc_temp] - add ebp,edx ; ebp = source - add eax,edi ; eax = dest - mov edi,[dc_pitch] ; edi = pitch - add eax,[dc_destorg] - xor ecx,ecx - xor edx,edx - - shr ebx,1 - jnc .even - - mov dl,[ebp] - mov cl,[ebp+1] - add ebp,4 - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax],dl - mov [eax+1],cl - mov dl,[ebp-2] - mov cl,[ebp-1] - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax+2],dl - mov [eax+3],cl - add eax,edi - -.even and ebx,ebx - jz .done - -.loop: - mov dl,[ebp] - mov cl,[ebp+1] - add ebp,8 - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax],dl - mov [eax+1],cl - mov dl,[ebp-6] - mov cl,[ebp-5] - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax+2],dl - mov [eax+3],cl - mov dl,[ebp-4] - mov cl,[ebp-3] - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax+edi],dl - mov [eax+edi+1],cl - mov dl,[ebp-2] - mov cl,[ebp-1] - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax+edi+2],dl - mov [eax+edi+3],cl - lea eax,[eax+edi*2] - dec ebx - - jnz .loop - -.done pop edi - pop esi - pop ebp - pop ebx - ret 4 - -GLOBAL @rt_map4cols_asm2@12 -GLOBAL _rt_map4cols_asm2 -GLOBAL rt_map4cols_asm2 - - align 16 - -rt_map4cols_asm2: -_rt_map4cols_asm2: - pop eax - mov ecx,[esp+8] - mov edx,[esp+4] - push ecx - mov ecx,[esp+4] - push eax - -@rt_map4cols_asm2@12: - push ebx - mov ebx,[esp+8] - push ebp - push esi - sub ebx,edx - push edi - js near .done - - mov esi,[dc_colormap] ; esi = colormap - shl edx,2 - mov eax,ecx - inc ebx ; ebx = count - mov edi,[ylookup+edx] - mov ebp,[dc_temp] - add ebp,edx ; ebp = source - add eax,edi ; eax = dest - mov edi,[dc_pitch] ; edi = pitch - add eax,[dc_destorg] - xor ecx,ecx - xor edx,edx - - shr ebx,1 - jnc .even - - mov dl,[ebp] - mov cl,[ebp+1] - add ebp,4 - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax],dl - mov [eax+1],cl - mov dl,[ebp-2] - mov cl,[ebp-1] - mov dl,[esi+edx] - mov cl,[esi+ecx] - mov [eax+2],dl - mov [eax+3],cl - add eax,edi - -.even and ebx,ebx - jz .done - -.loop: - mov dl,[ebp+3] - mov ch,[esi+edx] - mov dl,[ebp+2] - mov cl,[esi+edx] - shl ecx,16 - mov dl,[ebp+1] - mov ch,[esi+edx] - mov dl,[ebp] - mov cl,[esi+edx] - mov [eax],ecx - add eax,edi - - mov dl,[ebp+7] - mov ch,[esi+edx] - mov dl,[ebp+6] - mov cl,[esi+edx] - shl ecx,16 - mov dl,[ebp+5] - mov ch,[esi+edx] - mov dl,[ebp+4] - mov cl,[esi+edx] - mov [eax],ecx - add eax,edi - add ebp,8 - dec ebx - - jnz .loop - -.done pop edi - pop esi - pop ebp - pop ebx - ret 4 - - align 16 - GLOBAL rt_shaded4cols_asm GLOBAL _rt_shaded4cols_asm @@ -1648,9 +987,6 @@ ASM_PatchPitch: _ASM_PatchPitch: @ASM_PatchPitch@0: mov eax,[dc_pitch] - mov [rdcp1+2],eax - mov [rdcp2+2],eax - mov [rdcp3+2],eax mov [s4p+1],eax mov [a4p+1],eax mov [ac4p+1],eax diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 92581f01b..8004f0dfc 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -63,6 +63,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); namespace swrenderer { + using namespace drawerargs; seg_t* curline; side_t* sidedef; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index cfa218f14..6f58ec2a3 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -38,8 +38,6 @@ #include "r_data/r_translate.h" #include "v_palette.h" #include "r_data/colormaps.h" -#include "r_plane.h" -#include "r_draw_rgba.h" #include "gi.h" #include "stats.h" @@ -47,14 +45,6 @@ #undef RANGECHECK -EXTERN_CVAR (Int, r_drawfuzz) -EXTERN_CVAR (Bool, r_drawtrans) -EXTERN_CVAR (Float, transsouls) -EXTERN_CVAR (Int, r_columnmethod) - -namespace swrenderer -{ - // status bar height at bottom of screen // [RH] status bar position at bottom of screen extern int ST_Y; @@ -72,7 +62,6 @@ BYTE* viewimage; extern "C" { int ylookup[MAXHEIGHT]; BYTE *dc_destorg; -int dc_destheight; } int scaledviewwidth; @@ -80,71 +69,10 @@ int scaledviewwidth; // These get changed depending on the current // screen depth and asm/no asm. void (*R_DrawColumnHoriz)(void); -void (*R_DrawColumn)(void); -void (*R_FillColumn)(void); -void (*R_FillAddColumn)(void); -void (*R_FillAddClampColumn)(void); -void (*R_FillSubClampColumn)(void); -void (*R_FillRevSubClampColumn)(void); -void (*R_DrawAddColumn)(void); -void (*R_DrawTlatedAddColumn)(void); -void (*R_DrawAddClampColumn)(void); -void (*R_DrawAddClampTranslatedColumn)(void); -void (*R_DrawSubClampColumn)(void); -void (*R_DrawSubClampTranslatedColumn)(void); -void (*R_DrawRevSubClampColumn)(void); -void (*R_DrawRevSubClampTranslatedColumn)(void); -void (*R_DrawFuzzColumn)(void); void (*R_DrawTranslatedColumn)(void); void (*R_DrawShadedColumn)(void); void (*R_DrawSpan)(void); void (*R_DrawSpanMasked)(void); -void (*R_DrawSpanTranslucent)(void); -void (*R_DrawSpanMaskedTranslucent)(void); -void (*R_DrawSpanAddClamp)(void); -void (*R_DrawSpanMaskedAddClamp)(void); -void (*R_FillSpan)(void); -void (*R_FillColumnHoriz)(void); -void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); -void (*R_MapTiltedPlane)(int y, int x1); -void (*R_MapColoredPlane)(int y, int x1); -void (*R_DrawParticle)(vissprite_t *); -void (*R_SetupDrawSlab)(FSWColormap *base_colormap, float light, int shade); -void (*R_DrawSlab)(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); -fixed_t (*tmvline1_add)(); -void (*tmvline4_add)(); -fixed_t (*tmvline1_addclamp)(); -void (*tmvline4_addclamp)(); -fixed_t (*tmvline1_subclamp)(); -void (*tmvline4_subclamp)(); -fixed_t (*tmvline1_revsubclamp)(); -void (*tmvline4_revsubclamp)(); -void (*rt_copy1col)(int hx, int sx, int yl, int yh); -void (*rt_copy4cols)(int sx, int yl, int yh); -void (*rt_shaded1col)(int hx, int sx, int yl, int yh); -void (*rt_shaded4cols)(int sx, int yl, int yh); -void (*rt_map1col)(int hx, int sx, int yl, int yh); -void (*rt_add1col)(int hx, int sx, int yl, int yh); -void (*rt_addclamp1col)(int hx, int sx, int yl, int yh); -void (*rt_subclamp1col)(int hx, int sx, int yl, int yh); -void (*rt_revsubclamp1col)(int hx, int sx, int yl, int yh); -void (*rt_tlate1col)(int hx, int sx, int yl, int yh); -void (*rt_tlateadd1col)(int hx, int sx, int yl, int yh); -void (*rt_tlateaddclamp1col)(int hx, int sx, int yl, int yh); -void (*rt_tlatesubclamp1col)(int hx, int sx, int yl, int yh); -void (*rt_tlaterevsubclamp1col)(int hx, int sx, int yl, int yh); -void (*rt_map4cols)(int sx, int yl, int yh); -void (*rt_add4cols)(int sx, int yl, int yh); -void (*rt_addclamp4cols)(int sx, int yl, int yh); -void (*rt_subclamp4cols)(int sx, int yl, int yh); -void (*rt_revsubclamp4cols)(int sx, int yl, int yh); -void (*rt_tlate4cols)(int sx, int yl, int yh); -void (*rt_tlateadd4cols)(int sx, int yl, int yh); -void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); -void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); -void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); -void (*rt_initcols)(BYTE *buffer); -void (*rt_span_coverage)(int x, int start, int stop); // // R_DrawColumn @@ -155,27 +83,18 @@ extern "C" { int dc_pitch=0xABadCafe; // [RH] Distance between rows lighttable_t* dc_colormap; -FSWColormap *dc_fcolormap; -ShadeConstants dc_shade_constants; -fixed_t dc_light; int dc_x; int dc_yl; int dc_yh; fixed_t dc_iscale; fixed_t dc_texturefrac; -uint32_t dc_textureheight; int dc_color; // [RH] Color for column filler DWORD dc_srccolor; -uint32_t dc_srccolor_bgra; DWORD *dc_srcblend; // [RH] Source and destination DWORD *dc_destblend; // blending lookups -fixed_t dc_srcalpha; // Alpha value used by dc_srcblend -fixed_t dc_destalpha; // Alpha value used by dc_destblend // first pixel in a column (possibly virtual) const BYTE* dc_source; -const BYTE* dc_source2; -uint32_t dc_texturefracx; BYTE* dc_dest; int dc_count; @@ -183,10 +102,8 @@ int dc_count; DWORD vplce[4]; DWORD vince[4]; BYTE* palookupoffse[4]; -fixed_t palookuplight[4]; const BYTE* bufplce[4]; const BYTE* bufplce2[4]; -uint32_t buftexturefracx[4]; uint32_t bufheight[4]; // just for profiling @@ -198,9 +115,8 @@ BYTE *dc_translation; BYTE shadetables[NUMCOLORMAPS*16*256]; FDynamicColormap ShadeFakeColormap[16]; BYTE identitymap[256]; -FDynamicColormap identitycolormap; -bool drawer_needs_pal_input; +EXTERN_CVAR (Int, r_columnmethod) void R_InitShadeMaps() @@ -240,10 +156,6 @@ void R_InitShadeMaps() { identitymap[i] = i; } - identitycolormap.Color = ~0u; - identitycolormap.Desaturate = 0; - identitycolormap.Next = NULL; - identitycolormap.Maps = identitymap; } /************************************/ @@ -252,7 +164,6 @@ void R_InitShadeMaps() /* */ /************************************/ -#ifndef X86_ASM // // A column is a vertical slice/span from a wall texture that, // given the DOOM style restrictions on the view orientation, @@ -260,7 +171,7 @@ void R_InitShadeMaps() // Thus a special case loop for very fast rendering can // be used. It has also been used with Wolfenstein 3D. // -void R_DrawColumnP_C (void) +void R_DrawColumn (void) { int count; BYTE* dest; @@ -303,10 +214,10 @@ void R_DrawColumnP_C (void) } while (--count); } } -#endif + // [RH] Just fills a column with a color -void R_FillColumnP_C (void) +void R_FillColumnP (void) { int count; BYTE* dest; @@ -330,7 +241,7 @@ void R_FillColumnP_C (void) } } -void R_FillAddColumn_C (void) +void R_FillAddColumn (void) { int count; BYTE *dest; @@ -354,9 +265,10 @@ void R_FillAddColumn_C (void) *dest = RGB32k.All[bg & (bg>>15)]; dest += pitch; } while (--count); + } -void R_FillAddClampColumn_C (void) +void R_FillAddClampColumn (void) { int count; BYTE *dest; @@ -386,9 +298,10 @@ void R_FillAddClampColumn_C (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); + } -void R_FillSubClampColumn_C (void) +void R_FillSubClampColumn (void) { int count; BYTE *dest; @@ -417,9 +330,10 @@ void R_FillSubClampColumn_C (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); + } -void R_FillRevSubClampColumn_C (void) +void R_FillRevSubClampColumn (void) { int count; BYTE *dest; @@ -448,11 +362,13 @@ void R_FillRevSubClampColumn_C (void) *dest = RGB32k.All[a & (a>>15)]; dest += pitch; } while (--count); + } // // Spectre/Invisibility. // +#define FUZZTABLE 50 extern "C" { @@ -490,13 +406,12 @@ void R_InitFuzzTable (int fuzzoff) } } -#ifndef X86_ASM // // Creates a fuzzy image by copying pixels from adjacent ones above and below. // Used with an all black colormap, this could create the SHADOW effect, // i.e. spectres and invisible players. // -void R_DrawFuzzColumnP_C (void) +void R_DrawFuzzColumn (void) { int count; BYTE *dest; @@ -566,7 +481,6 @@ void R_DrawFuzzColumnP_C (void) fuzzpos = fuzz; } } -#endif // // R_DrawTranlucentColumn @@ -725,8 +639,8 @@ void R_DrawTlatedAddColumnP_C (void) fg = fg2rgb[fg]; bg = bg2rgb[bg]; - fg = (fg + bg) | 0x1f07c1f; - *dest = RGB32k.All[fg & (fg >> 15)]; + fg = (fg+bg) | 0x1f07c1f; + *dest = RGB32k.All[fg & (fg>>15)]; dest += pitch; frac += fracstep; } while (--count); @@ -1015,6 +929,8 @@ void R_DrawRevSubClampTranslatedColumnP_C () } } + + // // R_DrawSpan // With DOOM style restrictions on view orientation, @@ -1042,10 +958,7 @@ int ds_y; int ds_x1; int ds_x2; -FSWColormap* ds_fcolormap; lighttable_t* ds_colormap; -ShadeConstants ds_shade_constants; -dsfixed_t ds_light; dsfixed_t ds_xfrac; dsfixed_t ds_yfrac; @@ -1053,11 +966,9 @@ dsfixed_t ds_xstep; dsfixed_t ds_ystep; int ds_xbits; int ds_ybits; -double ds_lod; // start of a floor/ceiling tile image const BYTE* ds_source; -bool ds_source_mipmapped; // just for profiling int dscount; @@ -1078,14 +989,13 @@ extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource; // //========================================================================== -void R_SetSpanSource(FTexture *tex) +void R_SetSpanSource(const BYTE *pixels) { - ds_source = r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels(); - ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; + ds_source = pixels; #ifdef X86_ASM - if (!r_swtruecolor && ds_cursource != ds_source) + if (ds_cursource != ds_source) { - R_SetSpanSource_ASM(ds_source); + R_SetSpanSource_ASM(pixels); } #endif } @@ -1098,11 +1008,11 @@ void R_SetSpanSource(FTexture *tex) // //========================================================================== -void R_SetSpanColormap(FDynamicColormap *colormap, int shade) +void R_SetSpanColormap(BYTE *colormap) { - R_SetDSColorMapLight(colormap, 0, shade); + ds_colormap = colormap; #ifdef X86_ASM - if (!r_swtruecolor && ds_colormap != ds_curcolormap) + if (ds_colormap != ds_curcolormap) { R_SetSpanColormap_ASM (ds_colormap); } @@ -1126,19 +1036,18 @@ void R_SetupSpanBits(FTexture *tex) { ds_xbits--; } - if ((1 << ds_ybits) > tex->GetHeight()) + if ((1 << ds_ybits) > tex->GetHeight()) { ds_ybits--; } #ifdef X86_ASM - if (!r_swtruecolor) - R_SetSpanSize_ASM (ds_xbits, ds_ybits); + R_SetSpanSize_ASM (ds_xbits, ds_ybits); #endif } // // Draws the actual span. -#ifndef X86_ASM +//#ifndef X86_ASM void R_DrawSpanP_C (void) { dsfixed_t xfrac; @@ -1173,7 +1082,6 @@ void R_DrawSpanP_C (void) if (ds_xbits == 6 && ds_ybits == 6) { // 64x64 is the most common case by far, so special case it. - do { // Current texture index in u,v. @@ -1238,7 +1146,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]; @@ -1258,7 +1166,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]; @@ -1272,9 +1180,9 @@ void R_DrawSpanMaskedP_C (void) } while (--count); } } -#endif +//#endif -void R_DrawSpanTranslucentP_C (void) +void R_DrawSpanTranslucent (void) { dsfixed_t xfrac; dsfixed_t yfrac; @@ -1334,7 +1242,7 @@ void R_DrawSpanTranslucentP_C (void) } } -void R_DrawSpanMaskedTranslucentP_C (void) +void R_DrawSpanMaskedTranslucent (void) { dsfixed_t xfrac; dsfixed_t yfrac; @@ -1408,7 +1316,7 @@ void R_DrawSpanMaskedTranslucentP_C (void) } } -void R_DrawSpanAddClampP_C (void) +void R_DrawSpanAddClamp (void) { dsfixed_t xfrac; dsfixed_t yfrac; @@ -1474,7 +1382,7 @@ void R_DrawSpanAddClampP_C (void) } } -void R_DrawSpanMaskedAddClampP_C (void) +void R_DrawSpanMaskedAddClamp (void) { dsfixed_t xfrac; dsfixed_t yfrac; @@ -1555,12 +1463,11 @@ void R_DrawSpanMaskedAddClampP_C (void) } // [RH] Just fill a span with a color -void R_FillSpan_C (void) +void R_FillSpan (void) { memset (ylookup[ds_y] + ds_x1 + dc_destorg, ds_color, ds_x2 - ds_x1 + 1); } - // Draw a voxel slab // // "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman @@ -1657,19 +1564,17 @@ extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *v // wallscan stuff, in C -int vlinebits; -int mvlinebits; - #ifndef X86_ASM static DWORD vlinec1 (); +static int vlinebits; DWORD (*dovline1)() = vlinec1; DWORD (*doprevline1)() = vlinec1; #ifdef X64_ASM extern "C" void vlinetallasm4(); +#define dovline4 vlinetallasm4 extern "C" void setupvlinetallasm (int); -void (*dovline4)() = vlinetallasm4; #else static void vlinec4 (); void (*dovline4)() = vlinec4; @@ -1677,6 +1582,7 @@ void (*dovline4)() = vlinec4; static DWORD mvlinec1(); static void mvlinec4(); +static int mvlinebits; DWORD (*domvline1)() = mvlinec1; void (*domvline4)() = mvlinec4; @@ -1710,12 +1616,6 @@ void (*domvline4)() = mvlineasm4; void setupvline (int fracbits) { - if (r_swtruecolor) - { - vlinebits = fracbits; - return; - } - #ifdef X86_ASM if (CPU.Family <= 5) { @@ -1771,9 +1671,8 @@ DWORD vlinec1 () return frac; } -#endif -#if !defined(X86_ASM) +#ifndef _M_X64 void vlinec4 () { BYTE *dest = dc_dest; @@ -1790,24 +1689,54 @@ void vlinec4 () dest += dc_pitch; } while (--count); } +#else +// Optimized version for 64 bit. In 64 bit mode, accessing global variables is very expensive so even though +// this exceeds the register count, loading all those values into a local variable is faster than not loading all of them. +void vlinec4() +{ + BYTE *dest = dc_dest; + int count = dc_count; + int bits = vlinebits; + DWORD place; + auto pal0 = palookupoffse[0]; + auto pal1 = palookupoffse[1]; + auto pal2 = palookupoffse[2]; + auto pal3 = palookupoffse[3]; + auto buf0 = bufplce[0]; + auto buf1 = bufplce[1]; + auto buf2 = bufplce[2]; + auto buf3 = bufplce[3]; + const auto vince0 = vince[0]; + const auto vince1 = vince[1]; + const auto vince2 = vince[2]; + const auto vince3 = vince[3]; + auto vplce0 = vplce[0]; + auto vplce1 = vplce[1]; + auto vplce2 = vplce[2]; + auto vplce3 = vplce[3]; + + do + { + dest[0] = pal0[buf0[(place = vplce0) >> bits]]; vplce0 = place + vince0; + dest[1] = pal1[buf1[(place = vplce1) >> bits]]; vplce1 = place + vince1; + dest[2] = pal2[buf2[(place = vplce2) >> bits]]; vplce2 = place + vince2; + dest[3] = pal3[buf3[(place = vplce3) >> bits]]; vplce3 = place + vince3; + dest += dc_pitch; + } while (--count); +} +#endif + #endif void setupmvline (int fracbits) { - if (!r_swtruecolor) - { #if defined(X86_ASM) - setupmvlineasm(fracbits); - domvline1 = mvlineasm1; - domvline4 = mvlineasm4; + setupmvlineasm (fracbits); + domvline1 = mvlineasm1; + domvline4 = mvlineasm4; #else - mvlinebits = fracbits; + mvlinebits = fracbits; #endif - } - else - { - mvlinebits = fracbits; - } } #if !defined(X86_ASM) @@ -1889,7 +1818,7 @@ static void R_DrawFogBoundaryLine (int y, int x) } while (++x <= x2); } -void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) +void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip) { // This is essentially the same as R_MapVisPlane but with an extra step // to create new horizontal spans whenever the light changes enough that @@ -1909,7 +1838,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) clearbufshort (spanend+t2, b2-t2, x); } - R_SetColorMapLight(basecolormap, (float)light, wallshade); + dc_colormap = basecolormapdata + (rcolormap << COLORMAPSHIFT); for (--x; x >= x1; --x) { @@ -1934,7 +1863,7 @@ void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip) clearbufshort (spanend+t2, b2-t2, x); } rcolormap = lcolormap; - R_SetColorMapLight(basecolormap, (float)light, wallshade); + dc_colormap = basecolormapdata + (lcolormap << COLORMAPSHIFT); } else { @@ -1985,7 +1914,7 @@ void setuptmvline (int bits) tmvlinebits = bits; } -fixed_t tmvline1_add_C () +fixed_t tmvline1_add () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2016,7 +1945,7 @@ fixed_t tmvline1_add_C () return frac; } -void tmvline4_add_C () +void tmvline4_add () { BYTE *dest = dc_dest; int count = dc_count; @@ -2043,7 +1972,7 @@ void tmvline4_add_C () } while (--count); } -fixed_t tmvline1_addclamp_C () +fixed_t tmvline1_addclamp () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2079,7 +2008,7 @@ fixed_t tmvline1_addclamp_C () return frac; } -void tmvline4_addclamp_C () +void tmvline4_addclamp () { BYTE *dest = dc_dest; int count = dc_count; @@ -2111,7 +2040,7 @@ void tmvline4_addclamp_C () } while (--count); } -fixed_t tmvline1_subclamp_C () +fixed_t tmvline1_subclamp () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2146,7 +2075,7 @@ fixed_t tmvline1_subclamp_C () return frac; } -void tmvline4_subclamp_C () +void tmvline4_subclamp () { BYTE *dest = dc_dest; int count = dc_count; @@ -2177,7 +2106,7 @@ void tmvline4_subclamp_C () } while (--count); } -fixed_t tmvline1_revsubclamp_C () +fixed_t tmvline1_revsubclamp () { DWORD fracstep = dc_iscale; DWORD frac = dc_texturefrac; @@ -2212,7 +2141,7 @@ fixed_t tmvline1_revsubclamp_C () return frac; } -void tmvline4_revsubclamp_C () +void tmvline4_revsubclamp () { BYTE *dest = dc_dest; int count = dc_count; @@ -2646,248 +2575,32 @@ const BYTE *R_GetColumn (FTexture *tex, int col) { col = width + (col % width); } - - if (r_swtruecolor) - return (const BYTE *)tex->GetColumnBgra(col, NULL); - else - return tex->GetColumn(col, NULL); + return tex->GetColumn (col, NULL); } + // [RH] Initialize the column drawer pointers void R_InitColumnDrawers () { - // Save a copy when switching to true color mode as the assembly palette drawers might change them - static bool pointers_saved = false; - static DWORD(*dovline1_saved)(); - static DWORD(*doprevline1_saved)(); - static DWORD(*domvline1_saved)(); - static void(*dovline4_saved)(); - static void(*domvline4_saved)(); - - if (r_swtruecolor) - { - if (!pointers_saved) - { - pointers_saved = true; - dovline1_saved = dovline1; - doprevline1_saved = doprevline1; - domvline1_saved = domvline1; - dovline4_saved = dovline4; - domvline4_saved = domvline4; - } - - // This code intentionally flips sub and revsub for all the classic drawer functions - // because the renderer swapped sub and revsub! - - R_DrawColumnHoriz = R_DrawColumnHoriz_rgba; - R_DrawColumn = R_DrawColumn_rgba; - R_DrawFuzzColumn = R_DrawFuzzColumn_rgba; - R_DrawTranslatedColumn = R_DrawTranslatedColumn_rgba; - R_DrawShadedColumn = R_DrawShadedColumn_rgba; - R_DrawSpanMasked = R_DrawSpanMasked_rgba; - R_DrawSpan = R_DrawSpan_rgba; - - R_DrawSpanTranslucent = R_DrawSpanTranslucent_rgba; - R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucent_rgba; - R_DrawSpanAddClamp = R_DrawSpanAddClamp_rgba; - R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClamp_rgba; - R_FillColumn = R_FillColumn_rgba; - R_FillAddColumn = R_FillAddColumn_rgba; - R_FillAddClampColumn = R_FillAddClampColumn_rgba; - R_FillSubClampColumn = R_FillRevSubClampColumn_rgba; - R_FillRevSubClampColumn = R_FillSubClampColumn_rgba; - R_DrawAddColumn = R_DrawAddColumn_rgba; - R_DrawTlatedAddColumn = R_DrawTlatedAddColumn_rgba; - R_DrawAddClampColumn = R_DrawAddClampColumn_rgba; - R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumn_rgba; - R_DrawSubClampColumn = R_DrawRevSubClampColumn_rgba; - R_DrawSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumn_rgba; - R_DrawRevSubClampColumn = R_DrawSubClampColumn_rgba; - R_DrawRevSubClampTranslatedColumn = R_DrawSubClampTranslatedColumn_rgba; - R_FillSpan = R_FillSpan_rgba; - R_DrawFogBoundary = R_DrawFogBoundary_rgba; - R_FillColumnHoriz = R_FillColumnHoriz_rgba; - - R_DrawFogBoundary = R_DrawFogBoundary_rgba; - R_MapTiltedPlane = R_MapTiltedPlane_rgba; - R_MapColoredPlane = R_MapColoredPlane_rgba; - R_DrawParticle = R_DrawParticle_rgba; - - R_SetupDrawSlab = R_SetupDrawSlab_rgba; - R_DrawSlab = R_DrawSlab_rgba; - - tmvline1_add = tmvline1_add_rgba; - tmvline4_add = tmvline4_add_rgba; - tmvline1_addclamp = tmvline1_addclamp_rgba; - tmvline4_addclamp = tmvline4_addclamp_rgba; - tmvline1_subclamp = tmvline1_subclamp_rgba; - tmvline4_subclamp = tmvline4_subclamp_rgba; - tmvline1_revsubclamp = tmvline1_revsubclamp_rgba; - tmvline4_revsubclamp = tmvline4_revsubclamp_rgba; - - rt_copy1col = rt_copy1col_rgba; - rt_copy4cols = rt_copy4cols_rgba; - rt_map1col = rt_map1col_rgba; - rt_map4cols = rt_map4cols_rgba; - rt_shaded1col = rt_shaded1col_rgba; - rt_shaded4cols = rt_shaded4cols_rgba; - rt_add1col = rt_add1col_rgba; - rt_add4cols = rt_add4cols_rgba; - rt_addclamp1col = rt_addclamp1col_rgba; - rt_addclamp4cols = rt_addclamp4cols_rgba; - rt_subclamp1col = rt_revsubclamp1col_rgba; - rt_revsubclamp1col = rt_subclamp1col_rgba; - rt_tlate1col = rt_tlate1col_rgba; - rt_tlateadd1col = rt_tlateadd1col_rgba; - rt_tlateaddclamp1col = rt_tlateaddclamp1col_rgba; - rt_tlatesubclamp1col = rt_tlaterevsubclamp1col_rgba; - rt_tlaterevsubclamp1col = rt_tlatesubclamp1col_rgba; - rt_subclamp4cols = rt_revsubclamp4cols_rgba; - rt_revsubclamp4cols = rt_subclamp4cols_rgba; - rt_tlate4cols = rt_tlate4cols_rgba; - rt_tlateadd4cols = rt_tlateadd4cols_rgba; - rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_rgba; - rt_tlatesubclamp4cols = rt_tlaterevsubclamp4cols_rgba; - rt_tlaterevsubclamp4cols = rt_tlatesubclamp4cols_rgba; - rt_initcols = rt_initcols_rgba; - rt_span_coverage = rt_span_coverage_rgba; - - dovline1 = vlinec1_rgba; - doprevline1 = vlinec1_rgba; - domvline1 = mvlinec1_rgba; - - dovline4 = vlinec4_rgba; - domvline4 = mvlinec4_rgba; - } - else - { #ifdef X86_ASM - R_DrawColumn = R_DrawColumnP_ASM; - R_DrawColumnHoriz = R_DrawColumnHorizP_ASM; - R_DrawFuzzColumn = R_DrawFuzzColumnP_ASM; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; - R_DrawShadedColumn = R_DrawShadedColumnP_C; - R_DrawSpan = R_DrawSpanP_ASM; - R_DrawSpanMasked = R_DrawSpanMaskedP_ASM; - if (CPU.Family <= 5) - { - rt_map4cols = rt_map4cols_asm2; - } - else - { - rt_map4cols = rt_map4cols_asm1; - } + R_DrawColumnHoriz = R_DrawColumnHorizP_C; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; + R_DrawShadedColumn = R_DrawShadedColumnP_C; + R_DrawSpan = R_DrawSpanP_ASM; + R_DrawSpanMasked = R_DrawSpanMaskedP_ASM; #else - R_DrawColumnHoriz = R_DrawColumnHorizP_C; - R_DrawColumn = R_DrawColumnP_C; - R_DrawFuzzColumn = R_DrawFuzzColumnP_C; - R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; - R_DrawShadedColumn = R_DrawShadedColumnP_C; - R_DrawSpan = R_DrawSpanP_C; - R_DrawSpanMasked = R_DrawSpanMaskedP_C; - rt_map4cols = rt_map4cols_c; + R_DrawColumnHoriz = R_DrawColumnHorizP_C; + R_DrawTranslatedColumn = R_DrawTranslatedColumnP_C; + R_DrawShadedColumn = R_DrawShadedColumnP_C; + R_DrawSpan = R_DrawSpanP_C; + R_DrawSpanMasked = R_DrawSpanMaskedP_C; #endif - R_DrawSpanTranslucent = R_DrawSpanTranslucentP_C; - R_DrawSpanMaskedTranslucent = R_DrawSpanMaskedTranslucentP_C; - R_DrawSpanAddClamp = R_DrawSpanAddClampP_C; - R_DrawSpanMaskedAddClamp = R_DrawSpanMaskedAddClampP_C; - R_FillColumn = R_FillColumnP_C; - R_FillAddColumn = R_FillAddColumn_C; - R_FillAddClampColumn = R_FillAddClampColumn_C; - R_FillSubClampColumn = R_FillSubClampColumn_C; - R_FillRevSubClampColumn = R_FillRevSubClampColumn_C; - R_DrawAddColumn = R_DrawAddColumnP_C; - R_DrawTlatedAddColumn = R_DrawTlatedAddColumnP_C; - R_DrawAddClampColumn = R_DrawAddClampColumnP_C; - R_DrawAddClampTranslatedColumn = R_DrawAddClampTranslatedColumnP_C; - R_DrawSubClampColumn = R_DrawSubClampColumnP_C; - R_DrawSubClampTranslatedColumn = R_DrawSubClampTranslatedColumnP_C; - R_DrawRevSubClampColumn = R_DrawRevSubClampColumnP_C; - R_DrawRevSubClampTranslatedColumn = R_DrawRevSubClampTranslatedColumnP_C; - R_FillSpan = R_FillSpan_C; - R_DrawFogBoundary = R_DrawFogBoundary_C; - R_FillColumnHoriz = R_FillColumnHorizP_C; - - R_DrawFogBoundary = R_DrawFogBoundary_C; - R_MapTiltedPlane = R_MapTiltedPlane_C; - R_MapColoredPlane = R_MapColoredPlane_C; - R_DrawParticle = R_DrawParticle_C; - -#ifdef X86_ASM - R_SetupDrawSlab = [](FSWColormap *colormap, float light, int shade) { R_SetupDrawSlabA(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; - R_DrawSlab = R_DrawSlabA; -#else - R_SetupDrawSlab = [](FSWColormap *colormap, float light, int shade) { R_SetupDrawSlabC(colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT)); }; - R_DrawSlab = R_DrawSlabC; -#endif - - tmvline1_add = tmvline1_add_C; - tmvline4_add = tmvline4_add_C; - tmvline1_addclamp = tmvline1_addclamp_C; - tmvline4_addclamp = tmvline4_addclamp_C; - tmvline1_subclamp = tmvline1_subclamp_C; - tmvline4_subclamp = tmvline4_subclamp_C; - tmvline1_revsubclamp = tmvline1_revsubclamp_C; - tmvline4_revsubclamp = tmvline4_revsubclamp_C; - -#ifdef X86_ASM - rt_copy1col = rt_copy1col_asm; - rt_copy4cols = rt_copy4cols_asm; - rt_map1col = rt_map1col_asm; - rt_shaded4cols = rt_shaded4cols_asm; - rt_add4cols = rt_add4cols_asm; - rt_addclamp4cols = rt_addclamp4cols_asm; -#else - rt_copy1col = rt_copy1col_c; - rt_copy4cols = rt_copy4cols_c; - rt_map1col = rt_map1col_c; - rt_shaded4cols = rt_shaded4cols_c; - rt_add4cols = rt_add4cols_c; - rt_addclamp4cols = rt_addclamp4cols_c; -#endif - rt_shaded1col = rt_shaded1col_c; - rt_add1col = rt_add1col_c; - rt_addclamp1col = rt_addclamp1col_c; - rt_subclamp1col = rt_subclamp1col_c; - rt_revsubclamp1col = rt_revsubclamp1col_c; - rt_tlate1col = rt_tlate1col_c; - rt_tlateadd1col = rt_tlateadd1col_c; - rt_tlateaddclamp1col = rt_tlateaddclamp1col_c; - rt_tlatesubclamp1col = rt_tlatesubclamp1col_c; - rt_tlaterevsubclamp1col = rt_tlaterevsubclamp1col_c; - rt_subclamp4cols = rt_subclamp4cols_c; - rt_revsubclamp4cols = rt_revsubclamp4cols_c; - rt_tlate4cols = rt_tlate4cols_c; - rt_tlateadd4cols = rt_tlateadd4cols_c; - rt_tlateaddclamp4cols = rt_tlateaddclamp4cols_c; - rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c; - rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c; - rt_initcols = rt_initcols_pal; - rt_span_coverage = rt_span_coverage_pal; - - if (pointers_saved) - { - pointers_saved = false; - dovline1 = dovline1_saved; - doprevline1 = doprevline1_saved; - domvline1 = domvline1_saved; - dovline4 = dovline4_saved; - domvline4 = domvline4_saved; - } - } - - colfunc = basecolfunc = R_DrawColumn; - fuzzcolfunc = R_DrawFuzzColumn; - transcolfunc = R_DrawTranslatedColumn; - spanfunc = R_DrawSpan; - - // [RH] Horizontal column drawers - hcolfunc_pre = R_DrawColumnHoriz; - hcolfunc_post1 = rt_map1col; - hcolfunc_post4 = rt_map4cols; } // [RH] Choose column drawers in a single place +EXTERN_CVAR (Int, r_drawfuzz) +EXTERN_CVAR (Bool, r_drawtrans) +EXTERN_CVAR (Float, transsouls) static FDynamicColormap *basecolormapsave; @@ -2899,7 +2612,7 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) { if (flags & STYLEF_ColorIsFixed) { - colfunc = R_FillColumn; + colfunc = R_FillColumnP; hcolfunc_post1 = rt_copy1col; hcolfunc_post4 = rt_copy4cols; } @@ -2914,7 +2627,6 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) colfunc = transcolfunc; hcolfunc_post1 = rt_tlate1col; hcolfunc_post4 = rt_tlate4cols; - drawer_needs_pal_input = true; } return true; } @@ -2922,22 +2634,16 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) { dc_srcblend = Col2RGB8_Inverse[fglevel>>10]; dc_destblend = Col2RGB8_LessPrecision[bglevel>>10]; - dc_srcalpha = fglevel; - dc_destalpha = bglevel; } else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT) { dc_srcblend = Col2RGB8[fglevel>>10]; dc_destblend = Col2RGB8[bglevel>>10]; - dc_srcalpha = fglevel; - dc_destalpha = bglevel; } else { dc_srcblend = Col2RGB8_LessPrecision[fglevel>>10]; dc_destblend = Col2RGB8_LessPrecision[bglevel>>10]; - dc_srcalpha = fglevel; - dc_destalpha = bglevel; } switch (op) { @@ -2956,16 +2662,15 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawAddColumn; + colfunc = R_DrawAddColumnP_C; hcolfunc_post1 = rt_add1col; hcolfunc_post4 = rt_add4cols; } else { - colfunc = R_DrawTlatedAddColumn; + colfunc = R_DrawTlatedAddColumnP_C; hcolfunc_post1 = rt_tlateadd1col; hcolfunc_post4 = rt_tlateadd4cols; - drawer_needs_pal_input = true; } } else @@ -2978,16 +2683,15 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawAddClampColumn; + colfunc = R_DrawAddClampColumnP_C; hcolfunc_post1 = rt_addclamp1col; hcolfunc_post4 = rt_addclamp4cols; } else { - colfunc = R_DrawAddClampTranslatedColumn; + colfunc = R_DrawAddClampTranslatedColumnP_C; hcolfunc_post1 = rt_tlateaddclamp1col; hcolfunc_post4 = rt_tlateaddclamp4cols; - drawer_needs_pal_input = true; } } return true; @@ -3001,16 +2705,15 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawSubClampColumn; + colfunc = R_DrawSubClampColumnP_C; hcolfunc_post1 = rt_subclamp1col; hcolfunc_post4 = rt_subclamp4cols; } else { - colfunc = R_DrawSubClampTranslatedColumn; + colfunc = R_DrawSubClampTranslatedColumnP_C; hcolfunc_post1 = rt_tlatesubclamp1col; hcolfunc_post4 = rt_tlatesubclamp4cols; - drawer_needs_pal_input = true; } return true; @@ -3027,16 +2730,15 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } else if (dc_translation == NULL) { - colfunc = R_DrawRevSubClampColumn; + colfunc = R_DrawRevSubClampColumnP_C; hcolfunc_post1 = rt_revsubclamp1col; hcolfunc_post4 = rt_revsubclamp4cols; } else { - colfunc = R_DrawRevSubClampTranslatedColumn; + colfunc = R_DrawRevSubClampTranslatedColumnP_C; hcolfunc_post1 = rt_tlaterevsubclamp1col; hcolfunc_post4 = rt_tlaterevsubclamp4cols; - drawer_needs_pal_input = true; } return true; @@ -3061,8 +2763,6 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, { fixed_t fglevel, bglevel; - drawer_needs_pal_input = false; - style.CheckFuzz(); if (style.BlendOp == STYLEOP_Shadow) @@ -3085,19 +2785,13 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, alpha = clamp (alpha, 0, OPAQUE); } - if (translation != -1) + dc_translation = NULL; + if (translation != 0) { - dc_translation = NULL; - if (translation != 0) + FRemapTable *table = TranslationToTable(translation); + if (table != NULL && !table->Inactive) { - FRemapTable *table = TranslationToTable(translation); - if (table != NULL && !table->Inactive) - { - if (r_swtruecolor) - dc_translation = (BYTE*)table->Palette; - else - dc_translation = table->Remap; - } + dc_translation = table->Remap; } } basecolormapsave = basecolormap; @@ -3117,19 +2811,13 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, colfunc = R_DrawShadedColumn; hcolfunc_post1 = rt_shaded1col; hcolfunc_post4 = rt_shaded4cols; - drawer_needs_pal_input = true; - dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)]; - basecolormap = &ShadeFakeColormap[16-alpha]; + dc_color = fixedcolormap ? fixedcolormap[APART(color)] : basecolormap->Maps[APART(color)]; + dc_colormap = (basecolormap = &ShadeFakeColormap[16-alpha])->Maps; if (fixedlightlev >= 0 && fixedcolormap == NULL) { - R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + dc_colormap += fixedlightlev; } - else - { - R_SetColorMapLight(basecolormap, 0, 0); - } - bool active_columnmethod = r_columnmethod && !r_swtruecolor; - return active_columnmethod ? DoDraw1 : DoDraw0; + return r_columnmethod ? DoDraw1 : DoDraw0; } fglevel = GetAlpha(style.SrcAlpha, alpha); @@ -3137,10 +2825,10 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, if (style.Flags & STYLEF_ColorIsFixed) { - uint32_t x = fglevel >> 10; - uint32_t r = RPART(color); - uint32_t g = GPART(color); - uint32_t b = BPART(color); + int x = fglevel >> 10; + int r = RPART(color); + int g = GPART(color); + int b = BPART(color); // dc_color is used by the rt_* routines. It is indexed into dc_srcblend. dc_color = RGB32k.RGB[r>>3][g>>3][b>>3]; if (style.Flags & STYLEF_InvertSource) @@ -3149,21 +2837,18 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, g = 255 - g; b = 255 - b; } - uint32_t alpha = clamp(fglevel >> (FRACBITS - 8), 0, 255); - dc_srccolor_bgra = (alpha << 24) | (r << 16) | (g << 8) | b; // dc_srccolor is used by the R_Fill* routines. It is premultiplied // with the alpha. dc_srccolor = ((((r*x)>>4)<<20) | ((g*x)>>4) | ((((b)*x)>>4)<<10)) & 0x3feffbff; - hcolfunc_pre = R_FillColumnHoriz; - R_SetColorMapLight(&identitycolormap, 0, 0); + hcolfunc_pre = R_FillColumnHorizP; + dc_colormap = identitymap; } if (!R_SetBlendFunc (style.BlendOp, fglevel, bglevel, style.Flags)) { return DontDraw; } - bool active_columnmethod = r_columnmethod && !r_swtruecolor; - return active_columnmethod ? DoDraw1 : DoDraw0; + return r_columnmethod ? DoDraw1 : DoDraw0; } void R_FinishSetPatchStyle () @@ -3173,25 +2858,25 @@ void R_FinishSetPatchStyle () bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) { - if (colfunc == R_DrawAddColumn) + if (colfunc == R_DrawAddColumnP_C) { *tmvline1 = tmvline1_add; *tmvline4 = tmvline4_add; return true; } - if (colfunc == R_DrawAddClampColumn) + if (colfunc == R_DrawAddClampColumnP_C) { *tmvline1 = tmvline1_addclamp; *tmvline4 = tmvline4_addclamp; return true; } - if (colfunc == R_DrawSubClampColumn) + if (colfunc == R_DrawSubClampColumnP_C) { *tmvline1 = tmvline1_subclamp; *tmvline4 = tmvline4_subclamp; return true; } - if (colfunc == R_DrawRevSubClampColumn) + if (colfunc == R_DrawRevSubClampColumnP_C) { *tmvline1 = tmvline1_revsubclamp; *tmvline4 = tmvline4_revsubclamp; @@ -3200,78 +2885,3 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) return false; } -void R_SetTranslationMap(lighttable_t *translation) -{ - if (r_swtruecolor) - { - dc_fcolormap = nullptr; - dc_colormap = nullptr; - dc_translation = translation; - dc_shade_constants.light_red = 256; - dc_shade_constants.light_green = 256; - dc_shade_constants.light_blue = 256; - dc_shade_constants.light_alpha = 256; - dc_shade_constants.fade_red = 0; - dc_shade_constants.fade_green = 0; - dc_shade_constants.fade_blue = 0; - dc_shade_constants.fade_alpha = 256; - dc_shade_constants.desaturate = 0; - dc_shade_constants.simple_shade = true; - dc_light = 0; - } - else - { - dc_fcolormap = nullptr; - dc_colormap = translation; - } -} - -void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) -{ - dc_fcolormap = base_colormap; - if (r_swtruecolor) - { - dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; - dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; - dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; - dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; - dc_shade_constants.fade_red = dc_fcolormap->Fade.r; - dc_shade_constants.fade_green = dc_fcolormap->Fade.g; - dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; - dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; - dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; - dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); - dc_colormap = base_colormap->Maps; - dc_light = LIGHTSCALE(light, shade); - } - else - { - dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); - } -} - -void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade) -{ - ds_fcolormap = base_colormap; - if (r_swtruecolor) - { - ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255; - ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255; - ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255; - ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255; - ds_shade_constants.fade_red = ds_fcolormap->Fade.r; - ds_shade_constants.fade_green = ds_fcolormap->Fade.g; - ds_shade_constants.fade_blue = ds_fcolormap->Fade.b; - ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a; - ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256; - ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0); - ds_colormap = base_colormap->Maps; - ds_light = LIGHTSCALE(light, shade); - } - else - { - ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); - } -} - -} diff --git a/src/r_draw.h b/src/r_draw.h index 17365f3f5..e941c161d 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -19,82 +19,42 @@ // //----------------------------------------------------------------------------- +#include "r_draw_tc.h" + +#if 0 // Do not remove this. Used to reduce merge conflicts with ZDoom #ifndef __R_DRAW__ #define __R_DRAW__ #include "r_defs.h" -struct FSWColormap; - -EXTERN_CVAR(Bool, r_multithreaded); -EXTERN_CVAR(Bool, r_magfilter); -EXTERN_CVAR(Bool, r_minfilter); -EXTERN_CVAR(Bool, r_mipmap); -EXTERN_CVAR(Float, r_lod_bias); - -namespace swrenderer -{ - -// Spectre/Invisibility. -#define FUZZTABLE 50 -extern "C" int fuzzoffset[FUZZTABLE + 1]; // [RH] +1 for the assembly routine -extern "C" int fuzzpos; -extern "C" int fuzzviewheight; - -struct ShadeConstants -{ - uint16_t light_alpha; - uint16_t light_red; - uint16_t light_green; - uint16_t light_blue; - uint16_t fade_alpha; - uint16_t fade_red; - uint16_t fade_green; - uint16_t fade_blue; - uint16_t desaturate; - bool simple_shade; -}; - extern "C" int ylookup[MAXHEIGHT]; extern "C" int dc_pitch; // [RH] Distance between rows extern "C" lighttable_t*dc_colormap; -extern "C" FSWColormap *dc_fcolormap; -extern "C" ShadeConstants dc_shade_constants; -extern "C" fixed_t dc_light; extern "C" int dc_x; extern "C" int dc_yl; extern "C" int dc_yh; extern "C" fixed_t dc_iscale; extern double dc_texturemid; extern "C" fixed_t dc_texturefrac; -extern "C" uint32_t dc_textureheight; extern "C" int dc_color; // [RH] For flat colors (no texturing) extern "C" DWORD dc_srccolor; -extern "C" uint32_t dc_srccolor_bgra; extern "C" DWORD *dc_srcblend; extern "C" DWORD *dc_destblend; -extern "C" fixed_t dc_srcalpha; -extern "C" fixed_t dc_destalpha; // first pixel in a column extern "C" const BYTE* dc_source; -extern "C" const BYTE* dc_source2; -extern "C" uint32_t dc_texturefracx; extern "C" BYTE *dc_dest, *dc_destorg; -extern "C" int dc_destheight; extern "C" int dc_count; extern "C" DWORD vplce[4]; extern "C" DWORD vince[4]; extern "C" BYTE* palookupoffse[4]; -extern "C" fixed_t palookuplight[4]; extern "C" const BYTE* bufplce[4]; extern "C" const BYTE* bufplce2[4]; -extern "C" uint32_t buftexturefracx[4]; extern "C" uint32_t bufheight[4]; // [RH] Temporary buffer for column drawing @@ -103,15 +63,20 @@ extern "C" unsigned int dc_tspans[4][MAXHEIGHT]; extern "C" unsigned int *dc_ctspan[4]; extern "C" unsigned int horizspans[4]; + // [RH] Pointers to the different column and span drawers... // The span blitting interface. // Hook in assembler or system specific BLT here. -extern void (*R_DrawColumn)(void); extern DWORD (*dovline1) (); extern DWORD (*doprevline1) (); +#ifdef X64_ASM +#define dovline4 vlinetallasm4 +extern "C" void vlinetallasm4(); +#else extern void (*dovline4) (); +#endif extern void setupvline (int); extern DWORD (*domvline1) (); @@ -121,7 +86,7 @@ extern void setupmvline (int); extern void setuptmvline (int); // The Spectre/Invisibility effect. -extern void (*R_DrawFuzzColumn)(void); +extern void R_DrawFuzzColumn(void); // [RH] Draw shaded column extern void (*R_DrawShadedColumn)(void); @@ -133,23 +98,23 @@ extern void (*R_DrawTranslatedColumn)(void); // Span drawing for rows, floor/ceiling. No Spectre effect needed. extern void (*R_DrawSpan)(void); void R_SetupSpanBits(FTexture *tex); -void R_SetSpanColormap(FDynamicColormap *colormap, int shade); -void R_SetSpanSource(FTexture *tex); +void R_SetSpanColormap(BYTE *colormap); +void R_SetSpanSource(const BYTE *pixels); // Span drawing for masked textures. extern void (*R_DrawSpanMasked)(void); // Span drawing for translucent textures. -extern void (*R_DrawSpanTranslucent)(void); +void R_DrawSpanTranslucent(void); // Span drawing for masked, translucent textures. -extern void (*R_DrawSpanMaskedTranslucent)(void); +void R_DrawSpanMaskedTranslucent(void); // Span drawing for translucent, additive textures. -extern void (*R_DrawSpanAddClamp)(void); +void R_DrawSpanAddClamp(void); // Span drawing for masked, translucent, additive textures. -extern void (*R_DrawSpanMaskedAddClamp)(void); +void R_DrawSpanMaskedAddClamp(void); // [RH] Span blit into an interleaved intermediate buffer extern void (*R_DrawColumnHoriz)(void); @@ -158,163 +123,110 @@ extern void (*R_DrawColumnHoriz)(void); void R_InitColumnDrawers (); // [RH] Moves data from the temporary buffer to the screen. + +void rt_copy1col(int hx, int sx, int yl, int yh); +void rt_copy4cols(int sx, int yl, int yh); +void rt_map4cols(int sx, int yl, int yh); + extern "C" { -void rt_copy1col_c (int hx, int sx, int yl, int yh); -void rt_copy4cols_c (int sx, int yl, int yh); -void rt_shaded1col_c (int hx, int sx, int yl, int yh); +void rt_shaded1col (int hx, int sx, int yl, int yh); void rt_shaded4cols_c (int sx, int yl, int yh); void rt_shaded4cols_asm (int sx, int yl, int yh); -void rt_map1col_c (int hx, int sx, int yl, int yh); -void rt_add1col_c (int hx, int sx, int yl, int yh); -void rt_addclamp1col_c (int hx, int sx, int yl, int yh); -void rt_subclamp1col_c (int hx, int sx, int yl, int yh); -void rt_revsubclamp1col_c (int hx, int sx, int yl, int yh); +void rt_map1col (int hx, int sx, int yl, int yh); +void rt_add1col (int hx, int sx, int yl, int yh); +void rt_addclamp1col (int hx, int sx, int yl, int yh); +void rt_subclamp1col (int hx, int sx, int yl, int yh); +void rt_revsubclamp1col (int hx, int sx, int yl, int yh); -void rt_tlate1col_c (int hx, int sx, int yl, int yh); -void rt_tlateadd1col_c (int hx, int sx, int yl, int yh); -void rt_tlateaddclamp1col_c (int hx, int sx, int yl, int yh); -void rt_tlatesubclamp1col_c (int hx, int sx, int yl, int yh); -void rt_tlaterevsubclamp1col_c (int hx, int sx, int yl, int yh); +void rt_tlate1col (int hx, int sx, int yl, int yh); +void rt_tlateadd1col (int hx, int sx, int yl, int yh); +void rt_tlateaddclamp1col (int hx, int sx, int yl, int yh); +void rt_tlatesubclamp1col (int hx, int sx, int yl, int yh); +void rt_tlaterevsubclamp1col (int hx, int sx, int yl, int yh); -void rt_map4cols_c (int sx, int yl, int yh); void rt_add4cols_c (int sx, int yl, int yh); void rt_addclamp4cols_c (int sx, int yl, int yh); -void rt_subclamp4cols_c (int sx, int yl, int yh); -void rt_revsubclamp4cols_c (int sx, int yl, int yh); +void rt_subclamp4cols (int sx, int yl, int yh); +void rt_revsubclamp4cols (int sx, int yl, int yh); -void rt_tlate4cols_c (int sx, int yl, int yh); -void rt_tlateadd4cols_c (int sx, int yl, int yh); -void rt_tlateaddclamp4cols_c (int sx, int yl, int yh); -void rt_tlatesubclamp4cols_c (int sx, int yl, int yh); -void rt_tlaterevsubclamp4cols_c (int sx, int yl, int yh); +void rt_tlate4cols (int sx, int yl, int yh); +void rt_tlateadd4cols (int sx, int yl, int yh); +void rt_tlateaddclamp4cols (int sx, int yl, int yh); +void rt_tlatesubclamp4cols (int sx, int yl, int yh); +void rt_tlaterevsubclamp4cols (int sx, int yl, int yh); -void rt_copy1col_asm (int hx, int sx, int yl, int yh); -void rt_map1col_asm (int hx, int sx, int yl, int yh); - -void rt_copy4cols_asm (int sx, int yl, int yh); -void rt_map4cols_asm1 (int sx, int yl, int yh); -void rt_map4cols_asm2 (int sx, int yl, int yh); void rt_add4cols_asm (int sx, int yl, int yh); void rt_addclamp4cols_asm (int sx, int yl, int yh); } -extern void (*rt_copy1col)(int hx, int sx, int yl, int yh); -extern void (*rt_copy4cols)(int sx, int yl, int yh); -extern void (*rt_shaded1col)(int hx, int sx, int yl, int yh); -extern void (*rt_shaded4cols)(int sx, int yl, int yh); - -extern void (*rt_map1col)(int hx, int sx, int yl, int yh); -extern void (*rt_add1col)(int hx, int sx, int yl, int yh); -extern void (*rt_addclamp1col)(int hx, int sx, int yl, int yh); -extern void (*rt_subclamp1col)(int hx, int sx, int yl, int yh); -extern void (*rt_revsubclamp1col)(int hx, int sx, int yl, int yh); - -extern void (*rt_tlate1col)(int hx, int sx, int yl, int yh); -extern void (*rt_tlateadd1col)(int hx, int sx, int yl, int yh); -extern void (*rt_tlateaddclamp1col)(int hx, int sx, int yl, int yh); -extern void (*rt_tlatesubclamp1col)(int hx, int sx, int yl, int yh); -extern void (*rt_tlaterevsubclamp1col)(int hx, int sx, int yl, int yh); - -extern void (*rt_map4cols)(int sx, int yl, int yh); -extern void (*rt_add4cols)(int sx, int yl, int yh); -extern void (*rt_addclamp4cols)(int sx, int yl, int yh); -extern void (*rt_subclamp4cols)(int sx, int yl, int yh); -extern void (*rt_revsubclamp4cols)(int sx, int yl, int yh); - -extern void (*rt_tlate4cols)(int sx, int yl, int yh); -extern void (*rt_tlateadd4cols)(int sx, int yl, int yh); -extern void (*rt_tlateaddclamp4cols)(int sx, int yl, int yh); -extern void (*rt_tlatesubclamp4cols)(int sx, int yl, int yh); -extern void (*rt_tlaterevsubclamp4cols)(int sx, int yl, int yh); - -extern void (*rt_initcols)(BYTE *buffer); -extern void (*rt_span_coverage)(int x, int start, int stop); +#ifdef X86_ASM +#define rt_shaded4cols rt_shaded4cols_asm +#define rt_add4cols rt_add4cols_asm +#define rt_addclamp4cols rt_addclamp4cols_asm +#else +#define rt_shaded4cols rt_shaded4cols_c +#define rt_add4cols rt_add4cols_c +#define rt_addclamp4cols rt_addclamp4cols_c +#endif void rt_flip_posts(); void rt_draw4cols (int sx); // [RH] Preps the temporary horizontal buffer. -void rt_initcols_pal (BYTE *buffer); +void rt_initcols (BYTE *buffer=NULL); -void rt_span_coverage_pal(int x, int start, int stop); - -extern void (*R_DrawFogBoundary)(int x1, int x2, short *uclip, short *dclip); - -void R_DrawFogBoundary_C (int x1, int x2, short *uclip, short *dclip); +void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip); #ifdef X86_ASM -extern "C" void R_DrawColumnP_Unrolled (void); -extern "C" void R_DrawColumnP_ASM (void); -extern "C" void R_DrawFuzzColumnP_ASM (void); void R_DrawShadedColumnP_C (void); extern "C" void R_DrawSpanP_ASM (void); extern "C" void R_DrawSpanMaskedP_ASM (void); +void R_DrawColumnHorizP_C(void); + #else -void R_DrawColumnP_C (void); -void R_DrawFuzzColumnP_C (void); void R_DrawShadedColumnP_C (void); void R_DrawSpanP_C (void); void R_DrawSpanMaskedP_C (void); #endif +void R_DrawColumn(); void R_DrawColumnHorizP_C(void); void R_DrawTranslatedColumnP_C(void); -void R_DrawSpanTranslucentP_C (void); -void R_DrawSpanMaskedTranslucentP_C (void); +void R_DrawSpanTranslucent (void); +void R_DrawSpanMaskedTranslucent (void); void R_DrawTlatedLucentColumnP_C (void); #define R_DrawTlatedLucentColumn R_DrawTlatedLucentColumnP_C -extern void(*R_FillColumn)(void); -extern void(*R_FillAddColumn)(void); -extern void(*R_FillAddClampColumn)(void); -extern void(*R_FillSubClampColumn)(void); -extern void(*R_FillRevSubClampColumn)(void); -extern void(*R_DrawAddColumn)(void); -extern void(*R_DrawTlatedAddColumn)(void); -extern void(*R_DrawAddClampColumn)(void); -extern void(*R_DrawAddClampTranslatedColumn)(void); -extern void(*R_DrawSubClampColumn)(void); -extern void(*R_DrawSubClampTranslatedColumn)(void); -extern void(*R_DrawRevSubClampColumn)(void); -extern void(*R_DrawRevSubClampTranslatedColumn)(void); - -extern void(*R_FillSpan)(void); -extern void(*R_FillColumnHoriz)(void); - -void R_FillColumnP_C (void); - -void R_FillColumnHorizP_C (void); -void R_FillSpan_C (void); - -extern void(*R_SetupDrawSlab)(FSWColormap *base_colormap, float light, int shade); -extern void(*R_DrawSlab)(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +void R_FillColumnP (void); +void R_FillColumnHorizP (void); +void R_FillSpan (void); #ifdef X86_ASM -extern "C" void R_SetupDrawSlabA(const BYTE *colormap); -extern "C" void R_DrawSlabA(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +#define R_SetupDrawSlab R_SetupDrawSlabA +#define R_DrawSlab R_DrawSlabA #else -extern "C" void R_SetupDrawSlabC(const BYTE *colormap); -extern "C" void R_DrawSlabC(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); +#define R_SetupDrawSlab R_SetupDrawSlabC +#define R_DrawSlab R_DrawSlabC #endif +extern "C" void R_SetupDrawSlab(const BYTE *colormap); +extern "C" void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); + extern "C" int ds_y; extern "C" int ds_x1; extern "C" int ds_x2; -extern "C" FSWColormap* ds_fcolormap; extern "C" lighttable_t* ds_colormap; -extern "C" ShadeConstants ds_shade_constants; -extern "C" dsfixed_t ds_light; extern "C" dsfixed_t ds_xfrac; extern "C" dsfixed_t ds_yfrac; @@ -323,18 +235,15 @@ extern "C" dsfixed_t ds_ystep; extern "C" int ds_xbits; extern "C" int ds_ybits; extern "C" fixed_t ds_alpha; -extern "C" double ds_lod; // start of a 64*64 tile image extern "C" const BYTE* ds_source; -extern "C" bool ds_source_mipmapped; extern "C" int ds_color; // [RH] For flat color (no texturing) extern BYTE shadetables[/*NUMCOLORMAPS*16*256*/]; extern FDynamicColormap ShadeFakeColormap[16]; extern BYTE identitymap[256]; -extern FDynamicColormap identitycolormap; extern BYTE *dc_translation; // [RH] Added for muliresolution support @@ -358,15 +267,6 @@ inline ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translati // style was STYLE_Shade void R_FinishSetPatchStyle (); -extern fixed_t(*tmvline1_add)(); -extern void(*tmvline4_add)(); -extern fixed_t(*tmvline1_addclamp)(); -extern void(*tmvline4_addclamp)(); -extern fixed_t(*tmvline1_subclamp)(); -extern void(*tmvline4_subclamp)(); -extern fixed_t(*tmvline1_revsubclamp)(); -extern void(*tmvline4_revsubclamp)(); - // transmaskwallscan calls this to find out what column drawers to use bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()); @@ -382,26 +282,11 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_ // transmaskwallscan is like maskwallscan, but it can also blend to the background void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); -// Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color) -void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade); - -// Same as R_SetColorMapLight, but for ds_colormap and ds_light -void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade); - -void R_SetTranslationMap(lighttable_t *translation); - void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); -void R_DrawSingleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom); -void R_DrawSingleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); -void R_DrawDoubleSkyCol1_rgba(uint32_t solid_top, uint32_t solid_bottom); -void R_DrawDoubleSkyCol4_rgba(uint32_t solid_top, uint32_t solid_bottom); - -extern bool r_swtruecolor; - -} +#endif #endif diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index 61e0a8932..699352a6b 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -73,6 +73,8 @@ class DrawSpanLLVMCommand : public DrawerCommand public: DrawSpanLLVMCommand() { + using namespace drawerargs; + args.xfrac = ds_xfrac; args.yfrac = ds_yfrac; args.xstep = ds_xstep; @@ -122,6 +124,8 @@ protected: private: inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped) { + using namespace drawerargs; + bool magnifying = ds_lod < 0.0f; if (r_mipmap && mipmapped) { @@ -217,6 +221,8 @@ protected: public: DrawWall4LLVMCommand() { + using namespace drawerargs; + args.dest = (uint32_t*)dc_dest; args.dest_y = _dest_y; args.count = dc_count; @@ -281,6 +287,8 @@ protected: public: DrawWall1LLVMCommand() { + using namespace drawerargs; + args.dest = (uint32_t*)dc_dest; args.dest_y = _dest_y; args.pitch = dc_pitch; @@ -347,6 +355,8 @@ protected: public: DrawColumnLLVMCommand() { + using namespace drawerargs; + args.dest = (uint32_t*)dc_dest; args.source = dc_source; args.source2 = dc_source2; @@ -408,6 +418,8 @@ protected: public: DrawSkyLLVMCommand(uint32_t solid_top, uint32_t solid_bottom) { + using namespace drawerargs; + args.dest = (uint32_t*)dc_dest; args.dest_y = _dest_y; args.count = dc_count; @@ -492,6 +504,8 @@ class DrawFuzzColumnRGBACommand : public DrawerCommand public: DrawFuzzColumnRGBACommand() { + using namespace drawerargs; + _x = dc_x; _yl = dc_yl; _yh = dc_yh; @@ -609,6 +623,8 @@ class FillSpanRGBACommand : public DrawerCommand public: FillSpanRGBACommand() { + using namespace drawerargs; + _x1 = ds_x1; _x2 = ds_x2; _y = ds_y; @@ -655,6 +671,8 @@ class DrawSlabRGBACommand : public DrawerCommand public: DrawSlabRGBACommand(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p, ShadeConstants shade_constants, const BYTE *colormap, fixed_t light) { + using namespace drawerargs; + _dx = dx; _v = v; _dy = dy; @@ -774,6 +792,8 @@ class DrawFogBoundaryLineRGBACommand : public DrawerCommand public: DrawFogBoundaryLineRGBACommand(int y, int x, int x2) { + using namespace drawerargs; + _y = y; _x = x; _x2 = x2; @@ -862,6 +882,8 @@ class DrawTiltedSpanRGBACommand : public DrawerCommand public: DrawTiltedSpanRGBACommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) { + using namespace drawerargs; + _x1 = x1; _x2 = x2; _y = y; @@ -1005,6 +1027,8 @@ class DrawColoredSpanRGBACommand : public DrawerCommand public: DrawColoredSpanRGBACommand(int y, int x1, int x2) { + using namespace drawerargs; + _y = y; _x1 = x1; _x2 = x2; @@ -1051,6 +1075,8 @@ class FillTransColumnRGBACommand : public DrawerCommand public: FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a) { + using namespace drawerargs; + _x = x; _y1 = y1; _y2 = y2; @@ -1315,6 +1341,8 @@ void R_FillRevSubClampColumn_rgba() void R_DrawFuzzColumn_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); dc_yl = MAX(dc_yl, 1); @@ -1445,12 +1473,16 @@ void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BY DWORD vlinec1_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } void vlinec4_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1458,12 +1490,16 @@ void vlinec4_rgba() DWORD mvlinec1_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } void mvlinec4_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1471,12 +1507,16 @@ void mvlinec4_rgba() fixed_t tmvline1_add_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_add_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1484,12 +1524,16 @@ void tmvline4_add_rgba() fixed_t tmvline1_addclamp_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_addclamp_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1497,12 +1541,16 @@ void tmvline4_addclamp_rgba() fixed_t tmvline1_subclamp_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_subclamp_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; @@ -1510,12 +1558,16 @@ void tmvline4_subclamp_rgba() fixed_t tmvline1_revsubclamp_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); return dc_texturefrac + dc_count * dc_iscale; } void tmvline4_revsubclamp_rgba() { + using namespace drawerargs; + DrawerCommandQueue::QueueCommand(); for (int i = 0; i < 4; i++) vplce[i] += vince[i] * dc_count; diff --git a/src/r_draw_rgba.h b/src/r_draw_rgba.h index 8e66b7a72..5d159164e 100644 --- a/src/r_draw_rgba.h +++ b/src/r_draw_rgba.h @@ -39,89 +39,6 @@ EXTERN_CVAR(Float, r_lod_bias) namespace swrenderer { -///////////////////////////////////////////////////////////////////////////// -// Drawer functions: - -void rt_initcols_rgba(BYTE *buffer); -void rt_span_coverage_rgba(int x, int start, int stop); - -void rt_copy1col_rgba(int hx, int sx, int yl, int yh); -void rt_copy4cols_rgba(int sx, int yl, int yh); -void rt_shaded1col_rgba(int hx, int sx, int yl, int yh); -void rt_shaded4cols_rgba(int sx, int yl, int yh); -void rt_map1col_rgba(int hx, int sx, int yl, int yh); -void rt_add1col_rgba(int hx, int sx, int yl, int yh); -void rt_addclamp1col_rgba(int hx, int sx, int yl, int yh); -void rt_subclamp1col_rgba(int hx, int sx, int yl, int yh); -void rt_revsubclamp1col_rgba(int hx, int sx, int yl, int yh); -void rt_tlate1col_rgba(int hx, int sx, int yl, int yh); -void rt_tlateadd1col_rgba(int hx, int sx, int yl, int yh); -void rt_tlateaddclamp1col_rgba(int hx, int sx, int yl, int yh); -void rt_tlatesubclamp1col_rgba(int hx, int sx, int yl, int yh); -void rt_tlaterevsubclamp1col_rgba(int hx, int sx, int yl, int yh); -void rt_map4cols_rgba(int sx, int yl, int yh); -void rt_add4cols_rgba(int sx, int yl, int yh); -void rt_addclamp4cols_rgba(int sx, int yl, int yh); -void rt_subclamp4cols_rgba(int sx, int yl, int yh); -void rt_revsubclamp4cols_rgba(int sx, int yl, int yh); -void rt_tlate4cols_rgba(int sx, int yl, int yh); -void rt_tlateadd4cols_rgba(int sx, int yl, int yh); -void rt_tlateaddclamp4cols_rgba(int sx, int yl, int yh); -void rt_tlatesubclamp4cols_rgba(int sx, int yl, int yh); -void rt_tlaterevsubclamp4cols_rgba(int sx, int yl, int yh); - -void R_DrawColumnHoriz_rgba(); -void R_DrawColumn_rgba(); -void R_DrawFuzzColumn_rgba(); -void R_DrawTranslatedColumn_rgba(); -void R_DrawShadedColumn_rgba(); - -void R_FillColumn_rgba(); -void R_FillAddColumn_rgba(); -void R_FillAddClampColumn_rgba(); -void R_FillSubClampColumn_rgba(); -void R_FillRevSubClampColumn_rgba(); -void R_DrawAddColumn_rgba(); -void R_DrawTlatedAddColumn_rgba(); -void R_DrawAddClampColumn_rgba(); -void R_DrawAddClampTranslatedColumn_rgba(); -void R_DrawSubClampColumn_rgba(); -void R_DrawSubClampTranslatedColumn_rgba(); -void R_DrawRevSubClampColumn_rgba(); -void R_DrawRevSubClampTranslatedColumn_rgba(); - -void R_DrawSpan_rgba(void); -void R_DrawSpanMasked_rgba(void); -void R_DrawSpanTranslucent_rgba(); -void R_DrawSpanMaskedTranslucent_rgba(); -void R_DrawSpanAddClamp_rgba(); -void R_DrawSpanMaskedAddClamp_rgba(); -void R_FillSpan_rgba(); - -void R_DrawTiltedSpan_rgba(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); -void R_DrawColoredSpan_rgba(int y, int x1, int x2); - -void R_SetupDrawSlab_rgba(FSWColormap *base_colormap, float light, int shade); -void R_DrawSlab_rgba(int dx, fixed_t v, int dy, fixed_t vi, const BYTE *vptr, BYTE *p); - -void R_DrawFogBoundary_rgba(int x1, int x2, short *uclip, short *dclip); - -DWORD vlinec1_rgba(); -void vlinec4_rgba(); -DWORD mvlinec1_rgba(); -void mvlinec4_rgba(); -fixed_t tmvline1_add_rgba(); -void tmvline4_add_rgba(); -fixed_t tmvline1_addclamp_rgba(); -void tmvline4_addclamp_rgba(); -fixed_t tmvline1_subclamp_rgba(); -void tmvline4_subclamp_rgba(); -fixed_t tmvline1_revsubclamp_rgba(); -void tmvline4_revsubclamp_rgba(); - -void R_FillColumnHoriz_rgba(); -void R_FillSpan_rgba(); - ///////////////////////////////////////////////////////////////////////////// // Drawer commands: diff --git a/src/r_drawt.cpp b/src/r_drawt.cpp index d87c8f4c0..ecdf078d2 100644 --- a/src/r_drawt.cpp +++ b/src/r_drawt.cpp @@ -72,9 +72,8 @@ extern "C" void R_SetupAddCol(); extern "C" void R_SetupAddClampCol(); #endif -#ifndef X86_ASM // Copies one span at hx to the screen at sx. -void rt_copy1col_c (int hx, int sx, int yl, int yh) +void rt_copy1col (int hx, int sx, int yl, int yh) { BYTE *source; BYTE *dest; @@ -115,7 +114,7 @@ void rt_copy1col_c (int hx, int sx, int yl, int yh) } // Copies all four spans to the screen starting at sx. -void rt_copy4cols_c (int sx, int yl, int yh) +void rt_copy4cols (int sx, int yl, int yh) { int *source; int *dest; @@ -148,7 +147,7 @@ void rt_copy4cols_c (int sx, int yl, int yh) } // Maps one span at hx to the screen at sx. -void rt_map1col_c (int hx, int sx, int yl, int yh) +void rt_map1col (int hx, int sx, int yl, int yh) { BYTE *colormap; BYTE *source; @@ -183,7 +182,7 @@ void rt_map1col_c (int hx, int sx, int yl, int yh) } // Maps all four spans to the screen starting at sx. -void rt_map4cols_c (int sx, int yl, int yh) +void rt_map4cols (int sx, int yl, int yh) { BYTE *colormap; BYTE *source; @@ -225,7 +224,6 @@ void rt_map4cols_c (int sx, int yl, int yh) dest += pitch*2; } while (--count); } -#endif void rt_Translate1col(const BYTE *translation, int hx, int yl, int yh) { diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 98d27adec..539135afe 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -48,10 +48,6 @@ namespace swrenderer { -extern unsigned int dc_tspans[4][MAXHEIGHT]; -extern unsigned int *dc_ctspan[4]; -extern unsigned int *horizspan[4]; - ///////////////////////////////////////////////////////////////////////////// class DrawColumnRt1LLVMCommand : public DrawerCommand @@ -73,6 +69,8 @@ protected: public: DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh) { + using namespace drawerargs; + args.dest = (uint32_t*)dc_destorg + ylookup[yl] + sx; args.source = nullptr; args.source2 = nullptr; @@ -192,6 +190,8 @@ class DrawColumnHorizRGBACommand : public DrawerCommand public: DrawColumnHorizRGBACommand() { + using namespace drawerargs; + _count = dc_count; _iscale = dc_iscale; _texturefrac = dc_texturefrac; @@ -269,6 +269,8 @@ class FillColumnHorizRGBACommand : public DrawerCommand public: FillColumnHorizRGBACommand() { + using namespace drawerargs; + _x = dc_x; _count = dc_count; _color = GPalette.BaseColors[dc_color].d | (uint32_t)0xff000000; @@ -462,6 +464,8 @@ void rt_tlaterevsubclamp4cols_rgba (int sx, int yl, int yh) // call this function to set up the span pointers. void rt_initcols_rgba (BYTE *buff) { + using namespace drawerargs; + for (int y = 3; y >= 0; y--) horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0]; @@ -470,6 +474,8 @@ void rt_initcols_rgba (BYTE *buff) void rt_span_coverage_rgba(int x, int start, int stop) { + using namespace drawerargs; + unsigned int **tspan = &dc_ctspan[x & 3]; (*tspan)[0] = start; (*tspan)[1] = stop; @@ -480,6 +486,8 @@ void rt_span_coverage_rgba(int x, int start, int stop) // drawn to the screen along with up to three other columns. void R_DrawColumnHoriz_rgba (void) { + using namespace drawerargs; + if (dc_count <= 0) return; @@ -498,6 +506,8 @@ void R_DrawColumnHoriz_rgba (void) // [RH] Just fills a column with a given color void R_FillColumnHoriz_rgba (void) { + using namespace drawerargs; + if (dc_count <= 0) return; diff --git a/src/r_main.cpp b/src/r_main.cpp index b236dc0e7..1e314f127 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -811,6 +811,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) void R_SetupBuffer () { + using namespace drawerargs; + static BYTE *lastbuff = NULL; int pitch = RenderTarget->GetPitch(); diff --git a/src/r_main.h b/src/r_main.h index 5908667c8..c73b59d91 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -129,7 +129,6 @@ extern void (*hcolfunc_pre) (void); extern void (*hcolfunc_post1) (int hx, int sx, int yl, int yh); extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh); extern void (*hcolfunc_post4) (int sx, int yl, int yh); -extern bool drawer_needs_pal_input; void R_InitTextureMapping (); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index da58ad16c..36c2c1da5 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -72,6 +72,7 @@ EXTERN_CVAR(Int, r_skymode) namespace swrenderer { + using namespace drawerargs; extern subsector_t *InSubsector; diff --git a/src/r_plane.h b/src/r_plane.h index 5e91a4b0b..9141411af 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -96,9 +96,6 @@ void R_DrawNormalPlane (visplane_t *pl, double xscale, double yscale, fixed_t al void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked); void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); -extern void(*R_MapColoredPlane)(int y, int x1); -extern void(*R_MapTiltedPlane)(int y, int x1); - void R_MapTiltedPlane_C(int y, int x1); void R_MapTiltedPlane_rgba(int y, int x); void R_MapColoredPlane_C(int y, int x1); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 0e59ef0f7..44e6f906f 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -64,6 +64,7 @@ EXTERN_CVAR(Bool, r_mipmap) namespace swrenderer { + using namespace drawerargs; #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) diff --git a/src/r_things.cpp b/src/r_things.cpp index 659ad916a..6869e8341 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -78,6 +78,7 @@ CVAR(Bool, r_splitsprites, true, CVAR_ARCHIVE) namespace swrenderer { + using namespace drawerargs; // [RH] A c-buffer. Used for keeping track of offscreen voxel spans. diff --git a/src/r_things.h b/src/r_things.h index 0e036d633..f777488a5 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -100,7 +100,6 @@ struct vissprite_t vissprite_t() {} }; -extern void(*R_DrawParticle)(vissprite_t *); void R_DrawParticle_C (vissprite_t *); void R_DrawParticle_rgba (vissprite_t *); diff --git a/src/r_thread.h b/src/r_thread.h index d80fd0203..3077a095f 100644 --- a/src/r_thread.h +++ b/src/r_thread.h @@ -107,23 +107,23 @@ protected: { count += dest_y; dest_y = 0; - dest = (uint32_t*)swrenderer::dc_destorg; + dest = (uint32_t*)swrenderer::drawerargs::dc_destorg; } - else if (dest_y >= swrenderer::dc_destheight) + else if (dest_y >= swrenderer::drawerargs::dc_destheight) { dest_y = 0; count = 0; } if (count < 0 || count > MAXHEIGHT) count = 0; - if (dest_y + count >= swrenderer::dc_destheight) - count = swrenderer::dc_destheight - dest_y; + if (dest_y + count >= swrenderer::drawerargs::dc_destheight) + count = swrenderer::drawerargs::dc_destheight - dest_y; } public: DrawerCommand() { - _dest_y = static_cast((swrenderer::dc_dest - swrenderer::dc_destorg) / (swrenderer::dc_pitch * 4)); + _dest_y = static_cast((swrenderer::drawerargs::dc_dest - swrenderer::drawerargs::dc_destorg) / (swrenderer::drawerargs::dc_pitch * 4)); } virtual ~DrawerCommand() { } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 985238071..5c10406bf 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -134,7 +134,8 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) { #ifndef NO_SWRENDER using namespace swrenderer; - + using namespace drawerargs; + static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; @@ -1362,6 +1363,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, { #ifndef NO_SWRENDER using namespace swrenderer; + using namespace drawerargs; // Use an equation similar to player sprites to determine shade fixed_t shade = LIGHT2SHADE(lightlevel) - 12*FRACUNIT;