Skip to content

GPU: VICTORY_TEXTURE_DROP_MIPS=N leaves out a texture's N largest levels on the host (8 GB cards) - #610

Open
ofc0urse wants to merge 5 commits into
fxceless:mainfrom
ofc0urse:gpu/texture-drop-mips
Open

ofc0urse wants to merge 5 commits into
fxceless:mainfrom
ofc0urse:gpu/texture-drop-mips

Conversation

@ofc0urse

Copy link
Copy Markdown

Problem

On an 8 GB card the textures picked by index do not fit. With the current main, the card sits at its memory budget (about 6.8 GB in use of 7.1 GB), about 15,000 textures stay waiting for room, and frames that pass the budget get slow: the GPU time per frame triples once the system starts moving card memory into the PC's.

Change

VICTORY_TEXTURE_DROP_MIPS=N (0 by default, at most 4): the host copy of a 2D texture the title fills leaves out its N largest levels. Each level left out is three quarters of the texture's bytes.

Only textures where this is exact: 2D (arrays and cubes too), no render target, depth or UAV flag, single sample, at least 512 texels on the shorter side, and sides that halve into whole 4-texel blocks. Host level m is then title level m + N texel for texel.

  • resource.rs: drop_levels decides per description; host_texture makes the smaller copy; host_subresource maps a title subresource to the host one.
  • texture.rs: the staging buffer is laid out from the host texture as before, and detiles title level m + drop into host level m.
  • descriptor/host.rs: shader views shift their first level, level count and LOD clamp down by the same amount (shift_levels, with a unit test). A view of only the left-out levels shows the largest level the host has.
  • list.rs: a buffer-to-texture copy into such a texture goes to the level it has (none for a left-out level). Other copies and read-backs involving such a texture are skipped, logged once.
  • texture::alias falls back to the title-memory upload when the two textures leave out different levels.
  • README: one line under "Speed and memory".

Shaders see these textures at half size per level left out. Code that samples is unaffected apart from detail. Code that Loads with integer coordinates computed from the title's own sizes can read out of range. I have not seen that in the first room.

Measurements

RTX 4060 Ti 8 GB (driver 621.24), i5-14400F, 32 GB RAM, Windows 11, Series X profile, diagnostics build. Main c96b4f2 with #426 and #571 on top, default settings, VICTORY_TEXTURE_NO_WAIT=1, warm shader cache, same automated walk into the first room, 15 to 17 minutes each:

DROP_MIPS=0 DROP_MIPS=1
ms/frame, minutes 9 to 12 424-437 209-230
GPU ms/frame 226-247 82-89
textures picked by index uploaded 32,515 44,550
still waiting ~15,000 ~6,000
title-filled host copies alive 13,416 (2,889 MB) 15,191 (2,182 MB)
card in use / budget 6,788 / 7,104 MB 6,680 / 7,181 MB

Captured frames of the first room look right in both. With the switch, fine texture detail is softer (expected), and there is visibly less temporal smearing, from the shorter frames.

cargo build (diag and release) clean, cargo test -p victory-gpu views_shift_down passes. Not tested: other cards, other scenes, AMD, Wine.

Developed with Claude Code.

🤖 Generated with Claude Code

@Filip722

Filip722 commented Nov 25, 2026 •

Copy link
Copy Markdown

I reproduced a texture-to-buffer copy failure on this PR at 5971e08. With a retained mip on the second array slice, dropping one level left the destination untouched. The same copy succeeded with zero levels dropped.

81e1f7a is a cherry-pickable fix on this PR's head. It maps the retained source subresource before creating a host texture. The new D3D12 test checks the pixels, crop, row pitch, destination offset and surrounding bytes. It passes with both settings on Bazzite 44, RTX 5060 Laptop GPU (8 GB), NVIDIA 615.78.08, Proton Experimental 11.0-20261112 and vkd3d-proton 3.2.0. The wider resource suite passed 10/11 on both revisions with dropping disabled. The same depth-plane test failed during root signature creation on both.

This result uses generated textures. Gameplay impact remains unverified. Code and testing assisted by OpenAI Codex (GPT-6.2-Sol).

