From 97b664968e8150ee7dd91f7f51b4a67ac55854cb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 10:26:51 +0200 Subject: [PATCH 1/7] - removed a few unused VM opcodes. --- src/scripting/vm/vmexec.cpp | 8 -------- src/scripting/vm/vmexec.h | 22 ---------------------- src/scripting/vm/vmops.h | 5 ----- 3 files changed, 35 deletions(-) diff --git a/src/scripting/vm/vmexec.cpp b/src/scripting/vm/vmexec.cpp index 0bad8c055..eb212a646 100644 --- a/src/scripting/vm/vmexec.cpp +++ b/src/scripting/vm/vmexec.cpp @@ -104,14 +104,6 @@ void ThrowVMException(VMException *x); if (a == NULL) { ThrowAbortException(x, nullptr); } \ ptr = (VM_SBYTE *)a + o -static const VM_UWORD ZapTable[16] = -{ - 0x00000000, 0x000000FF, 0x0000FF00, 0x0000FFFF, - 0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x00FFFFFF, - 0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF, - 0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFFFF -}; - #ifdef NDEBUG #define WAS_NDEBUG 1 #else diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index 452414c99..7e8a53a6a 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -1195,28 +1195,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret) reg.d[a] = ~reg.d[B]; NEXTOP; - OP(SEXT): - ASSERTD(a); ASSERTD(B); - reg.d[a] = (VM_SWORD)(reg.d[B] << C) >> C; - NEXTOP; - - OP(ZAP_R): - ASSERTD(a); ASSERTD(B); ASSERTD(C); - reg.d[a] = reg.d[B] & ZapTable[(reg.d[C] & 15) ^ 15]; - NEXTOP; - OP(ZAP_I): - ASSERTD(a); ASSERTD(B); - reg.d[a] = reg.d[B] & ZapTable[(C & 15) ^ 15]; - NEXTOP; - OP(ZAPNOT_R): - ASSERTD(a); ASSERTD(B); ASSERTD(C); - reg.d[a] = reg.d[B] & ZapTable[reg.d[C] & 15]; - NEXTOP; - OP(ZAPNOT_I): - ASSERTD(a); ASSERTD(B); - reg.d[a] = reg.d[B] & ZapTable[C & 15]; - NEXTOP; - OP(EQ_R): ASSERTD(B); ASSERTD(C); CMPJMP(reg.d[B] == reg.d[C]); diff --git a/src/scripting/vm/vmops.h b/src/scripting/vm/vmops.h index dac907580..fb0a9e50e 100644 --- a/src/scripting/vm/vmops.h +++ b/src/scripting/vm/vmops.h @@ -174,11 +174,6 @@ xx(MAX_RK, max, RIRIKI, MAX_RR, 4, REGT_INT), xx(ABS, abs, RIRI, NOP, 0, 0), // dA = abs(dB) xx(NEG, neg, RIRI, NOP, 0, 0), // dA = -dB xx(NOT, not, RIRI, NOP, 0, 0), // dA = ~dB -xx(SEXT, sext, RIRII8, NOP, 0, 0), // dA = dB, sign extended by shifting left then right by C -xx(ZAP_R, zap, RIRIRI, NOP, 0, 0), // dA = dB, with bytes zeroed where bits in C/dC are one -xx(ZAP_I, zap, RIRII8, NOP, 0, 0), -xx(ZAPNOT_R, zapnot, RIRIRI, NOP, 0, 0), // dA = dB, with bytes zeroed where bits in C/dC are zero -xx(ZAPNOT_I, zapnot, RIRII8, NOP, 0, 0), xx(EQ_R, beq, CIRR, NOP, 0, 0), // if ((dB == dkC) != A) then pc++ xx(EQ_K, beq, CIRK, EQ_R, 4, REGT_INT), xx(LT_RR, blt, CIRR, NOP, 0, 0), // if ((dkB < dkC) != A) then pc++ From c8e631bf26a97917e432d5deca918c059a9a30a2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 11:42:44 +0200 Subject: [PATCH 2/7] - fixed: The colormap was not fully initialized for 3D floors in sectors where neither the original floor nor ceiling were visible. --- src/gl/scene/gl_flats.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c7ab0eeb2..98f5afa80 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -750,6 +750,7 @@ void GLFlat::ProcessSector(sector_t * frontsector) // is no longer necessary. ceiling = true; + Colormap = frontsector->Colormap; for (k = 0; k < (int)x.ffloors.Size(); k++) { rover = x.ffloors[k]; From c1e64fa5760b7702210253b4e6152a14eb67a647 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 12:03:20 +0200 Subject: [PATCH 3/7] - fixed: The rail trail should use r_trail_sparsity, not r_spiral_sparsity. - fixed: Spawning actors on the rail trail must ignore the sparsity CVARs completely. --- src/p_effect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 81a1bc5d6..7163b7548 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -814,7 +814,7 @@ void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, // Create the inner trail. if (color2 != -1 && r_rail_trailsparsity > 0 && spawnclass == NULL) { - double stepsize = 3 * r_rail_spiralsparsity * sparsity; + double stepsize = 3 * r_rail_trailsparsity * sparsity; int trail_steps = xs_FloorToInt(steps * r_rail_trailsparsity / sparsity); color2 = color2 == 0 ? -1 : ParticleColor(color2); @@ -891,7 +891,7 @@ void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, if (sparsity < 1) sparsity = 32; - double stepsize = 3 * r_rail_spiralsparsity * sparsity; + double stepsize = sparsity; int trail_steps = (int)((steps * 3) / sparsity); DVector3 diff(0, 0, 0); From 9fc309d5b5468cb80d6aea502939f48c7bcf611b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 12:20:33 +0200 Subject: [PATCH 4/7] - stop the music when processing a fatal error. --- src/posix/cocoa/i_main.mm | 2 ++ src/win32/i_main.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/posix/cocoa/i_main.mm b/src/posix/cocoa/i_main.mm index d8fef4932..1c418b91b 100644 --- a/src/posix/cocoa/i_main.mm +++ b/src/posix/cocoa/i_main.mm @@ -32,6 +32,7 @@ */ #include "i_common.h" +#include "s_sound.h" #include #include @@ -125,6 +126,7 @@ void popterm() void Mac_I_FatalError(const char* const message) { I_SetMainWindowVisible(false); + S_StopMusic(true); FConsoleWindow::GetInstance().ShowFatalError(message); } diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index c82fb1969..4ae1595ef 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -81,6 +81,7 @@ #include "doomstat.h" #include "r_utility.h" #include "g_levellocals.h" +#include "s_sound.h" #include "stats.h" #include "st_start.h" @@ -1060,6 +1061,7 @@ void DoMain (HINSTANCE hInstance) { I_ShutdownGraphics (); RestoreConView (); + S_StopMusic(true); I_FlushBufferedConsoleStuff(); if (error.GetMessage ()) { From e1cd0dc588087933c0c93bda132e89781387af8c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 16:31:44 +0200 Subject: [PATCH 5/7] - major optimization on carry scroller code. The old version was checking every single actor in every single sector for being affected by a carry scroller if there was so much as a single such scroller in the map. Changed it so that the scroll thinker flags all actors in the affected sectors so that these expensive calculations can be skipped for everything else. This change and reduce think time by 1/3 on maps like ZDCMP2 (on the test machine it went down from 6 ms to 4 ms on this map.) --- src/actor.h | 1 + src/p_mobj.cpp | 9 ++++++++- src/p_scroll.cpp | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/actor.h b/src/actor.h index 043f07ae5..be3f28ec6 100644 --- a/src/actor.h +++ b/src/actor.h @@ -401,6 +401,7 @@ enum ActorFlag7 enum ActorFlag8 { MF8_FRIGHTENING = 0x00000001, // for those moments when halloween just won't do + MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector }; // --- mobj.renderflags --- diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2e16347db..1fb7e259d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4098,6 +4098,7 @@ void AActor::Tick () CheckPortalTransition(false); LinkToWorld(&ctx); } + flags8 &= MF8_INSCROLLSEC; } else { @@ -4250,12 +4251,16 @@ void AActor::Tick () // [RH] Consider carrying sectors here DVector2 cumm(0, 0); - if ((level.Scrolls.Size() != 0 || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR)) + + if ((((flags8 & MF8_INSCROLLSEC) && level.Scrolls.Size() > 0) || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR)) { double height, waterheight; // killough 4/4/98: add waterheight const msecnode_t *node; int countx, county; + // Clear the flag for the next frame. + flags8 &= MF8_INSCROLLSEC; + // killough 3/7/98: Carry things on floor // killough 3/20/98: use new sector list which reflects true members // killough 3/27/98: fix carrier bug @@ -5079,6 +5084,8 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a { level.total_secrets++; } + // force scroller check in the first tic. + actor->flags8 |= MF8_INSCROLLSEC; return actor; } diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index f2661a2a1..d8666d9a7 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -256,6 +256,11 @@ void DScroller::Tick () case EScroll::sc_carry: level.Scrolls[m_Affectee].X += dx; level.Scrolls[m_Affectee].Y += dy; + // mark all potentially affected things here so that the very expensive calculation loop in AActor::Tick does not need to run for actors which do not touch a scrolling sector. + for (auto n = level.sectors[m_Affectee].touching_thinglist; n; n = n->m_snext) + { + n->m_thing->flags8 |= MF8_INSCROLLSEC; + } break; case EScroll::sc_carry_ceiling: // to be added later From a4231ffd001ba1bfa91702ba0abd3b8587f926d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 21:33:48 +0200 Subject: [PATCH 6/7] - more handling of some very broken old ATI drivers. --- src/gl/system/gl_interface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 308d741bb..e24ac553b 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -213,6 +213,16 @@ void gl_LoadExtensions() gl.glslversion = 0; gl.flags |= RFL_NO_CLIP_PLANES; } + else if (gl.glslversion < 1.4f && !CheckExtension("GL_ARB_uniform_buffer_object")) + { + // Some old ATI drivers report OpenGL 3.1 with GLSL version 1.3 and no support for uniform buffers. + // We have no choice but to force them down to OpenGL 2.x. + gl.legacyMode = true; + gl.lightmethod = LM_LEGACY; + gl.buffermethod = BM_LEGACY; + gl.glslversion = 0; + gl.flags |= RFL_NO_CLIP_PLANES; + } else { gl.legacyMode = false; From fc8639226d231b151585edfb72b2e80b700f48b2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 May 2017 21:36:32 +0200 Subject: [PATCH 7/7] - yet again Visual Studio's autocompletion feature deleted some tildes. --- src/p_mobj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 1fb7e259d..54be4a2de 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4098,7 +4098,7 @@ void AActor::Tick () CheckPortalTransition(false); LinkToWorld(&ctx); } - flags8 &= MF8_INSCROLLSEC; + flags8 &= ~MF8_INSCROLLSEC; } else { @@ -4259,7 +4259,7 @@ void AActor::Tick () int countx, county; // Clear the flag for the next frame. - flags8 &= MF8_INSCROLLSEC; + flags8 &= ~MF8_INSCROLLSEC; // killough 3/7/98: Carry things on floor // killough 3/20/98: use new sector list which reflects true members