From 0d5cb0536e3077844761f990b2a87132a96c72d7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 9 Mar 2017 18:08:09 -0500 Subject: [PATCH 1/7] - enable multiprocessor compilation with MSVC++ using /MP for MSBuild - Target NEON processors for ARM. --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d50274473..37746a89e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -413,6 +413,11 @@ else( X64 ) set( CMAKE_CXX_FLAGS ${SAFE_CMAKE_CXX_FLAGS} ) endif( X64 ) +# Set up flags for MSVC +if (MSVC) + set( CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}" ) +endif (MSVC) + # Set up flags for GCC if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) @@ -471,6 +476,11 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set( CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_C_FLAGS}" ) set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_CXX_FLAGS}" ) + # ARM processors (Raspberry Pi, et al) - enable ARM NEON support. + if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") + set( CMAKE_CXX_FLAGS "-mfpu=neon ${CMAKE_CXX_FLAGS}" ) + endif () + # Use the highest C++ standard available since VS2015 compiles with C++14 # but we only require C++11. The recommended way to do this in CMake is to # probably to use target_compile_features, but I don't feel like maintaining From cb9f2e2eb07196da13d2f290726bb7fe4c00015b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 10 Mar 2017 00:18:20 -0500 Subject: [PATCH 2/7] - fixed: P_AlignFlat's y-offset data was ignored when calculating plane offsets for the final render --- src/swrenderer/plane/r_flatplane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index b3c695c78..a086cd323 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -69,7 +69,7 @@ namespace swrenderer { double cosine = cos(planeang), sine = sin(planeang); pviewx = pl->xform.xOffs + ViewPos.X * cosine - ViewPos.Y * sine; - pviewy = pl->xform.yOffs - ViewPos.X * sine - ViewPos.Y * cosine; + pviewy = pl->xform.yOffs + pl->xform.baseyOffs - ViewPos.X * sine - ViewPos.Y * cosine; } else { From 5b9fece062e6343fb58b81b57ea29055ae69d1f4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 10 Mar 2017 10:37:43 +0100 Subject: [PATCH 3/7] - fixed bad definition of FBlockThingsIterator.Next(). When implementing the BlockLinesIterator apparently some incorrect code got modified. - fixed an uninitialized variable in P_CheckSight. --- src/p_maputl.cpp | 6 +++--- src/p_sight.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index c4fe47f31..053f44c13 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -954,7 +954,7 @@ DEFINE_ACTION_FUNCTION(DBlockLinesIterator, CreateFromPos) ACTION_RETURN_OBJECT(new DBlockLinesIterator(x, y, z, h, radius, sec)); } -DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Next) +DEFINE_ACTION_FUNCTION(DBlockLinesIterator, Next) { PARAM_SELF_PROLOGUE(DBlockLinesIterator); ACTION_RETURN_BOOL(self->Next()); @@ -1293,9 +1293,9 @@ DEFINE_ACTION_FUNCTION(DBlockThingsIterator, CreateFromPos) ACTION_RETURN_OBJECT(new DBlockThingsIterator(x, y, z, h, radius, ignore, nullptr)); } -DEFINE_ACTION_FUNCTION(DBlockLinesIterator, Next) +DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Next) { - PARAM_SELF_PROLOGUE(DBlockLinesIterator); + PARAM_SELF_PROLOGUE(DBlockThingsIterator); ACTION_RETURN_BOOL(self->Next()); } diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 68bf2ed3d..92cd52b95 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -735,7 +735,7 @@ bool SightCheck::P_SightPathTraverse () // step through map blocks // Count is present to prevent a round off error from skipping the break - int itres; + int itres = -1; for (count = 0 ; count < 1000 ; count++) { // end traversing when reaching the end of the blockmap From f1630cebf3bd2084a079c39de5ee0e22420e8d28 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 10 Mar 2017 12:09:15 +0100 Subject: [PATCH 4/7] - backported Line_Align... fix. --- 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 62730e731..cc62d18a9 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1444,7 +1444,7 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t { double cosine = cos(planeang), sine = sin(planeang); pviewx = FLOAT2FIXED(pl->xform.xOffs + ViewPos.X * cosine - ViewPos.Y * sine); - pviewy = FLOAT2FIXED(pl->xform.yOffs - ViewPos.X * sine - ViewPos.Y * cosine); + pviewy = FLOAT2FIXED(pl->xform.yOffs + pl->xform.baseyOffs - ViewPos.X * sine - ViewPos.Y * cosine); } else { From 2f2dcaf5fee174c0caa555f7492cb8b4ca7d3bd5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Mar 2017 15:40:15 +0100 Subject: [PATCH 5/7] Fix crash when vid_hw2d is off --- src/swrenderer/r_swcanvas.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/swrenderer/r_swcanvas.cpp b/src/swrenderer/r_swcanvas.cpp index aa817e707..82f34313f 100644 --- a/src/swrenderer/r_swcanvas.cpp +++ b/src/swrenderer/r_swcanvas.cpp @@ -110,6 +110,13 @@ void SWCanvas::DrawTexture(DCanvas *canvas, FTexture *img, DrawParms &parms) double centeryback = viewport->CenterY; viewport->CenterY = 0; + int oldviewwindowx = 0; + int oldviewwindowy = 0; + oldviewwindowx = viewwindowx; + oldviewwindowy = viewwindowy; + viewwindowx = 0; + viewwindowy = 0; + // There is not enough precision in the drawing routines to keep the full // precision for y0. :( double sprtopscreen; @@ -187,6 +194,8 @@ void SWCanvas::DrawTexture(DCanvas *canvas, FTexture *img, DrawParms &parms) } viewport->CenterY = centeryback; + viewwindowx = oldviewwindowx; + viewwindowy = oldviewwindowy; } viewport->RenderTarget->Unlock(); From 1996c1bc0b61c0374d4123089bbcb80c6d6063d7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Mar 2017 15:40:33 +0100 Subject: [PATCH 6/7] Fix crash HOM effect when vid_hw2d is off --- src/gl/system/gl_swframebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index a0fc6e716..c721af665 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -1076,7 +1076,7 @@ void OpenGLSWFrameBuffer::CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_ int OpenGLSWFrameBuffer::GetPageCount() { - return 1; + return 2; } //========================================================================== From d637ee5624f6c1c421afb515855b62a0dfc2deec Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 Mar 2017 16:23:16 +0100 Subject: [PATCH 7/7] Fix span dynamic light rendering glitch --- src/swrenderer/plane/r_flatplane.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index a086cd323..c7cadfbab 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -209,19 +209,27 @@ namespace swrenderer drawerargs.dc_viewpos.Z = (float)((viewport->CenterY - y - 0.5) / viewport->InvZtoScale * zspan); drawerargs.dc_viewpos_step.X = (float)(zspan / viewport->CenterX); - static DrawerLight lightbuffer[64 * 1024]; - static int nextlightindex = 0; - // Plane normal drawerargs.dc_normal.X = 0.0f; drawerargs.dc_normal.Y = 0.0f; drawerargs.dc_normal.Z = (y >= viewport->CenterY) ? 1.0f : -1.0f; - // Setup lights for row - drawerargs.dc_num_lights = 0; - drawerargs.dc_lights = lightbuffer + nextlightindex; + // Calculate max lights that can touch the row so we can allocate memory for the list + int max_lights = 0; VisiblePlaneLight *cur_node = light_list; - while (cur_node && nextlightindex < 64 * 1024) + while (cur_node) + { + if (!(cur_node->lightsource->flags2&MF2_DORMANT)) + max_lights++; + cur_node = cur_node->next; + } + + drawerargs.dc_num_lights = 0; + drawerargs.dc_lights = Thread->FrameMemory->AllocMemory(max_lights); + + // Setup lights for row + cur_node = light_list; + while (cur_node) { double lightX = cur_node->lightsource->X() - ViewPos.X; double lightY = cur_node->lightsource->Y() - ViewPos.Y; @@ -244,7 +252,6 @@ namespace swrenderer uint32_t green = cur_node->lightsource->GetGreen(); uint32_t blue = cur_node->lightsource->GetBlue(); - nextlightindex++; auto &light = drawerargs.dc_lights[drawerargs.dc_num_lights++]; light.x = lx; light.y = lconstant; @@ -255,9 +262,6 @@ namespace swrenderer cur_node = cur_node->next; } - - if (nextlightindex == 64 * 1024) - nextlightindex = 0; } else {