I also compared the setting itself during offline Series X loading, using one build of fork main 310c6eb with this PR and local Proton compatibility changes. Both runs used the same cache/profile seed, input, CPU cap and 50% texture-room setting. Around 90 seconds the renderer counted 7,510 title-filled textures using 2,342 MiB at zero levels dropped, versus 7,403 using 1,343 MiB with one dropped. Around two minutes it held 7,531 versus 15,388. Both showed loading artwork and a fade to black. The full-size run stopped at the VRAM reserve after 164 s. The reduced-size run stopped at the host RAM reserve after 168 s. These are single runs per setting. World entry and in-game performance remain unverified.

@lucaseddd

Copy link
Copy Markdown

RTX 3060 Laptop 6 GB / Windows 10 22H2 follow-up. The operator reported that the opening cutscene looked better with one mip level dropped, with dark/missing-looking surfaces and low frame rate still present.

Builds: fxceless c96b4f2 + 310c6eb (packed-texture queue and reuploads at full budget) + Xeltax/VIcky#9 (integer render-target blending, adapted to both depth paths). The second build also includes #610 at 5971e08 and sets VICTORY_TEXTURE_DROP_MIPS=1. Both used Agility SDK 1.620.2, diagnostics, VICTORY_CARD_BUFFERS_MB=512, VICTORY_TEXTURE_GUARD=0, VICTORY_TEXTURE_NO_WAIT=1 and VICTORY_SHADER_LOOP_LIMIT=256. Both loaded an existing host pipeline library. The test was offline, with title data on an HDD.

One run per build Baseline (full mips) #610 (one mip dropped)
Boot log to first frame with 500+ draws 13m44s 7m26s
Median frame time, first 18 reported 3D intervals (>=500 draws) 557 ms 384 ms
Range of those interval averages 331–1,264 ms 295–1,628 ms
Indexed textures waiting at end of that window 15,426 10,568
Indexed texture uploads reported cumulatively at that point 8,329 34,129

What worked: The #610 build reached the world sooner in this pair, reduced the queue, and improved observed cutscene presentation. Separately, the blend backport turned the same E_INVALIDARG mesh pipeline into a successful creation on this GPU (VIctory #806 reproduction). The targeted blend, packed-neighbor and mip-view tests passed.

What remained: The full-mip build still hit a large texture backlog after 310c6eb, even with the compilation queue empty. Dropping one mip still produced slow intervals and visible dark areas. In several later 3D intervals with zero pipelines being built, copy-back was still about 142–281 ms per frame. This makes waiting for pipeline compilation alone an unproductive next test for that section. I also checked whether VIctory's cd94d35/940d32f6 page-marked copy-back changes could be applied directly to this tree. They conflicted across the host, descriptor, and shader-emission paths, so they were not part of either run.

The runs used successive pipeline caches and were not frame- or camera-matched. The table is an observational comparison, not an isolated speedup estimate. Upload counts are cumulative counters, not VRAM residency.

@sagouindupm

Copy link
Copy Markdown

Measured on an 8 GB card in the Series S profile, since that is what this is for.

Setup. RTX 3050 8 GB, i5-12400F, 32 GB, Windows 11, release build. Tree: main at 310c6eb + #32 + #188 + #86 + DLSS (Marvisak/VIctory#1704) + #51 + #640 + this PR + #467 + #518, as sagouindupm/victory-fork series-s-perf. Each run loads the same checkpoint (first room of the world), about 5 minutes, no input; the frame time is read from the window title every 9 s.

VICTORY_TEXTURE_DROP_MIPS Last four readings Video memory at the end Tree
unset 406, 361, 350 ms (run 1); 396, 365, 344 ms (run 2) 7.45, 7.42 GB without this PR, #467, #518
unset 373, 351, 362, 348 ms 6.74 GB with the three
1 225, 215, 224, 218 ms 5.77 GB with the three
1 224, 226, 214, 217 ms 5.82 GB with the three
2 215, 209, 219, 216 ms 4.88 GB with the three

So here =1 takes the settled world from about 355 ms to about 220 ms a frame and frees about 1 GB of the card; =2 frees another 0.9 GB and changes nothing more in the frame time, so on 8 GB one level is enough in this scene. I did not see a loss of sharpness at 1920x1080 output from 1280x720 in the screenshots (character, room, yard through the window).

Two things to know:

  • In the first of the two =1 runs the scene came up wrong (a flat green wall behind the character, frames of 2 s for about two minutes, then 225 ms). The second =1 run and the =2 run were right. One odd launch in three is too few to say it is this PR and not the known launch-to-launch differences on this base (the first room's walls are missing in about every other launch without this PR too), so take it as a count.
  • With the switch the first minute in the world is slower (0.7 to 2 s a frame while textures arrive), with or without the odd launch.

Not tested: =3 and =4, anything past the first room, Series X, this PR alone without #467 and #518.

AI-assisted: Claude Code (Claude Fable 5.2) made the runs and wrote this note.

@Filip722

Copy link
Copy Markdown

One more result for the 8 GB texture mode. With one mip dropped, the host texture shrank as intended, but a CPU refresh still read and hashed the omitted high-resolution data. An asset-free 512×512 RGBA8 test on this PR's head (5971e08b8e74112339ddbde33e298e2701b58a15) reproduced it. A single-slice, four-mip texture read 1,392,640 bytes, including the 1,048,576-byte level the host had omitted.

Cherry-pickable follow-up on this PR's head. It limits the CPU refresh to the retained mip range for single-slice 2D textures. The same texture then read 344,064 bytes. Changing only the excluded level left the upload clean. Changing a retained texel updated the expected staging byte and preserved its adjacent channels. With dropping off, the single-slice control still read 1,392,640 bytes. The two-slice control still read 2,785,280 bytes and preserved the original slice stride in both modes.

The focused texture-memory suite passed 4/4 with dropping off and 4/4 with one mip dropped. The retained-layout test compares all output bytes for linear, 4 KiB tiled and 64 KiB tiled layouts, including packed mip tails. The asset policy passed across 169 files. These byte counts measure the synthetic texture. I haven't established a title-level loading-time or FPS gain.

RTX 5060 Laptop GPU (8 GB), NVIDIA 615.78.08, Bazzite 44, Proton Experimental 11.0-20261112, vkd3d-proton 3.2.0 (ec20719452e916b), Rust 1.98.1 Windows MSVC target. Codex (GPT-6.2-Sol, high reasoning) assisted with the change, tests and report.

@sagouindupm

Copy link
Copy Markdown

@Filip722 the title-level number you said was missing, for your follow-up 3169410, on the same 8 GB card and scene as my comment above (RTX 3050, Series S, VICTORY_TEXTURE_DROP_MIPS=1, the tree of that comment with your commit cherry-picked on top: series-s-perf). Two runs each; frame time read from the window title every 9 s from 100 s after launch.

Readings before the world settles under 300 ms Settled frame time (last four) "textures" in the last frame line
#610 alone 12 and 3 (the second run's world was already up at the first reading) 225, 215, 224, 218 and 224, 226, 214, 217 ms 4.4 ms 9.7 MB
#610 + 3169410 11 and 10 220, 222, 215, 222 and 220, 239, 229, 218 ms 7.6 ms 21.7 MB; 2.1 ms 4.0 MB

So here: no regression (both runs reach the world, picture as before, walls present in both), and no gain I can measure in either the settled frame time or the time the world takes to settle; both are inside the run-to-run spread on this base. The texture part of a settled frame is only 2 to 9 ms here, so there is little for it to save once the world is up; a gain would have to show while textures arrive, and with four runs I cannot see one.

AI-assisted: Claude Code (Claude Fable 5.2) made the runs and wrote this note.

@CuteBooty

Copy link
Copy Markdown

A second card: RTX 3070 8 GB, Series X mode, N=1

5971e08 picked onto c96b4f2 + main 310c6eb (with #605 left out) and a number of other open PRs. The prologue's
first room and what follows, warm shader cache, settled medians of the log's frame lines:

Frame Preparing On the card Queue (slots queued / due)
Without the switch, 2 runs 573 and 614 ms 256-262 ms 275-309 ms about 24,000 / 22,000
=1, 4 runs 321, 344, 426, 449 ms 140-169 ms 124-220 ms 15,500-18,500 / about 10,000
  • Run-to-run spread on this PC is about 130 ms with identical settings, so read the table as "roughly 580 down to
    roughly 390 ms", not to the millisecond.
  • Three more runs with =1 and a longer bake budget sat at 533-584 ms; the longest was 29 minutes with no error,
    no device removal.
  • The line "copy with a texture whose host copy leaves out levels skipped" fired once per run. I did not trace any
    blank texture to it. Detail is softer, as expected.
  • The card is still at its budget with =1 (6.5-7.0 GB in use of 6.4-6.9 GB, 5-7.6 GB shared), so later scenes
    still lose textures; the switch moves the limit, it does not remove it.

Not tried: =2, and the switch together with #704 (see the note there).

Setup: RTX 3070 8 GB (driver 621.24, 32-lane waves), Ryzen 5 3600, 32 GB, Windows 11, Series X mode, 1920x1080, relay at its default (stage 2), card buffers 1 / 1024 MB, a diagnostics build.

oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
GPU: VICTORY_* switches set to 0 are off (fxceless#610)
(cherry picked from commit e82a6ad)
@ArturoWolff

Copy link
Copy Markdown

Integration note for rebasing #610 (5971e08) onto 8dd30ab: unlike the earlier 8 GB frame-time tests, this checks whether the new opt-in levels-on-demand path and mip dropping agree on level numbers. It is independent of the default cross-view guard.

The merge builds. In resource.rs, however, the reserved texture goes through host_texture_as, which reduces the host mip chain, then Tiled::make gets the original r.desc.mip_levels. The shape test that admits textures to this path does not exclude a nonzero drop_levels(&r.desc). There are further runtime eligibility checks; this alone does not show a game texture actually got mapped incorrectly.

I extracted the existing shape test unchanged and ran an asset-free Windows-target unit test in fresh GE-Proton11-14 processes on Linux. For a single-slice 1024×1024 RGBA8 texture with 11 levels, the invariant “a texture whose levels were dropped must not enter the unshifted tile path” passed at VICTORY_TEXTURE_DROP_MIPS=0 and failed at 1, 2, and 4. Adding && drop_levels(&r.desc) == 0 to tiled eligibility made all four cases pass; the 256×256, nine-level control stayed eligible at all four settings. #610's existing view-shift test also passed before the change at 0 and 1, so it doesn't catch this interaction.

Conservative integration option: keep mip dropping on the existing non-reserved path for affected textures and keep on-demand tiling for the rest, until tile mapping supports the same title-to-host mip offset. No game or hardware tiling run, pixel readback, VRAM/FPS measurement, or wall-rendering claim here.

AI disclosure: Hermes Agent inspected the merge, wrote and ran the regression test, and posted these results on ArturoWolff’s behalf.

ofc0urse and others added 5 commits November 25, 2026 08:59
…els on the host

On an 8 GB card the textures picked by index stop at the card's memory
budget with about 15,000 more due, and the GPU time per frame is about
three times what it is when they fit (RTX 4060 Ti, first room).

With the switch, host copies of 2D textures the title fills (at least 512
texels on the shorter side, sides halving into whole 4-texel blocks) leave
out their N largest levels: staging detiles title level m + N into host
level m, shader views shift their levels down, buffer-to-texture copies go
to the level the host copy has, and other copies with such a texture are
skipped. Off (0) by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: OpenAI Codex (GPT-6.2-Sol)
(cherry picked from commit 81e1f7a80021f66068697e118e5aa01bc564c4de)
Keep the original title layout offsets for retained mip data and narrow the CPU refresh range for single-slice 2D textures. Preserve the title extent for residency and budget checks and keep array slice strides intact.

Assisted-by: Codex (GPT-6.2-Sol)
(cherry picked from commit 31694102841a09ec13cd8d4a14f36e49668bd664)
Levels on demand (VICTORY_LEVELS_ON_DEMAND=1) cuts a reserved texture into
tiles by the title's level numbers, while a texture with
VICTORY_TEXTURE_DROP_MIPS has a shorter host mip chain. Such a texture now
takes the plain path, as ArturoWolff pointed out in the review of fxceless#610.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A copy between a texture whose host copy leaves out levels and another
texture was skipped. A title level has the same size in every host copy
that has it, so both sides now map to their own host subresource:

- CopyTextureRegion maps the source subresource as it already mapped the
  destination; a level a side does not have is skipped.
- CopyResource between host copies that leave out different numbers of
  levels copies each level both have (copy_levels); equal ones keep
  CopyResource.

On an 8 GB card with VICTORY_TEXTURE_DROP_MIPS=1 the skipped copy left a
static blocky patch on screen in the first room; with this change the
patch is gone and the skip counter stays at 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CuteBooty

Copy link
Copy Markdown

Both fixes ran in the game here

Both applied to our tree with line offsets only (3169410's test needed its staged_memory / fingerprint calls
adapted). With them in, three Series S runs of 12, 25 and 24 minutes with VICTORY_TEXTURE_DROP_MIPS=1, from the
first room to the first mission of Chapter I: no error, no device removal, and nothing in the picture I can tie to
either change. No measurable frame-time change, as expected.

The once-per-run line "copy with a texture whose host copy leaves out levels skipped" still fires; that is the
texture-to-texture path in unlike(), which neither commit touches. A few textures with wrong contents (an
armband, a bag) are still there and may belong to that path; not shown.

Setup: RTX 3070 8 GB (driver 621.24, 32-lane waves), Ryzen 5 3600, 32 GB, Windows 11, Series S mode (PR #188), 1920x1080, VICTORY_TEXTURE_DROP_MIPS=1, relay at its default (stage 2), card buffers 1 / 1024 MB, a diagnostics build of a tree with a number of open PRs picked.

@ofc0urse

Copy link
Copy Markdown
Author

Rebased onto main at 9376fd6, with the review fixes folded in:

  • fc4b3dd, 7d0e398: @Filip722's two follow-ups (retained-level read back; a refresh reads only the retained levels), cherry-picked with their authorship.
  • bd2ccd8: a texture that leaves out levels stays off the levels-on-demand tile path, the check @ArturoWolff suggested.
  • 68e6f6a (new): copies with such textures go level by level instead of being skipped. CopyTextureRegion maps the source subresource the way it already mapped the destination. CopyResource between host copies that leave out different numbers of levels copies each level both have. A title level has the same size in every host copy that has it, so boxes stay as they are. The "skipped" warning no longer fires in a run.

Same machine as before (RTX 4060 Ti 8 GB, driver 621.24, Series X profile, diagnostics build, warm cache, same automated walk into the first room). Settled minutes, a26859f + this PR:

DROP_MIPS ms/frame GPU ms indexed textures uploaded waiting host copies the title fills
0 233-255 59-68 16,411 ~24,700 4,574 (2,059 MB)
1 240-251 68-72 46,955 ~16,600 12,270 (2,054 MB)

On the new main the switch no longer changes the frame time here: the card room work in a26859f already keeps this card inside its budget. What changes is how much is on the card: about three times the indexed textures and 2.7 times the title-filled copies in the same 2 GB. In the captures that is the window glass, the textured building and the clothing of the people in the yard, which stay plain with =0.

One open problem I could not pin down. With =1 on a26859f and 9376fd6, four of five runs (one of them the BC-only test below) show two static, blocky patches in the lower corners of the first room (stale content where the lower wall should be; same pixels in every capture of a run). Two runs with =0 did not show them. What I ruled out:

  • the skipped copy: the patches stay with 68e6f6a, where no copy is skipped;
  • non-block-compressed textures: leaving out levels only for BC1-BC7 formats (a local test, not in this PR) still shows them.

The same staircase edge appears on a character's shoulder with =0 as well, so the switch may only move an existing artefact onto a larger area. =1 was clean on c96b4f2. If someone knows which pass draws the lower wall there, I can test further.

Not tested: other cards, scenes past the first room, levels on demand together with the switch, AMD, Wine.

🤖 Generated with Claude Code

@ArturoWolff

Copy link
Copy Markdown

Verified the tile-eligibility part of your rebase (bd2ccd8, tested at 68e6f6a) on Linux/GE-Proton11-14. In the earlier comparison, a 1024² RGBA8 texture still qualified for the unshifted tile path at DROP_MIPS=1/2/4. On this head it no longer qualifies at any of those settings; at 0 it still does.

I extracted the hosted shape predicate into a private helper used by both hosted and the test. With VICTORY_LEVELS_ON_DEMAND=1, four fresh processes (VICTORY_TEXTURE_DROP_MIPS=0,1,2,4) each reported 1 passed; 0 failed. The 512² case followed 1024²; 508² and 256² stayed eligible below the size threshold, as did 516² where dropping would violate block alignment. These were single-slice descriptors, not hardware tile allocations.

That resolves the specific predicate failure I reported. This test does not exercise the new copy commands or identify which pass draws the lower wall.

AI-assisted: Hermes Agent wrote and ran the regression fixture, compared the results, and posted this follow-up for ArturoWolff.

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.

6 participants