From 9c023c78a412ecd6011eb407e727be55a5c73f92 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 6 Dec 2018 09:20:01 -0500 Subject: [PATCH 01/11] - changing vid_scalefactor now always shows current scaling data unless it gets set to "1" - vid_scaletoheight/width now works in all scaling modes, and can now also scale on custom resolutions directly --- src/r_videoscale.cpp | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/r_videoscale.cpp b/src/r_videoscale.cpp index 0981c01d7..9918def62 100644 --- a/src/r_videoscale.cpp +++ b/src/r_videoscale.cpp @@ -77,11 +77,14 @@ namespace } } +void R_ShowCurrentScaling(); CUSTOM_CVAR(Float, vid_scalefactor, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { setsizeneeded = true; if (self < 0.05 || self > 2.0) self = 1.0; + if (self != 1.0) + R_ShowCurrentScaling(); } CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -142,21 +145,6 @@ void R_ShowCurrentScaling() Printf("Real resolution: %i x %i\nEmulated resolution: %i x %i\n", x1, y1, x2, y2); } -bool R_CalcsShouldBeBlocked() -{ - if (vid_scalemode < 0 || vid_scalemode > 1) - { - Printf("vid_scalemode should be 0 or 1 before using this command.\n"); - return true; - } - if (vid_aspect != 0 && vid_cropaspect == true) - { // just warn ... I'm not going to fix this, it's a pretty niche condition anyway. - Printf("Warning: Using this command while vid_aspect is not 0 will yield results based on FULL screen geometry, NOT cropped!.\n"); - return false; - } - return false; -} - CCMD (vid_showcurrentscaling) { R_ShowCurrentScaling(); @@ -164,24 +152,21 @@ CCMD (vid_showcurrentscaling) CCMD (vid_scaletowidth) { - if (R_CalcsShouldBeBlocked()) - return; - if (argv.argc() > 1) - vid_scalefactor = (float)((double)atof(argv[1]) / screen->GetClientWidth()); - - R_ShowCurrentScaling(); + { + // the following enables the use of ViewportScaledWidth to get the proper dimensions in custom scale modes + vid_scalefactor = 1; + vid_scalefactor = (float)((double)atof(argv[1]) / ViewportScaledWidth(screen->GetClientWidth(), screen->GetClientHeight())); + } } CCMD (vid_scaletoheight) { - if (R_CalcsShouldBeBlocked()) - return; - if (argv.argc() > 1) - vid_scalefactor = (float)((double)atof(argv[1]) / screen->GetClientHeight()); - - R_ShowCurrentScaling(); + { + vid_scalefactor = 1; + vid_scalefactor = (float)((double)atof(argv[1]) / ViewportScaledHeight(screen->GetClientWidth(), screen->GetClientHeight())); + } } inline bool atob(char* I) From f6561ca23b07b3764b110966da15b0da9d5363e1 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 6 Dec 2018 17:04:41 +0200 Subject: [PATCH 02/11] - fixed native calls to LevelLocals.GetUDMF*() functions https://forum.zdoom.org/viewtopic.php?t=62774 --- src/scripting/vmthunks.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index c6998fec2..1bafaf84a 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2451,7 +2451,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetAutomapPosition, GetAutomapPositi ACTION_RETURN_VEC2(AM_GetPosition()); } -static int ZGetUDMFInt(int type, int index, int key) +static int ZGetUDMFInt(FLevelLocals *self, int type, int index, int key) { return GetUDMFInt(type, index, ENamedName(key)); } @@ -2465,7 +2465,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFInt, ZGetUDMFInt) ACTION_RETURN_INT(GetUDMFInt(type, index, key)); } -static double ZGetUDMFFloat(int type, int index, int key) +static double ZGetUDMFFloat(FLevelLocals *self, int type, int index, int key) { return GetUDMFFloat(type, index, ENamedName(key)); } @@ -2479,7 +2479,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetUDMFFloat, ZGetUDMFFloat) ACTION_RETURN_FLOAT(GetUDMFFloat(type, index, key)); } -static void ZGetUDMFString(int type, int index, int key, FString *result) +static void ZGetUDMFString(FLevelLocals *self, int type, int index, int key, FString *result) { *result = GetUDMFString(type, index, ENamedName(key)); } From a7c4fc9dc270624f57c9aa122eecd9080e67992a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 6 Dec 2018 13:57:15 -0500 Subject: [PATCH 03/11] - add plutonia map32 to node regen compatibility - https://forum.zdoom.org/viewtopic.php?f=2&t=62777 --- wadsrc/static/compatibility.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 621f2f9ad..e61374965 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -172,6 +172,7 @@ AF40D0E49BD1B76D4B1AADD8212ADC46 // MAP01 (the wad that shall not be named =P) 3DEE4EFEFAF3260C800A30734F54CE75 // Hellbound, map14 5FAA25F5A6AAB3409CAE0AF87F910341 // DOOM.wad e1m6 94893A0DC429A22ADC4B3A73DA537E16 // DOOM2.WAD map25 +D5F64E02679A81B82006AF34A6A8EAC3 // plutonia.wad map32 { rebuildnodes } From 0dfb0d84272fe410d5e4d48abed51efc267424ed Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 7 Dec 2018 10:20:18 +0200 Subject: [PATCH 04/11] - fixed broken Z coordinate in Actor.Vec3Angle() native call --- src/scripting/vmthunks_actors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 97e5066fb..2823d9263 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -475,7 +475,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, Vec2To, Vec2To) ACTION_RETURN_VEC2(self->Vec2To(t)); } -static void Vec3Angle(AActor *self, double length, double angle, double z, bool absolute, DVector2 *result) +static void Vec3Angle(AActor *self, double length, double angle, double z, bool absolute, DVector3 *result) { *result = self->Vec3Angle(length, angle, z, absolute); } From f17a90ef6911472623fa7e5699f55299af3490b2 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Dec 2018 19:30:00 +0100 Subject: [PATCH 05/11] - implement xor swap for vec registers --- asmjit/asmjit/x86/x86regalloc.cpp | 41 ++++++++++++++++++++++++++----- asmjit/asmjit/x86/x86regalloc_p.h | 32 ++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/asmjit/asmjit/x86/x86regalloc.cpp b/asmjit/asmjit/x86/x86regalloc.cpp index d0b3d58be..b6ede2858 100644 --- a/asmjit/asmjit/x86/x86regalloc.cpp +++ b/asmjit/asmjit/x86/x86regalloc.cpp @@ -271,6 +271,22 @@ Error X86RAPass::emitSwapGp(VirtReg* dstReg, VirtReg* srcReg, uint32_t dstPhysId return kErrorOk; } +Error X86RAPass::emitSwapVec(VirtReg* dstReg, VirtReg* srcReg, uint32_t dstPhysId, uint32_t srcPhysId, const char* reason) noexcept { + ASMJIT_ASSERT(dstPhysId != Globals::kInvalidRegId); + ASMJIT_ASSERT(srcPhysId != Globals::kInvalidRegId); + ASMJIT_ASSERT(dstPhysId != srcPhysId); + + X86Reg a = X86Reg::fromSignature(dstReg->getSignature(), dstPhysId); + X86Reg b = X86Reg::fromSignature(srcReg->getSignature(), srcPhysId); + + ASMJIT_PROPAGATE(cc()->emit(X86Inst::kIdXorps, a, b)); + if (_emitComments) + cc()->getCursor()->setInlineComment(cc()->_cbDataZone.sformat("[%s] %s, %s", reason, dstReg->getName(), srcReg->getName())); + ASMJIT_PROPAGATE(cc()->emit(X86Inst::kIdXorps, b, a)); + ASMJIT_PROPAGATE(cc()->emit(X86Inst::kIdXorps, a, b)); + return kErrorOk; +} + Error X86RAPass::emitImmToReg(uint32_t dstTypeId, uint32_t dstPhysId, const Imm* src) noexcept { ASMJIT_ASSERT(dstPhysId != Globals::kInvalidRegId); @@ -778,6 +794,9 @@ _MoveOrLoad: if (C == X86Reg::kKindGp) { self->swapGp(dVReg, sVd); } + else if (C == X86Reg::kKindVec) { + self->swapVec(dVReg, sVd); + } else { self->spill(dVReg); self->move(sVd, physId); @@ -932,10 +951,13 @@ static ASMJIT_INLINE void X86RAPass_intersectStateVars(X86RAPass* self, X86RASta didWork = true; continue; } - else if (C == X86Reg::kKindGp) { + else if (C == X86Reg::kKindGp || C == X86Reg::kKindVec) { if (aCell.getState() == VirtReg::kStateReg) { if (dVReg->getPhysId() != Globals::kInvalidRegId && aVReg->getPhysId() != Globals::kInvalidRegId) { - self->swapGp(dVReg, aVReg); + if (C == X86Reg::kKindGp) + self->swapGp(dVReg, aVReg); + else + self->swapVec(dVReg, aVReg); didWork = true; continue; @@ -2787,9 +2809,13 @@ ASMJIT_INLINE void X86VarAlloc::alloc() { // allocation tasks by a single 'xchg' instruction, swapping // two registers required by the instruction/node or one register // required with another non-required. - if (C == X86Reg::kKindGp && aPhysId != Globals::kInvalidRegId) { + // Uses xor swap for Vec registers. + if ((C == X86Reg::kKindGp || C == X86Reg::kKindVec) && aPhysId != Globals::kInvalidRegId) { TiedReg* bTied = bVReg->_tied; - _context->swapGp(aVReg, bVReg); + if (C == X86Reg::kKindGp) + _context->swapGp(aVReg, bVReg); + else + _context->swapVec(aVReg, bVReg); aTied->flags |= TiedReg::kRDone; addTiedDone(C); @@ -3341,8 +3367,11 @@ ASMJIT_INLINE void X86CallAlloc::alloc() { // allocation tasks by a single 'xchg' instruction, swapping // two registers required by the instruction/node or one register // required with another non-required. - if (C == X86Reg::kKindGp && sPhysId != Globals::kInvalidRegId) { - _context->swapGp(aVReg, bVReg); + if ((C == X86Reg::kKindGp || C == X86Reg::kKindVec) && sPhysId != Globals::kInvalidRegId) { + if (C == X86Reg::kKindGp) + _context->swapGp(aVReg, bVReg); + else + _context->swapVec(aVReg, bVReg); aTied->flags |= TiedReg::kRDone; addTiedDone(C); diff --git a/asmjit/asmjit/x86/x86regalloc_p.h b/asmjit/asmjit/x86/x86regalloc_p.h index ac9aad2f0..739b5f3e8 100644 --- a/asmjit/asmjit/x86/x86regalloc_p.h +++ b/asmjit/asmjit/x86/x86regalloc_p.h @@ -327,6 +327,7 @@ public: Error emitLoad(VirtReg* vreg, uint32_t id, const char* reason); Error emitSave(VirtReg* vreg, uint32_t id, const char* reason); Error emitSwapGp(VirtReg* aVReg, VirtReg* bVReg, uint32_t aId, uint32_t bId, const char* reason) noexcept; + Error emitSwapVec(VirtReg* aVReg, VirtReg* bVReg, uint32_t aId, uint32_t bId, const char* reason) noexcept; Error emitImmToReg(uint32_t dstTypeId, uint32_t dstPhysId, const Imm* src) noexcept; Error emitImmToStack(uint32_t dstTypeId, const X86Mem* dst, const Imm* src) noexcept; @@ -515,6 +516,37 @@ public: ASMJIT_X86_CHECK_STATE } + //! Swap two registers + //! + //! Xor swap on Vec registers. + ASMJIT_INLINE void swapVec(VirtReg* aVReg, VirtReg* bVReg) { + ASMJIT_ASSERT(aVReg != bVReg); + + ASMJIT_ASSERT(aVReg->getKind() == X86Reg::kKindVec); + ASMJIT_ASSERT(aVReg->getState() == VirtReg::kStateReg); + ASMJIT_ASSERT(aVReg->getPhysId() != Globals::kInvalidRegId); + + ASMJIT_ASSERT(bVReg->getKind() == X86Reg::kKindVec); + ASMJIT_ASSERT(bVReg->getState() == VirtReg::kStateReg); + ASMJIT_ASSERT(bVReg->getPhysId() != Globals::kInvalidRegId); + + uint32_t aIndex = aVReg->getPhysId(); + uint32_t bIndex = bVReg->getPhysId(); + + emitSwapVec(aVReg, bVReg, aIndex, bIndex, "Swap"); + + aVReg->setPhysId(bIndex); + bVReg->setPhysId(aIndex); + + _x86State.getListByKind(X86Reg::kKindVec)[aIndex] = bVReg; + _x86State.getListByKind(X86Reg::kKindVec)[bIndex] = aVReg; + + uint32_t m = aVReg->isModified() ^ bVReg->isModified(); + _x86State._modified.xor_(X86Reg::kKindVec, (m << aIndex) | (m << bIndex)); + + ASMJIT_X86_CHECK_STATE + } + // -------------------------------------------------------------------------- // [Alloc / Spill] // -------------------------------------------------------------------------- From e70138a26680bafe21871aebc7a99391bc4a3cc4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 7 Dec 2018 20:15:02 +0100 Subject: [PATCH 06/11] - fixed crash with FraggleScript in Nimrod MAP02. --- src/fragglescript/t_variable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fragglescript/t_variable.cpp b/src/fragglescript/t_variable.cpp index 6ece4f22a..d38e62120 100644 --- a/src/fragglescript/t_variable.cpp +++ b/src/fragglescript/t_variable.cpp @@ -148,7 +148,7 @@ AActor* actorvalue(const svalue_t &svalue) return NULL; } // Inventory items in the player's inventory have to be considered non-present. - if (svalue.value.mobj == NULL || !svalue.value.mobj->IsMapActor()) + if (SpawnedThings[intval] == nullptr || !SpawnedThings[intval]->IsMapActor()) { return NULL; } From 92b722e0eee7dcc10f228154dfbcf48ee549bce9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 8 Dec 2018 11:56:31 +0100 Subject: [PATCH 07/11] - don't put mutexes into static local variables. Their initialization semantics are not safe for synchronization objects. --- src/polyrenderer/poly_renderthread.cpp | 6 ++---- src/swrenderer/r_renderthread.cpp | 6 ++---- src/swrenderer/r_swcolormaps.cpp | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/polyrenderer/poly_renderthread.cpp b/src/polyrenderer/poly_renderthread.cpp index 7febb4bb7..22900c17a 100644 --- a/src/polyrenderer/poly_renderthread.cpp +++ b/src/polyrenderer/poly_renderthread.cpp @@ -74,6 +74,7 @@ void PolyRenderThread::FlushDrawQueue() } } +static std::mutex loadmutex; void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) { if (texture == nullptr) @@ -87,8 +88,6 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) // It is critical that this function is called before any direct // calls to GetPixels for this to work. - static std::mutex loadmutex; - std::unique_lock lock(loadmutex); texture->GetPixels(style); @@ -101,10 +100,9 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) } } +static std::mutex polyobjmutex; void PolyRenderThread::PreparePolyObject(subsector_t *sub) { - static std::mutex polyobjmutex; - std::unique_lock lock(polyobjmutex); if (sub->BSP == nullptr || sub->BSP->bDirty) diff --git a/src/swrenderer/r_renderthread.cpp b/src/swrenderer/r_renderthread.cpp index 986879618..90a0792ea 100644 --- a/src/swrenderer/r_renderthread.cpp +++ b/src/swrenderer/r_renderthread.cpp @@ -89,6 +89,7 @@ namespace swrenderer return pal_drawers.get(); } + static std::mutex loadmutex; void RenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) { if (texture == nullptr) @@ -102,8 +103,6 @@ namespace swrenderer // It is critical that this function is called before any direct // calls to GetPixels for this to work. - static std::mutex loadmutex; - std::unique_lock lock(loadmutex); texture->GetPixels(style); @@ -116,10 +115,9 @@ namespace swrenderer } } + static std::mutex polyobjmutex; void RenderThread::PreparePolyObject(subsector_t *sub) { - static std::mutex polyobjmutex; - std::unique_lock lock(polyobjmutex); if (sub->BSP == nullptr || sub->BSP->bDirty) diff --git a/src/swrenderer/r_swcolormaps.cpp b/src/swrenderer/r_swcolormaps.cpp index 13c66706b..d5b374ad1 100644 --- a/src/swrenderer/r_swcolormaps.cpp +++ b/src/swrenderer/r_swcolormaps.cpp @@ -70,12 +70,12 @@ TArray SpecialSWColormaps; // Colored Lighting Stuffs // //========================================================================== +static std::mutex buildmapmutex; static FDynamicColormap *CreateSpecialLights (PalEntry color, PalEntry fade, int desaturate) { // GetSpecialLights is called by the scene worker threads. // If we didn't find the colormap, search again, but this time one thread at a time - static std::mutex buildmapmutex; std::unique_lock lock(buildmapmutex); // If this colormap has already been created, just return it From 888af3d684c38009aacd911e28791c4c05b92b56 Mon Sep 17 00:00:00 2001 From: Player701 Date: Sat, 8 Dec 2018 13:53:13 +0300 Subject: [PATCH 08/11] - Added Plutonia 2 MAP10 and MAP11 to the "rebuildnodes" compatibility list. --- wadsrc/static/compatibility.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index e61374965..030cea322 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -173,6 +173,8 @@ AF40D0E49BD1B76D4B1AADD8212ADC46 // MAP01 (the wad that shall not be named =P) 5FAA25F5A6AAB3409CAE0AF87F910341 // DOOM.wad e1m6 94893A0DC429A22ADC4B3A73DA537E16 // DOOM2.WAD map25 D5F64E02679A81B82006AF34A6A8EAC3 // plutonia.wad map32 +BA4860C7A2F5D705DB32A1A38DB77EC4 // pl2.wad map10 +EDA5CE7C462BD171BF8110AC56B67857 // pl2.wad map11 { rebuildnodes } From 670d975a337242049808eae7e17684c174769d89 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 8 Dec 2018 23:31:55 +0100 Subject: [PATCH 09/11] - moved argsCache out of JitCompiler::CreateFuncSignature --- src/scripting/vm/jit_call.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scripting/vm/jit_call.cpp b/src/scripting/vm/jit_call.cpp index f51fd1c39..137203017 100644 --- a/src/scripting/vm/jit_call.cpp +++ b/src/scripting/vm/jit_call.cpp @@ -543,6 +543,8 @@ void JitCompiler::EmitNativeCall(VMNativeFunction *target) ParamOpcodes.Clear(); } +static std::map>> argsCache; + asmjit::FuncSignature JitCompiler::CreateFuncSignature() { using namespace asmjit; @@ -657,7 +659,6 @@ asmjit::FuncSignature JitCompiler::CreateFuncSignature() } // FuncSignature only keeps a pointer to its args array. Store a copy of each args array variant. - static std::map>> argsCache; std::unique_ptr> &cachedArgs = argsCache[key]; if (!cachedArgs) cachedArgs.reset(new TArray(args)); From f6bb33787bbb1742a5fed068bb0c07f1874cdde2 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 9 Dec 2018 10:13:43 +0200 Subject: [PATCH 10/11] - fixed Actor.A_StopSound() native call Wrong function overload was selected by compiler https://forum.zdoom.org/viewtopic.php?t=62820 --- src/scripting/vmthunks_actors.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 2823d9263..a067a296e 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -128,7 +128,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetPointer, COPY_AAPTR) // //========================================================================== -DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopSound, S_StopSound) +static void NativeStopSound(AActor *actor, int slot) +{ + S_StopSound(actor, slot); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopSound, NativeStopSound) { PARAM_SELF_PROLOGUE(AActor); PARAM_INT(slot); From 40f77e5dac41b158bbb0a96f43bdbca4925dab1a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 9 Dec 2018 13:00:36 +0200 Subject: [PATCH 11/11] - removed erroneous assertion https://forum.zdoom.org/viewtopic.php?t=62815 --- src/v_text.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/v_text.cpp b/src/v_text.cpp index 9f6e41161..e9a78bee4 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -219,8 +219,6 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double int kerning; FTexture *pic; - assert(string[0] != '$'); - if (parms.celly == 0) parms.celly = font->GetHeight() + 1; parms.celly *= parms.scaley;