Skip to content

fix(cs2): shader OOM guards, swapchain teardown, stuck scrub, ReShade add-on, 1.42.0.1 shadow sigs - #215

Merged
Wockstajit merged 1 commit into
mainfrom
fix/discord-crash-scrub-reshade-fixes
Dec 2, 2026
Merged

Wockstajit merged 1 commit into
mainfrom
fix/discord-crash-scrub-reshade-fixes

Conversation

@Wockstajit

Copy link
Copy Markdown
Owner

Summary

Fixes the unfixed bugs and crashes triaged from recent Discord reports, repairs the ReShade add-on launch path so ReShade effects appear in renders, and incorporates the verified CS2 1.42.0.1 \scenesystem.dll\ shadow signatures from #213 (credit @SpasaevDonut).

  • Stuck demo-bar scrub drag: added a drag-only release watchdog in \DemoBarScrubJs.h\ and C++ \VK_LBUTTON\ auto-release in \DemoScrub.cpp\ / \DemoScrubMath.h\ so a missed Panorama \SliderReleased\ event cannot hijack pause/seeks.
  • Shader derivation OOM aborts, 512 MiB RAM retention, and shutdown hangs: added RAII guards and \std::bad_alloc\ / ...\ catches across \EnvironmentNativeMaterialDerive.cpp, \SmokeAppearance.cpp, and \RenderSystemDX11Hooks.cpp; capped derivation worker concurrency and added commit-headroom backoff; gated the 512 MiB DXBC dump cache behind \mvm_debug; bounds-checked DXBC instruction lengths in \SmokeAppearanceMath.h; added \ShutdownNativeMaterialDerivation()\ called from \Filmmaker::Shutdown().
  • Dangling swapchain teardown crash: detoured \IDXGISwapChain::Release\ in \RenderSystemDX11Hooks.cpp\ to clear \g_pSwapChain\ when its final ref drops.
  • ReShade add-on missing in renders: updated \dlss-tool.cjs\ and \ReShade.isolated.ini\ so \prepareLaunch()\ upgrades stale/non-addon \d3d11.dll\ from the bundled ReShade 6.8.0, removes any stray ReShade \dxgi.dll\ proxy in the private bin, ensures [ADDON] AddonPath\ keeps .\, and re-enables \mvm_reshade_state.addon64\ if listed in [ADDON] DisabledAddons.
  • CS2 1.42.0.1 \scenesystem.dll\ shadow signatures: updated \kShadowBuildParentPattern\ in \LightFx.cpp, \kCopySstBuilderPattern\ in \ShadowStageProbe.cpp, and \Automation/verify/cs2-build-stamp.txt\ (ClientVersion 2000951).

Related issue

Closes #214
Incorporates #213

Scope and affected areas

  • CS2
  • Deadlock
  • Launcher
  • Website
  • Build or automation
  • Docs only

Verification

  • Relevant automated tests passed (\DemoScrubMathTests, \EnvironmentNativeMaterialTests, \SmokeAppearanceTests, \BugReport|CrashReport|Demo|VpScale\ 13/13, \EnvironmentNative|Smoke|Relight\ 15/15, JS suites \launcher-dlss-ini, \dlss-local-installer, \launch-optional-dlss, \pause-toggle, \shadow-separation, \documentation-integrity)
  • Build passed (\AfxHookSource2\ \x64-source2-release\ Release)
  • Signature verification passed (\�erify-cs2-signatures.py\ 109/109 match, 0 broken, 0 wrong-module on CS2 \ClientVersion=2000951\ / \1.42.0.1)
  • Security, licenses, secrets, and asset rights reviewed (\check-repo-policy.mjs --scan\ and --changed: no findings)

AI assistance

  • AI-assisted: Yes (bug triage, code edits, tests, verification)
  • Responsible contributor: @Wockstajit

Risks and limitations

  • Live CS2 verification of the 0.4.3 release build follows on the
    elease/0.4\ backport branch before publishing \�0.4.3.

Deployment status

Not released (targeting \�0.4.3\ via
elease/0.4)

… add-on, 1.42.0.1 shadow sigs

Fixes recent Discord bug/crash reports and incorporates #213 (credit @SpasaevDonut):

- DemoBarScrubJs, DemoScrub, DemoScrubMath: recover from missed Panorama SliderReleased events so a stuck scrub drag cannot hijack pause/seeks.
- EnvironmentNativeMaterialDerive, SmokeAppearance, SmokeAppearanceMath, RenderSystemDX11Hooks, Filmmaker: guard shader derivation/creation hooks against std::bad_alloc aborts, cap derivation worker concurrency and wait on commit headroom, gate the 512 MiB shader dump cache behind mvm_debug, bounds-check DXBC instruction lengths, and drain workers on shutdown.
- RenderSystemDX11Hooks: detour IDXGISwapChain::Release to clear g_pSwapChain before teardown instead of dangling in AfxViewportScaler::TrackBreaks.
- dlss-tool.cjs, ReShade.isolated.ini: refresh stale/non-addon d3d11.dll from bundled ReShade, remove stray ReShade dxgi.dll in the private bin, keep .\ in [ADDON] AddonPath, and un-disable mvm_reshade_state.addon64 in [ADDON] DisabledAddons so ReShade effects appear in renders.
- LightFx.cpp, ShadowStageProbe.cpp, cs2-build-stamp.txt: update scenesystem.dll shadow signatures for CS2 1.42.0.1 (ClientVersion 2000951), from #213.

Closes #214
@Wockstajit Wockstajit added type: fix Correct existing behaviour area: cs2 CS2 hook and filmmaker features in AfxHookSource2 area: panorama In-game Panorama panels and ui-mockup area: launcher SourceMovieMakerLauncher host, app and packaging labels Dec 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T03:17:21.171767Z 4a4d3cc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a4d3cc8a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

WindowResize_Shutdown(); // destroys the resize readout window before the DLL goes away
SceneKeys_Flush();
Environment::FlushCommittedEdits();
Environment::ShutdownNativeMaterialDerivation();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invoke derivation shutdown from the client teardown hook

On normal CS2 quit, this call is never reached: a repo-wide search finds no caller of Filmmaker::Shutdown(), while the actual new_CCS2_Client_Shutdown hook in AfxHookSource2/main.cpp shuts down the render-system engine and calls the original client shutdown without invoking it. The derivation queue therefore never gets its stop signal, so detached workers and queued shader references can remain active while shutdown proceeds; invoke this cleanup from the reached teardown path.

Useful? React with 👍 / 👎.

Comment on lines +263 to +264
if(!queue.started){queue.started=true;
for(unsigned i=0;i<DerivationWorkers();++i)std::thread(DerivationWorker).detach();}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry worker startup if thread creation fails

If creation of the first worker throws, for example because the OS cannot allocate another thread, queue.started is already true and the surrounding catch(...) suppresses the exception. No worker drains queue.jobs, and later enqueues skip the startup block, leaving shader references and bytecode queued with no derivations for the rest of the session. Roll back started or set it only after a worker starts; QueueScaledColorVariant uses the same startup ordering.

Useful? React with 👍 / 👎.

static std::mutex lock;std::lock_guard<std::mutex> guard(lock);
// Development aid: keep the bytecode of every clustered-light program only while mvm_debug is
// recording, so normal sessions never hold up to 512 MiB of raw DXBC in RAM for dumpprograms.
if(info.lightSlot&&MvmDebugLog_Active()){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the documented shader-dump workflow

When mirv_relight dumpprograms is run on an already-loaded map without mvm_debug having been active when its material shaders were derived, this condition has prevented their bytecode from being recorded. The dump command only serializes the existing record (the separate cluster cache contributes at most two compute kernels), so ValidateNativeVariants receives no light-material programs and reports zero variants; there is no path to recover their bytecode without recompiling the shaders. Make the required capture timing explicit and ensure the documented loaded-map workflow can populate the dump or fail clearly.

Useful? React with 👍 / 👎.

Log("auto-release stuck drag at %.3f (sawDown=%d upFrames=%d)", g_target, g_dragSawMouseDown ? 1 : 0, g_dragMouseUpFrames);
g_released = true;
g_reaims = 0;
if (TimelinePlayhead_Scrubbing()) TimelinePlayhead_EndScrub();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Finalize the camera-path owner on automatic scrub release

When a camera-timeline drag loses its SliderReleased event, CameraPath::ScrubToTick(..., false) has left m_play.Scrubbing() set and m_scrubReleasePending false. This fallback ends only TimelinePlayhead, so CameraPath::RunFrame() keeps calling TickScrub and writing the last preview pose every frame even after DemoScrub becomes inactive; release the camera-path owner too so the recovery actually unpins the view.

Useful? React with 👍 / 👎.

@Wockstajit
Wockstajit merged commit 53d8713 into main Dec 2, 2026
9 checks passed
@Wockstajit
Wockstajit deleted the fix/discord-crash-scrub-reshade-fixes branch December 2, 2026 03:27
Wockstajit added a commit that referenced this pull request Dec 2, 2026
…gnatures (#216)

Maintenance release 0.4.3 on release/0.4 (bug fixes only, no 1.0 features):

- Backports #198 (DeathMsg signatures for CS2 1.42) and #192 (SkyOrient entity class check).
- Incorporates #213 (scenesystem.dll shadow signatures for CS2 1.42.0.1, credit @SpasaevDonut).
- Backports #215: stuck demo-bar scrub drag recovery, shader derivation/hook std::bad_alloc guards, worker concurrency cap and commit-headroom backoff, mvm_debug gate on the 512 MiB shader dump cache, DXBC length bounds checks, clean worker shutdown, IDXGISwapChain::Release hook, and ReShade add-on launch repair (refreshing bundled ReShade d3d11.dll, clearing stray ReShade dxgi.dll, keeping .\ in [ADDON] AddonPath, and un-disabling mvm_reshade_state.addon64).
- Bumps launcher version to 0.4.3 and adds the 0.4.3 section to CHANGELOG.md (What's New).

Refs #214
Wockstajit added a commit that referenced this pull request Dec 2, 2026
…es (#218)

Credits @SpasaevDonut for the CS2 1.42.0.1 scenesystem.dll shadow signature updates from #213 (incorporated in #215 and shipped in v0.4.3).

Co-authored-by: SpasaevDonut <246049908+SpasaevDonut@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cs2 CS2 hook and filmmaker features in AfxHookSource2 area: launcher SourceMovieMakerLauncher host, app and packaging area: panorama In-game Panorama panels and ui-mockup type: fix Correct existing behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix recent CS2 crashes, stuck demo scrub, ReShade render add-on, and 1.42.0.1 shadow signatures

1 participant