Skip to content

PE loader: render_resolution below a mode rewrites every larger mode - #1

Open
adriadam10 wants to merge 1 commit into
MrCheese5:uw-c-render-resolutionfrom
adriadam10:render-res-below-mode
Open

adriadam10 wants to merge 1 commit into
MrCheese5:uw-c-render-resolutionfrom
adriadam10:render-res-below-mode

Conversation

@adriadam10

@adriadam10 adriadam10 commented Nov 25, 2026 •

Copy link
Copy Markdown

A fix for xcl-dev#735 at render sizes below 3840x2160, on top of 0c43a53; tested merged onto main 568e7db.

Tested

  • NVIDIA GeForce GTX 1050 Ti 4 GB (Pascal, driver 32.0.15.8266), Intel Core i5-8400, 16 GB RAM, Windows 11, Rust stable MSVC, release build
  • XCL_RENDER_RES=854x480, the retail title, 120 s smoke run

Problem
All three patches are applied (arena check … no longer breaks, 5 loads, largest display mode … is now 854x480), but the title then allocates its display targets at 2560x1440: it takes the largest mode in the table, and with only the last entry rewritten, 2560x1440 is now the largest. The same happens for any size below 2560x1440 (below 1920x1080, 1664x936, …).

Fix (one commit, 2dfece0; the same change as 6dc0d6a in adriadam10/xcl, where it was tested): patch also rewrites every mode larger than the render size on either side; sizes above 3840x2160 ("screen") change only the last entry as before. Unit test patch_below_a_mode_rewrites_every_larger_mode added; cargo test --release -p xcl --lib widescreen on that commit: 5 passed, 0 failed, 0 ignored. The run below was made before the commit, on the same file uncommitted (hence "uncommitted changes" in its block).

-        let e = i + 16 * (MODES.len() - 1);
-        data[e..e + 4].copy_from_slice(&size.0.to_le_bytes());
-        data[e + 4..e + 8].copy_from_slice(&size.1.to_le_bytes());
+        for (j, m) in MODES.iter().enumerate() {
+            if j == MODES.len() - 1 || m[0] > size.0 || m[1] > size.1 {
+                let e = i + 16 * j;
+                data[e..e + 4].copy_from_slice(&size.0.to_le_bytes());
+                data[e + 4..e + 8].copy_from_slice(&size.1.to_le_bytes());
+            }
+        }

With it, the display targets are 854x480 and the first frame is 854x480:

xcl-smoke v1
commit: 0bc67fe4de8e5799f037bf9480ab3ef624b0c59b (uncommitted changes)
gpu: NVIDIA GeForce GTX 1050 Ti
title: retail-480
seconds: 120
exit: 0x0
frames shown: 1085 (PresentX 1086)
presents per 2 s (last 3): 14 14 15
device removals: 0
crashes: 0
peak commit: 12142 MB

Peak commit falls from 15.0 GB (native) to 12.1 GB, and the loading screen runs at 16.8 fps instead of 6.8 — useful for testing on small GPUs.

Not tested: menus and UI layout at 854x480 (only the loading screen), sizes below 854x480, AMD.

AI use

  • Claude Code (Claude Opus 5.5) found the cause, wrote the fix and this description; the runs above are on the machine named under Tested.

The title takes the largest mode in its table: with only the 3840x2160 entry rewritten to 854x480,
it picked 2560x1440 instead. Every mode larger than the render size on either side becomes it too.

Co-Authored-By: Claude <noreply@anthropic.com>
@pickles976

pickles976 commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent CPU-only 1280x720 verification of 2dfece0b480d7d740b03ad810180efd0f6579a9a, compared with xcl-dev#735 at 0c43a53620aba918699412e4ba25c314b45a3b73.

Goal: verify the existing fix rather than propose a competing low-VRAM/title-specific patch. Host: Linux x86_64, Rust 1.96.0; title: retail Xbox 1.0.2.1. No game or GPU workload in this check.

Method: fetched widescreen.rs at each exact commit; compiled its unchanged pure helpers and upstream tests with native rustc --edition=2021 --test -O. Excluded only the Windows/config-dependent patch_image function. An additional test read the title executable without writing it, reconstructed individual PE sections in temporary memory (RVA, raw bytes, zero-filled virtual tail), and invoked patch, patch_slack_check, and patch_output_size on those section copies.

Observed at 1280x720:

Not verified: full-crate/loader integration, actual target allocation or presentation at 720p, UI layout, VRAM reduction, performance, or gameplay. No title bytes changed on disk. Our recent desktop-presented Wine trial caused a host GPU hang; therefore this evidence is deliberately offline, not a claim of a safe runtime configuration.

AI assistance: OpenAI coding assistant authored the verification harness and report; results above came from commands executed on this machine.

Additional bounded runtime check (Linux/Wine, RTX 4060 Laptop 8 GB)

Local integration of the resolution changes plus this follow-up; not the exact full PR stack. The only monitor adaptation is a primary-monitor query in place of xcl-dev#734's selected-monitor helper; requested XCL_RENDER_RES=1280x720, not screen. Our existing local build also carries sparse-mapping, Wine-vtable/guard, and GPU-source-staging integrations.

  • Full-crate focused widescreen::tests: 5 passed, release cross-build passed (Rust 1.98.1, x86_64-pc-windows-msvc).
  • Runtime patch log: table +0x615c0c0 -> 1280x720; arena check +0x247af2d; five output-size loads.
  • PresentX source frame dumps 1,3,...,63 are 1280x720, format 28. They are black startup frames, not UI/gameplay validation. Inspected a dump visually as well.
  • Xvfb isolated display; guard requested stop at 30 s. Wrapper including teardown lasted 47.18 s. Peak sampled before stop NVIDIA usage 4650 MiB; sampling ended at 29.68 s. This is not a full-run VRAM peak or a matched native-resolution performance comparison.
  • No new kernel journal entries over the trial; Wine/Xvfb exited and NVIDIA usage returned to 10 MiB. DXGI logged missing Xvfb EDID/display-metadata errors, so this is not an error-free run.

This establishes that the in-memory mode fix reaches 720p source presentation on this Wine integration. It does not establish correct nonblack rendering, UI layout, 30fps gameplay, long-run stability, or memory savings.

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