From fc84c3cd6c5443b2fc508ed85b1e5cbe3890fcba Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Sat, 2 May 2026 17:59:15 -0700 Subject: [PATCH] Fixed crash in release build. --- neo/doomdll.vcxproj | 1 + neo/doomdll.vcxproj.user | 1 + neo/game.vcxproj | 1 + neo/opengl/gl_d3d12shim.cpp | 25 +++++++++++++++++++++++-- neo/opengl/opengl.vcxproj | 2 +- neo/renderer/Image_init.cpp | 15 +++++++++------ 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/neo/doomdll.vcxproj b/neo/doomdll.vcxproj index 5ffbc59d..26e18ec1 100644 --- a/neo/doomdll.vcxproj +++ b/neo/doomdll.vcxproj @@ -248,6 +248,7 @@ openal\lib;sys\win32\dongle;%(AdditionalLibraryDirectories) ../Doom3.exe d3d12.lib;nafxcw.lib;libcmt.lib;%(AdditionalDependencies) + true Use diff --git a/neo/doomdll.vcxproj.user b/neo/doomdll.vcxproj.user index aee7e7f9..d06734bf 100644 --- a/neo/doomdll.vcxproj.user +++ b/neo/doomdll.vcxproj.user @@ -42,5 +42,6 @@ WindowsLocalDebugger +set r_fullscreen 0 +set r_mode 6 D:\projects\Doom3 + +set r_fullscreen 0 +set r_mode 6| \ No newline at end of file diff --git a/neo/game.vcxproj b/neo/game.vcxproj index 166f3754..569583fa 100644 --- a/neo/game.vcxproj +++ b/neo/game.vcxproj @@ -253,6 +253,7 @@ ../gamex64.dll + true Use diff --git a/neo/opengl/gl_d3d12shim.cpp b/neo/opengl/gl_d3d12shim.cpp index 348218fe..69bdb864 100644 --- a/neo/opengl/gl_d3d12shim.cpp +++ b/neo/opengl/gl_d3d12shim.cpp @@ -9567,8 +9567,29 @@ static std::unordered_map g_qd3d12Pbuffers; static void QD3D12_RegisterWindowDC(QD3D12Window* w) { - if (w && w->hdc) - g_qd3d12DcToWindow[w->hdc] = w; + if (w == NULL) { + return; + } + + const HDC hdc = w->hdc; + if (hdc == NULL) { + return; + } + + // If the HDC is already registered, only update the pointer. + // This avoids insert/rehash for the common case. + std::unordered_map::iterator it = g_qd3d12DcToWindow.find(hdc); + if (it != g_qd3d12DcToWindow.end()) { + it->second = w; + return; + } + + // Avoid tiny-map rehash behavior in release builds. + if (g_qd3d12DcToWindow.bucket_count() < 256) { + g_qd3d12DcToWindow.reserve(256); + } + + g_qd3d12DcToWindow.emplace(hdc, w); } static void QD3D12_UnregisterWindowDC(HDC dc) diff --git a/neo/opengl/opengl.vcxproj b/neo/opengl/opengl.vcxproj index 8c4a5305..5e8e6e5c 100644 --- a/neo/opengl/opengl.vcxproj +++ b/neo/opengl/opengl.vcxproj @@ -232,7 +232,7 @@ MultiThreaded streamline/include 4996 - AdvancedVectorExtensions102 + StreamingSIMDExtensions2 diff --git a/neo/renderer/Image_init.cpp b/neo/renderer/Image_init.cpp index e2fc6aa8..dd97657c 100644 --- a/neo/renderer/Image_init.cpp +++ b/neo/renderer/Image_init.cpp @@ -1618,13 +1618,16 @@ idImage *idImageManager::ImageFromFile( const char *_name, textureFilter_t filte } - if (depth == TD_BUMP) + if (image->texnum != idImage::TEXTURE_NOT_LOADED) { - glTextureNormalMap(image->texnum, true); - } - else - { - glTextureNormalMap(image->texnum, false); + if (depth == TD_BUMP) + { + glTextureNormalMap(image->texnum, true); + } + else + { + glTextureNormalMap(image->texnum, false); + } } return image;