From 0036f7fadea94459a58d8ad3401341d5a888f151 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 28 Jan 2021 12:56:10 +0200 Subject: [PATCH 1/3] - fixed wrong gdtoa definitions for Apple ARM64 https://forum.zdoom.org/viewtopic.php?t=71303 --- libraries/gdtoa/gdtoa.h | 9 ++------- libraries/gdtoa/gdtoaimp.h | 15 ++------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/libraries/gdtoa/gdtoa.h b/libraries/gdtoa/gdtoa.h index 8b7390a28..516e6a68c 100644 --- a/libraries/gdtoa/gdtoa.h +++ b/libraries/gdtoa/gdtoa.h @@ -48,20 +48,15 @@ THIS SOFTWARE. * compiling to deal with, which means we can't run the generation * program on the target. */ -#if defined(__x86_64__) +#if defined(__x86_64__) || defined(__arm64__) #define IEEE_8087 #define Arith_Kind_ASL 1 #define Long int #define Intcast (int)(long) #define Double_Align #define X64_bit_pointers -#elif defined(__i386__) -#define IEEE_8087 -#define Arith_Kind_ASL 1 #else -#define IEEE_MC68k -#define Arith_Kind_ASL 2 -#define Double_Align +#error Unsupported architecture #endif #else #include "arith.h" diff --git a/libraries/gdtoa/gdtoaimp.h b/libraries/gdtoa/gdtoaimp.h index c63bf3135..ae7eeb572 100644 --- a/libraries/gdtoa/gdtoaimp.h +++ b/libraries/gdtoa/gdtoaimp.h @@ -202,7 +202,7 @@ THIS SOFTWARE. * all ia32 compilers had phased out extended precision. */ #elif defined(__APPLE__) -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) || defined(__arm64__) #define f_QNAN 0xffc00000 #define d_QNAN0 0x0 #define d_QNAN1 0xfff80000 @@ -216,18 +216,7 @@ THIS SOFTWARE. #define ldus_QNAN3 0xc000 #define ldus_QNAN4 0xffff #else -#define f_QNAN 0xffc00000 -#define d_QNAN0 0xfff80000 -#define d_QNAN1 0x0 -#define ld_QNAN0 0xfff80000 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x0 -#define ldus_QNAN0 0xfff8 -#define ldus_QNAN1 0x0 -#define ldus_QNAN2 0x0 -#define ldus_QNAN3 0x0 -#define ldus_QNAN4 0x0 +#error Unsupported architecture #endif #else #include "gd_qnan.h" From f108a106c90cff09ee5017720e4d2d3a6b8ae021 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Jan 2021 13:54:18 +0100 Subject: [PATCH 2/3] - backend update from Raze. --- src/common/filesystem/ancientzip.h | 2 +- src/common/filesystem/filesystem.cpp | 6 ++++-- src/common/rendering/gl/gl_hwtexture.cpp | 1 + src/common/utility/cmdlib.h | 2 ++ src/common/utility/m_fixed.h | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/common/filesystem/ancientzip.h b/src/common/filesystem/ancientzip.h index 3b1497e02..621505504 100644 --- a/src/common/filesystem/ancientzip.h +++ b/src/common/filesystem/ancientzip.h @@ -41,7 +41,7 @@ public: int Explode(unsigned char *out, unsigned int outsize, FileReader &in, unsigned int insize, int flags); }; -class CExplosionError : CRecoverableError +class CExplosionError : public CRecoverableError { public: CExplosionError(const char *message) : CRecoverableError(message) {} diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 7fd559502..0ea4ac7a6 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -837,6 +837,7 @@ void FileSystem::InitHashChains (void) { unsigned int i, j; + NumEntries = FileInfo.Size(); Hashes.Resize(8 * NumEntries); // Mark all buckets as empty memset(Hashes.Data(), -1, Hashes.Size() * sizeof(Hashes[0])); @@ -1522,10 +1523,11 @@ const char *FileSystem::GetResourceFileFullName (int rfnum) const noexcept bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/) { - FString name2, type2, path; + FString name2=name, type2, path; // The old code said 'filename' and ignored the path, this looked like a bug. - auto lump = FindFile(name); + FixPathSeperator(name2); + auto lump = FindFile(name2); if (lump < 0) return false; // Does not exist. auto oldlump = FileInfo[lump]; diff --git a/src/common/rendering/gl/gl_hwtexture.cpp b/src/common/rendering/gl/gl_hwtexture.cpp index 70c353082..0043a67b8 100644 --- a/src/common/rendering/gl/gl_hwtexture.cpp +++ b/src/common/rendering/gl/gl_hwtexture.cpp @@ -312,6 +312,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i { glTextureBytes = 1; forcenofilter = true; + needmipmap = false; } int w = 0, h = 0; diff --git a/src/common/utility/cmdlib.h b/src/common/utility/cmdlib.h index 9c85aa05f..4c4468c98 100644 --- a/src/common/utility/cmdlib.h +++ b/src/common/utility/cmdlib.h @@ -99,5 +99,7 @@ inline void fillshort(void* buff, size_t count, uint16_t clear) } } +template inline constexpr T Sgn(const T& val) { return (val > 0) - (val < 0); } + #endif diff --git a/src/common/utility/m_fixed.h b/src/common/utility/m_fixed.h index 99115df6e..30209d635 100644 --- a/src/common/utility/m_fixed.h +++ b/src/common/utility/m_fixed.h @@ -7,8 +7,11 @@ __forceinline constexpr int32_t MulScale(int32_t a, int32_t b, int32_t shift) { return (int32_t)(((int64_t)a * b) >> shift); } +__forceinline constexpr double MulScaleF(double a, double b, int32_t shift) { return (a * b) * (1. / (uint32_t(1) << shift)); } __forceinline constexpr int32_t DMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d) >> shift); } +__forceinline constexpr int32_t TMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d + (int64_t)e * f) >> shift); } __forceinline constexpr int32_t DivScale(int32_t a, int32_t b, int shift) { return (int32_t)(((int64_t)a << shift) / b); } +__forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { return ((a << shift) / b); } #include "xs_Float.h" From 638c49fe0f73d7ab1cf12b6abc11bb11c8e201fc Mon Sep 17 00:00:00 2001 From: drfrag Date: Fri, 29 Jan 2021 19:29:42 +0100 Subject: [PATCH 3/3] - Fixed nodes were not rebuilt after loading broken extended nodes. --- src/maploader/maploader.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 1b712a449..7faaa01d1 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -746,6 +746,11 @@ bool MapLoader::LoadExtendedNodes (FileReader &dalump, uint32_t id) catch (const CRecoverableError& err) { Printf("Error loading nodes: %s.\n", err.what()); + + ForceNodeBuild = true; + Level->subsectors.Clear(); + Level->segs.Clear(); + Level->nodes.Clear(); return false; } } @@ -758,7 +763,8 @@ bool MapLoader::LoadExtendedNodes (FileReader &dalump, uint32_t id) catch (CRecoverableError &error) { Printf("Error loading nodes: %s\n", error.GetMessage()); - + + ForceNodeBuild = true; Level->subsectors.Clear(); Level->segs.Clear(); Level->nodes.Clear();