From a2801f9da401195f7915d8f57473ced8e249f176 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sun, 11 Oct 2026 07:48:03 -0400 Subject: [PATCH] [Fix] (Build): restore the MSVC Windows build of the opengl32 drop-in --- MobileGL/MG_Impl/EGLImpl/Exporting/GlvndVendor.cpp | 12 ++++++++++-- MobileGL/MG_Impl/Pipe/TextureEmit.h | 2 +- .../GLState/BufferState/PersistentMapTracker.cpp | 5 +++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/MobileGL/MG_Impl/EGLImpl/Exporting/GlvndVendor.cpp b/MobileGL/MG_Impl/EGLImpl/Exporting/GlvndVendor.cpp index b6cf3efd..edcc8a0a 100644 --- a/MobileGL/MG_Impl/EGLImpl/Exporting/GlvndVendor.cpp +++ b/MobileGL/MG_Impl/EGLImpl/Exporting/GlvndVendor.cpp @@ -348,8 +348,16 @@ namespace { void* EGLAPIENTRY VendorGetDispatchAddress(const char* procName) { return LookupEntryPoint(procName); } } // namespace -extern "C" MOBILEGL_EGL_API EGLBoolean __egl_Main(uint32_t version, const __EGLapiExports* exports, - __EGLvendorInfo* vendor, __EGLapiImports* imports) { +// libeglabi.h has already declared this prototype without an export attribute, and MSVC refuses a +// redeclaration that adds dllexport. Windows has no glvnd to look the symbol up, so it is a plain +// external definition there. +#ifdef _WIN32 +#define MOBILEGL_GLVND_EGL_MAIN extern "C" +#else +#define MOBILEGL_GLVND_EGL_MAIN MOBILEGL_EGL_API +#endif +MOBILEGL_GLVND_EGL_MAIN EGLBoolean __egl_Main(uint32_t version, const __EGLapiExports* exports, + __EGLvendorInfo* vendor, __EGLapiImports* imports) { (void)vendor; if (EGL_VENDOR_ABI_GET_MAJOR_VERSION(version) != EGL_VENDOR_ABI_MAJOR_VERSION) { // A vendor that does not know the ABI it is being handed must say so, not guess: the diff --git a/MobileGL/MG_Impl/Pipe/TextureEmit.h b/MobileGL/MG_Impl/Pipe/TextureEmit.h index cf7774ed..4a27c0d4 100644 --- a/MobileGL/MG_Impl/Pipe/TextureEmit.h +++ b/MobileGL/MG_Impl/Pipe/TextureEmit.h @@ -1634,7 +1634,7 @@ namespace MobileGL::MG_Pipe { rectBoxes, rectCount, slab, pitch, m_regions.data(), m_regions.size()); m_regions.resize(pieceRegions); fillRecord(slab.Box, - reinterpret_cast(reinterpret_cast(shadow)) + + static_cast(reinterpret_cast(shadow)) + slab.RunOffset); const Bool pieceAccepted = emitRecord( static_cast(shadow) + slab.RunOffset, slab.RunBytes); diff --git a/MobileGL/MG_State/GLState/BufferState/PersistentMapTracker.cpp b/MobileGL/MG_State/GLState/BufferState/PersistentMapTracker.cpp index 62a276b3..8b97208c 100644 --- a/MobileGL/MG_State/GLState/BufferState/PersistentMapTracker.cpp +++ b/MobileGL/MG_State/GLState/BufferState/PersistentMapTracker.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -1012,7 +1013,7 @@ namespace MobileGL::MG_Record { for (SizeT wordIndex = 0; wordIndex < (tracked->pageCount + 63) / 64; ++wordIndex) { Uint64 word = tracked->pageBits[wordIndex].load(std::memory_order_relaxed); while (word != 0) { - const SizeT bit = static_cast(__builtin_ctzll(word)); + const SizeT bit = static_cast(std::countr_zero(word)); word &= word - 1; const SizeT pageIndex = (wordIndex << 6) + bit; // Clear the bit FIRST, per the order the correctness argument @@ -1026,7 +1027,7 @@ namespace MobileGL::MG_Record { std::memory_order_relaxed); SizeT runEnd = pageIndex + 1; while (word != 0) { - const SizeT nextBit = static_cast(__builtin_ctzll(word)); + const SizeT nextBit = static_cast(std::countr_zero(word)); if ((wordIndex << 6) + nextBit != runEnd) break; word &= word - 1; tracked->pageBits[wordIndex].fetch_and(~(1ull << nextBit),