Skip to content

fix(shroud): Stop the shroud upload from exhausting memory on device reset - #632

Open
tintinhamans wants to merge 2 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/shroud-upload-reset-memory
Open

tintinhamans wants to merge 2 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/shroud-upload-reset-memory

Conversation

@tintinhamans

Copy link
Copy Markdown

The shroud was uploaded to the GPU with CopyRects on every frame. On NVIDIA the driver keeps a little memory for each of those calls and only allocates it when the device is reset. After a long match a single reset (lock screen, UAC prompt, alt-tab in fullscreen) allocates hundreds of MB in one go, and the 32-bit process runs out of address space. Reset then fails with out of memory, which is where crashes like CLIENT-55X come from.

The shroud now lives in a plain buffer, m_shroudData, and is copied into a managed texture through a lock. CopyRects, the system-memory surface it copied from and the pitch member are gone. This is the same change as upstream TheSuperHackers#3440 (issue TheSuperHackers#3439), and the same design BFME ended up with.

Measured on the upstream build, same skirmish at 120 fps for 10 minutes and then a forced device reset: main lost 316 MB of address space in that one reset, with this change it lost nothing. The upload is also cheaper, W3DShroud::render went from 0.032 ms to 0.006 ms per frame. On our own test setup an earlier version of this fix went through a 20 minute match and a screen lock without losing memory.

The second commit fixes the m_finalFogData fill in fillShroudData, which advanced the wrong pointer and only filled the first row. That code is behind DO_FOG_INTERPOLATION, so nothing changes in current builds.

Both GeneralsMD and Generals are changed. Zero Hour builds here; the Generals half could not be compiled in this tree, it is the same code that builds upstream.

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/shroud-upload-reset-memory branch from d5fe570 to cb9956c Compare October 8, 2026 23:05
@elopezgomez567-stack

Copy link
Copy Markdown

git init
git add .
git commit -m "Initial commit"
git push origin main

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/shroud-upload-reset-memory branch from cb9956c to 8744d24 Compare October 9, 2026 21:31
#include "WW3D2/camera.h"
#include "WWLib/simplevec.h"
#include "WW3D2/dx8wrapper.h"
#include "WWMath/vector2i.h"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enter_pairing_code.png

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/shroud-upload-reset-memory branch from 8744d24 to 95170bb Compare October 10, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants