Surface storage and clipping

The title-to-attract path reaches a surface clip with H=02800000h (x=0,w=640)
and V=01430056h (y=86,h=323), format 128h, pitch 0A000A00h and color offset
A58000h. The origin changes the writable rectangle of the same framebuffer;
it does not identify a new allocation or move the framebuffer origin.

The native cache identifies surface storage by color/depth offsets, format and
pitch. A smaller clip reuses its storage. Draws snapshot the clip as a scissor.
Swizzled surface dimensions come from the format's width/height exponents.
Linear storage grows only if a new clip requires larger extents. Growth retains
color, depth and stencil through GPU copies; retired resources are released.
There is no CPU readback or allocation when only the clip changes.

The existing offline suite checks a full surface followed by an inset draw,
including preservation outside the clip, and checks retained color/depth/stencil
and initialized added capacity after growing a target. D3D11 debug validation
checks the native copy operations on both the hardware adapter and WARP.

Primary interfaces used to verify the implementation:
https://raw.githubusercontent.com/xemu-project/xemu/master/hw/xbox/nv2a/pgraph/gl/draw.c
https://raw.githubusercontent.com/xemu-project/xemu/master/hw/xbox/nv2a/pgraph/gl/surface.c
https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-copysubresourceregion

16-bit targets and texture aliases

Loading reaches format 07070213h, pitch 0A000100h, color offset 1160000h,
depth offset zero. Its color code 3 is RGB565, depth code 1 is Z16, layout 2
is swizzled, and both dimension exponents are 7 (128 by 128). The native backend
creates B5G6R5_UNORM color and D16_UNORM depth rather than treating the surface
as an ordinary 32-bit image. Readback expands the actual 16-bit colors. Target
growth preserves both formats and copies Z16 through R16_TYPELESS storage.
Stencil operations have no effect on the stencil-free depth format.

Texture binding checks matching surface offset, format, dimensions, layout and
linear pitch before uploading ordinary RAM textures. A matching surface uses
its current GPU view; CPU RAM does not contain its freshly rendered contents.
Surface growth refreshes that shared view. RGB565 presentation converts color
with one GPU draw using a shader prepared at target creation, without CPU reads.

140 offline cases pass on the RTX 5060 Ti and WARP with no D3D11 debug messages,
including RGB565/Z16 rendering, retained color/depth after growth, color
conversion and subsequent sampling of both 16-bit and 32-bit GPU surfaces.
This does not establish complete game graphics coverage or screenshot parity.

Surface/register corroboration (facts only):
https://raw.githubusercontent.com/xemu-project/xemu/master/hw/xbox/nv2a/nv2a_regs.h
https://learn.microsoft.com/en-us/windows/win32/api/d3d11/ne-d3d11-d3d11_format_support

The original SDK can issue repeated flips without new geometry. Each native flip
selects the current GPU color surface before presentation; the previous flip's
temporary main-target binding is not the next presentation source.

Diagnostic snapshots retain main, the last presented image, after any flip.
They do not promote an unfinished frame or offscreen pass during shutdown. A new
offline case presents a red frame, starts an unpresented 32x32 RGB565 pass, and
verifies that capture still returns the complete original 64x64 frame. The full
141-case suite passes on the RTX 5060 Ti and WARP without validation messages.

Issue 14: graphics storage lifetime (2026-10-12)

The report describes intermittent black sky and vehicle depth artifacts; its
Discord follow-up gives only an extended period of playtime, with no duration
or scene-change trigger. Source:
https://github.com/timftw21/burnout2-recompilation/issues/14

Two concrete cache faults were found. Ordinary textures were uploaded once and
cached by guest address/descriptor. Neither they nor GPU surfaces/reflection
copies were retired when their backing guest allocation was freed or decommitted.
Reusing an address could therefore display its former texture or GPU surface;
dead views also continued consuming the texture/target budgets and slots.
Separately, inactive image/pitch/palette registers created distinct keys for
identical supported textures. Swizzled image size/pitch comes from format, and
none of the supported formats uses a palette. Those inactive key fields are
now zero; linear textures retain their actual image dimensions and pitch.

Original-byte corroboration: the verified B5207C40 target's SDK resource destroy
routine at 002171D0 passes its Data field to MmFreeContiguousMemory at 0021723D
(FF15AC3C2900). Import 00293CAC contains AB000080, ordinal 171. Bounded native
analysis decoded 43 instructions through the return at 00217250. No runtime
CPU decoding or substituted game resource-release routine was added.

Native allocation release/decommit now invalidates overlapping cached graphics
storage before reuse. Texture payloads, color/depth extents and all cubemap faces
are covered, including high-address RAM aliases. Queued work is submitted first.
The renderer unbinds and releases the obsolete views/targets, subtracts their
budgets and reuses vacant resource slots; unrelated resources stay intact.
D3D11 context references and deferred resource destruction are documented at:
https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-pssetshaderresources
https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-flush

Both final hardware and WARP suites pass all 186 cases without D3D11 validation
messages. Focused cases exercise partial/aliased allocation replacement, former
render-target storage reused as an ordinary texture, depth storage release,
reflection-face replacement and inactive texture registers. A 5000-cycle check
creates/releases 2D textures, color/depth targets and cubemaps, checking that
live view counts and resource budgets return to baseline while another texture
remains usable. All 163 common PNG fixtures match the overnight build exactly.
CPU (21976 instruction, 579 memory, 6744 floating, 109 control cases), audio,
117 storage checks and the hidden-window diagnostic also pass.

An automated 601-second session on Ryzen 5 5600X / RTX 5060 Ti used Airport
Terminal 3, 3x resolution, widescreen, 180 Hz, interpolation on and V-sync off.
It reached the track-records screen and completed 36034 original frames without
a crash or reported audio/graphics boundary. Two F9 windows lasted 14.999 and
14.998 seconds. Between their final samples, targets stayed at 10, target budget
at 117227520 bytes and local GPU usage near 133 MiB (139354112 to 138948608).
Views changed from 218 to 225, source texture bytes by only 121152; private RAM
changed from 325132288 to 338251776 bytes. This session exercised the release
fix before the separate inactive-key normalization; final suites and the final
game benchmark also include key normalization. These are bounded observations,
not proof that every intermittent glitch in the report has been reproduced.

Final executable PE 6ACD0165, image 80429056 bytes: an automated 14.9998-second
Airport Terminal 3 benchmark at 240 Hz, 1x, widescreen, interpolation/V-sync off
measured 223.406 FPS, median 4.3646 ms, p99 5.7388 ms, max 7.4992 ms, no dropped
frames and unchanged benchmark settings. The active overnight PGO profile and
portable x64 compiler settings are retained. The actual executable's PE identity
matches the benchmark. Original user settings were restored byte for byte.
Reports/images/controller script are under build/checks/issue-14; raw game
captures remain beside the executable under build/captures. No stress/build
workers remain. The specific reported sky/vehicle glitch still needs confirmation
on the reporter's machine or a reproducible longer-play sequence.
