Skip to content

Preserve D3D9 state lifetimes and add staged performance diagnostics - #1

Merged
prematurely merged 2 commits into
mainfrom
codex/renderstack-candidate-20261109
Nov 9, 2026
Merged

prematurely merged 2 commits into
mainfrom
codex/renderstack-candidate-20261109

Conversation

@prematurely

@prematurely prematurely commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Repeated D3D9 state restoration and texture-source mapping reclamation add CPU work and require precise resource lifetimes. This candidate preserves those lifetimes, reduces redundant state/submission work, and provides staged F7/F8 diagnostics with HUD, main-thread/CS attribution and exact-binary symbol sidecars.

Included:

  • State-block/journal restoration, constant first-write capture/submission, binding ownership, x86 Fading entry and Bridge lifecycle fixes.
  • Unified measurement, CPU/CS activity statistics and streaming-configuration preparation.
  • Upload-source mapping reuse and cheap rechecks of unchanged patch-signature rejection.
  • Native behavior regressions, paired A/B and A/A evidence, and validation records.

Validation:

  • Windows CI passed: clean Release x86 build, 39 passed / 0 failed / 45 existing skips, packaging, package layout and all artifact uploads.
  • The tested PR merge commit is 6dd8c85a044d1236d7cebeccc586fb879b6f926b; its Git tree was verified identical to head 491f8aa4934914a94746901115aa557ce5ccd354.
  • Split/SDK/symbol ZIPs and source manifest were downloaded and checked. Both DLL SHA-256 values match their packaged RSYM sidecars.
  • The first cloud run built successfully but failed two fixture setups. Standalone streaming and symbol probes unnecessarily discovered Ninja/glslang. The follow-up resolves only the tools used, retaining all assertions. Red/green reproduction with unavailable Ninja/glslang paths passed 14 native decision checks, 120 consumer/preparation/replay assertions and 27 symbol tests.
  • Fresh complete local pipeline with GPU probes enabled: 81 passed / 0 failed / 3 skipped. The three skips are an already-current build and two external source audits without supplied inputs. This diagnostic process used logical CPU 0 and a repository-local TEMP/TMP directory; neither the game nor system settings were changed.
  • Earlier local failures are retained: ordinary environment 77 passed / 5 compiler failures / 2 skips, then CPU-0-only diagnosis 69 passed / 13 temporary-file/fixture-creation failures / 2 skips. Isolated success does not establish the root cause or normal-host stability.
  • Hosted CI retains its existing GPU/environment-sensitive skips and does not replace local GPU behavior coverage. Diagnostic affinity results are not performance benchmarks.

Performance limits: pressured mip-chain uploads reduced CPU cycles about 7%, and failed-patch polling reduced CPU work in the recorded experiments. Single-mip and empty-Present wall-time regressions are included. Whole-Present throughput and a controlled fixed-route GTA FPS/first-exit improvement remain unproven; these limits are retained after manual functional acceptance.

See candidate status, measurement report and paired evidence.

Vulkan staging/copy behavior and public interfaces are retained. No new batching/multicore implementation is included.

Game acceptance (2026-11-09):

  • The exact DLLs and matching symbols from PR CI run 42545794212, attempt 2 were backed up and deployed. Installed hashes, captured binary fingerprints and RSYM sidecars match; the existing game/Proper Shaders configuration was retained.
  • Predeployment checks on these exact CI binaries passed five lifecycle cases and 1,569 texture-upload checks. The user then confirmed normal loading, movement and visuals, and described first-exit stutter as reduced only slightly.
  • The completed F8 capture contains 2,922 frame intervals and 1,852 CPU samples, with no dropped frames/samples or failed Presents. Peak interval remains 139.87 ms, near the camera jump about two seconds after InteriorChange; 17 of 26 peak-frame samples include packImageData in a structural caller chain.
  • The last three seconds of CPU sampling measured 53.14 FPS and P95 28.81 ms. The outdoor attribution window measured main-thread CPU 93.61%, CS CPU 19.14%, and CS queue idle 79.27%. Instrumentation and recorded focus loss prevent treating these numbers as a controlled A/B improvement. The previous capture's 107.56 ms peak and 67.23 FPS tail are retained as observations, not a causal version comparison.
  • Repeated DayVector signature rejection logs fell from 2,500 during the earlier capture to zero during this capture (one rejection during startup). Existing shader constant-index and render-state warnings also appear in the old-version logs.
  • Manual functional acceptance is complete and the user has authorized merging after a qualified game test. Significant first-exit stalls, generic redundant state traffic, and quantified performance acceptance remain follow-up work; this merge does not claim those issues are solved.

Post-merge verification:

  • Squash merged as 659f9ed60084f16dba98bb4cd396edeca2ab17cc; main and the game-tested candidate have identical Git tree 9a3da2adf8dbc70f72462271967646cd647f97f0.
  • Main Windows CI passed: 39 passed / 0 failed / 45 existing skips, with successful Release x86 build, packaging, package-layout verification and artifact uploads. Counts were read from the downloaded test-results.json for this exact merge commit.
  • The game retains the already-tested PR CI attempt 2 binaries; the post-merge build was not redeployed.

…stics

Publish the current candidate with native behavior regressions, source mapping reuse, bounded patch-rejection retries and paired measurement evidence. Keep end-to-end performance caveats and current local compiler failures explicit.
@prematurely
prematurely marked this pull request as ready for review November 9, 2026 02:40
Copilot AI balanced review requested due to automatic review settings November 9, 2026 02:40
@prematurely
prematurely merged commit 659f9ed into main Nov 9, 2026
2 of 3 checks passed

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 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-11-09T02:48:37.175752Z 491f8aa Draft marked ready
🔒 Security Review ✅ Completed 2026-11-09T02:46:04.671365Z 491f8aa Draft marked ready
ℹ️ 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: 491f8aa493

ℹ️ 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".

Comment on lines +749 to +754
std::lock_guard<std::recursive_mutex> lock(m_bridgeObserverMutex);
const auto observer = m_bridgeObserver;
if (event == D3D9BridgeEvent::FinalRelease)
m_bridgeObserver = {};
if (observer.Notify)
observer.Notify(observer.Context, this, event, result, params, present);

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 Keep lifecycle callbacks in a consistent device-lock order

For a multithreaded device, an overlapping Reset and Present can deadlock during measurement. Reset acquires LockDevice() before calling NotifyBridge, whereas PresentEx calls NotifyBridge(PresentAfter) without that lock. The Present callback holds m_bridgeObserverMutex while OnUnwrappedDeviceEvent calls RuntimePresent, whose attribution/HUD path calls GetAudit() and acquires the device lock. If Reset acquires the device lock first, it waits for the observer mutex while Present waits for the device lock, permanently blocking both threads. Serialize these lifecycle notifications with a consistent lock order rather than invoking device-lock-taking callbacks under the observer mutex in the opposite order.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Implemented in follow-up PR #2, commit f6876b2f. Both SetObserver and NotifyBridge now acquire the recursive device lock before the observer lock. Notification stays synchronous, including unregister and final release.

The native regression runs Reset on the device-creation thread while a second thread Presents, then reenters the real GetAudit from the callback. The pre-fix DLL deadlocks and exits through the watchdog with code 86; the fixed DLL passes 33 checks, including concurrent unregister and absence of later callbacks. Existing final-release audit coverage and the 82-check native runtime suite also pass.

The complete local pipeline passed 85/85 required/executed checks, with zero failures and only the two missing-external-input audit skips. Detailed regression evidence. The follow-up PR is open and not merged.

Comment on lines +754 to +756
if (!g_owner) g_owner = GetCurrentThreadId();
g_controller.SetAvailable(g_config.cpu, g_config.journal || g_diagnostics != nullptr);
if (g_device != device || g_owner != GetCurrentThreadId()) return;

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 Validate the capture device before assigning its owner thread

If a secondary device presents on another thread before the selected device's first Present, this assigns the secondary thread to g_owner before rejecting its device. RuntimePrepareDevice retains the first registered device, and OnUnwrappedDeviceEvent forwards Presents from every registered device, so this ordering is reachable with multiple devices. All subsequent Presents from the selected device's actual render thread then fail the owner check, leaving its measurement HUD and F7/F8 capture permanently inactive until that device is released. Reject non-selected devices before initializing g_owner.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Implemented in follow-up PR #2, commit f6876b2f. The g_device != device guard now runs before owner assignment, capture-state advancement and key consumption.

The regression prepares a real selected HAL device, then Presents a second real device from another thread first with F8 held. The old runtime fails to start the selected device's capture. The fix passes all 8 focused checks: the secondary device does not consume F8 or start workers, and the selected render thread completes the capture with actual CPU samples. The complete native runtime suite passes 82 checks; full local validation is 85 passed / 0 failed / 2 missing-external-input skips.

Regression and validation report. The follow-up PR is open and not merged.

RuntimeCpuModule module;
module.base = reinterpret_cast<std::uintptr_t>(entry.modBaseAddr);
module.size = entry.modBaseSize;
module.path = entry.szExePath;

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 Convert enumerated module paths to UTF-8 before resolving symbols

When the game is installed under a non-ASCII path on a Windows system using a non-UTF-8 ANSI code page, this stores ANSI bytes in module.path: the Bridge project uses CharacterSet=MultiByte, so MODULEENTRY32 and Module32First select the ANSI API. ResolveCpu subsequently passes that string to MeasurementSymbolResolver::LoadModule, which interprets it with std::filesystem::u8path. For example, a CP1252 path containing é cannot be decoded as UTF-8, so loading the Bridge/backend DLL and its valid .rsym fails and the capture loses its function-level attribution. Enumerate with the wide APIs and explicitly encode the resulting path as UTF-8.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Implemented in follow-up PR #2, commit f6876b2f. Module collection now uses MODULEENTRY32W, Module32FirstW and Module32NextW, followed by explicit UTF-16 → UTF-8 conversion.

The native regression runs under Windows ACP 936 and loads an actual backend DLL plus its matching RSYM from a path containing Chinese characters, é and Ω. It checks the captured report path, validates the sidecar against that DLL and resolves the real Direct3DCreate9 address. The old enumerator fails the lossless-path assertion; the fixed runtime passes all 9 focused checks. Full local validation is 85 passed / 0 failed / 2 missing-external-input skips.

Regression and validation report. The follow-up PR is open and not merged.

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