Skip to content

HLE/Bink: neutralize skipped movie frame buffers to YUV black - #3245

Open
Saksukella wants to merge 1 commit into
xcl-dev:mainfrom
Saksukella:fix/bink-skip-yuv-black
Open

Saksukella wants to merge 1 commit into
xcl-dev:mainfrom
Saksukella:fix/bink-skip-yuv-black

Conversation

@Saksukella

Copy link
Copy Markdown
Contributor

When XCL_SKIP_BINK skips a Bink 2 movie (BinkNextFrame / BinkDoFrame* fast-advanced), the title's YUV plane buffers remain zero-filled (Y=0x00, cR=0x00, cB=0x00). Because YUV (0, 0, 0) converts to bright green (0xff008700) in the title's YUV-to-RGB shader, skipped cutscenes and logos flash or hold a solid green frame instead of black. This change tracks registered Bink frame buffers while XCL_SKIP_BINK is active and fills skipped planes to neutral YUV black (Y=0x00, cR=0x80, cB=0x80, A=0xFF, H=0x00).

What is in it

  • crates/xcl/src/hle/bink.rs:
    • Hook BinkRegisterFrameBuffers and BinkAllocateFrameBuffers when XCL_SKIP_BINK is enabled, tracking opened handles and registered BINKFRAMEBUFFERS descriptors and cleaning up on BinkClose.
    • Validate every plane pointer, pitch, and height (VirtualQuery writable check on Windows + 64 MiB cap) before filling skipped movie planes to neutral YUV black (Y=0x00, cR=0x80, cB=0x80, A=0xFF, H=0x00).
    • Add pure-CPU unit tests for BINKFRAMEBUFFERS ABI offsets (bink_frame_buffers_abi_offsets) and plane neutralization / null-plane handling (neutralize_frame_buffers_fills_yuv_black_and_skips_null_planes).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 9 7900X, 32 GB RAM, Windows 11 Pro (build 26200), rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test --lib -p xcl hle::bink -- --test-threads=4: 6 passed, 0 failed, 0 ignored (0.01s).
  • cargo check --workspace: passed.

Regression run

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17279 MB
xcl-smoke v1
commit: ae474ad1d7b2736fcea85bce04db3369e29c8c10
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1684 (PresentX 1684)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16238 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).
  • Full cargo test --workspace run (targeted hle::bink suite + cargo check --workspace + 60s TitleID 7952987A smoke run were executed).
  • Non-Windows hosts (XCL builds and runs on Windows only).

AI use

  • Assisted with Bink ABI offset verification, unit test authoring, and rebase verification; all diffs, tests, and hardware smoke runs were verified locally.

@github-actions github-actions Bot added the area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH label Nov 28, 2026
raylitebull added a commit that referenced this pull request Nov 29, 2026
…ppear immediately

GitHub search `status:success` lags on newly opened PRs (dropping PRs
like #3247/#3245/#3237 even when all required CheckRuns are green).
Scan non-draft PRs without `status:success` (moving `mergeable` to Stage B
for speed) and filter directly on live CheckRuns. Also sort newer PRs
first within each priority bucket.

Assisted-by: Antigravity (Gemini 4 Neon)
@Foniass

Foniass commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Review (diff read, not a merge-check):

  • Unversioned pointer read, then large fills. When no registration was seen, the fallback reads a pointer at handle + 0xB0. That offset is taken from one build of the Bink DLL, and nothing checks the version: is_bink_dll matches any bink2*.dll. It then fills up to 64 MiB per plane after loose checks only (pages writable, no cross-check against the handle's width/height). On another Bink build this is silent memory corruption in the title.
  • &*fb on a possibly unaligned pointer is UB.
  • The ABI test compares the Rust struct only with itself.
  • Only hle::bink tests were run, and the smoke run does not set XCL_SKIP_BINK, so the changed path never ran.
  • AI use names no model, and the Bink struct layouts have no provenance note.

Suggested verdict: not yet (drop the fallback or gate it on a known DLL version).

(Review written with Claude Code, Claude Opus 5.5; the first point was traced in the code.)

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head ae474ad

No other PR to main makes this change. The same problem is solved in a different way by commit f0255ae on amd-dev (in the open branch merge #3547). That commit also wraps BinkRegisterFrameBuffers, but it uses 3 plane sets at +0x18, limited-range black (Y 16, cR/cB 128), alpha 0, leaves H alone, and has an XCL_SKIP_BINK_BLACK=0 switch.
Things to check in bink.rs: BinkFrameBuffers::frames has 2 entries and neutralize_frame_buffers clamps total_frames to 2. If the DLL's struct really has three sets, the third is never painted. The fallback in neutralize_registered_for reads a frame-buffers pointer at HBINK+0xB0, and nothing in the diff shows that offset was verified.
Whichever version lands first, the other should be reconciled with it.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants