From 6f92efc72cb87baee5550de42a2b0c489774f704 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 12 Oct 2016 12:43:26 +0200 Subject: [PATCH 1/5] - renamed thingdef_codeptr.cpp and moved it out of thingdef/. Ultimately, thingdef should only contain code that is directly related to the DECORATE parser, but that's not the case with this file. It's only function definitions which get used during gameplay and will also be accessed by ZScript. The change is intentionally on master so that pull requests can adjust to it now instead of creating conflicts later. --- src/CMakeLists.txt | 2 +- src/{thingdef/thingdef_codeptr.cpp => p_actionfunctions.cpp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{thingdef/thingdef_codeptr.cpp => p_actionfunctions.cpp} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03299bb0a..ebfac3050 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1090,6 +1090,7 @@ set (PCH_SOURCES p_3dfloors.cpp p_3dmidtex.cpp p_acs.cpp + p_actionfunctions.cpp p_buildmap.cpp p_ceiling.cpp p_conversation.cpp @@ -1227,7 +1228,6 @@ set (PCH_SOURCES textures/warptexture.cpp thingdef/olddecorations.cpp thingdef/thingdef.cpp - thingdef/thingdef_codeptr.cpp thingdef/thingdef_data.cpp thingdef/thingdef_exp.cpp thingdef/thingdef_expression.cpp diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/p_actionfunctions.cpp similarity index 100% rename from src/thingdef/thingdef_codeptr.cpp rename to src/p_actionfunctions.cpp From fbbdd403f19eb93c4c7747d1b000c7bea3677ec6 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 12 Oct 2016 14:37:57 -0400 Subject: [PATCH 2/5] - Implemented r_linearsky for dual-layer skies --- src/r_plane.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cfc30e1c7..f016c9e04 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -888,9 +888,19 @@ static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) // Get a column of sky when there are two overlapping sky textures static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) { - DWORD ang = (skyangle + xtoviewangle[x]) ^ skyflip; - DWORD angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); - DWORD angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + DWORD ang, angle1, angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + + if (r_linearsky) + { + angle_t xangle = (angle_t)((0.5 - x / (double)viewwidth) * FocalTangent * ANGLE_90); + ang = (skyangle + xangle) ^ skyflip; + } + else + { + ang = (skyangle + xtoviewangle[x]) ^ skyflip; + } + angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS); + angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); // Check if this column has already been built. If so, there's // no reason to waste time building it again. From d96ec6c311ba5abf867844c931426f9de2b0f730 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 13 Oct 2016 02:12:48 -0400 Subject: [PATCH 3/5] - Expand truecolor sky buffer from 4 columns to 2048 columns. 2048 is probably the max we'll ever need, even with 4k, 8k, or higher resolutions, since the algorithm checks for repeat columns. --- src/r_plane.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index f016c9e04..a3facc342 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -852,10 +852,11 @@ extern FTexture *rw_pic; // since the most anyone can ever see of the sky is 500 pixels. // We need 4 skybufs because wallscan can draw up to 4 columns at a time. // Need two versions - one for true color and one for palette +#define MAXSKYBUF 2048 static BYTE skybuf[4][512]; -static uint32_t skybuf_bgra[4][512]; +static uint32_t skybuf_bgra[MAXSKYBUF][512]; static DWORD lastskycol[4]; -static DWORD lastskycol_bgra[4]; +static DWORD lastskycol_bgra[MAXSKYBUF]; static int skycolplace; static int skycolplace_bgra; @@ -945,7 +946,7 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) else { //return R_GetOneSkyColumn(fronttex, x); - for (i = 0; i < 4; ++i) + for (i = 0; i < MAXSKYBUF; ++i) { if (lastskycol_bgra[i] == skycol) { @@ -955,7 +956,7 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) lastskycol_bgra[skycolplace_bgra] = skycol; uint32_t *composite = skybuf_bgra[skycolplace_bgra]; - skycolplace_bgra = (skycolplace_bgra + 1) & 3; + skycolplace_bgra = (skycolplace_bgra + 1) % MAXSKYBUF; // The ordering of the following code has been tuned to allow VC++ to optimize // it well. In particular, this arrangement lets it keep count in a register From 5d08a812404b463ce6b2008f8b74092a2b501c6e Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 13 Oct 2016 02:37:38 -0400 Subject: [PATCH 4/5] - fixed: compiler warning with bad copy-paste - fixed: speed up sky compositing in truecolor mode with large buffers - only the last 4 buffers used are checked. --- src/r_plane.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index a3facc342..d69e8a5c4 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -889,7 +889,7 @@ static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) // Get a column of sky when there are two overlapping sky textures static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) { - DWORD ang, angle1, angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS); + DWORD ang, angle1, angle2; if (r_linearsky) { @@ -946,11 +946,12 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) else { //return R_GetOneSkyColumn(fronttex, x); - for (i = 0; i < MAXSKYBUF; ++i) + for (i = skycolplace_bgra - 4; i < skycolplace_bgra; ++i) { - if (lastskycol_bgra[i] == skycol) + int ic = (i % MAXSKYBUF); // i "checker" - can wrap around the ends of the array + if (lastskycol_bgra[ic] == skycol) { - return (BYTE*)(skybuf_bgra[i]); + return (BYTE*)(skybuf_bgra[ic]); } } From 3a133946610332bec615f444fff75efaaecf14aa Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Thu, 13 Oct 2016 02:47:07 -0400 Subject: [PATCH 5/5] - Changed max sky buffer to 3072 from 2048 --- src/r_plane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index d69e8a5c4..c4d72b1a0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -852,7 +852,7 @@ extern FTexture *rw_pic; // since the most anyone can ever see of the sky is 500 pixels. // We need 4 skybufs because wallscan can draw up to 4 columns at a time. // Need two versions - one for true color and one for palette -#define MAXSKYBUF 2048 +#define MAXSKYBUF 3072 static BYTE skybuf[4][512]; static uint32_t skybuf_bgra[MAXSKYBUF][512]; static DWORD lastskycol[4];