Skip to content

Make a title texture's host texture on first need (opt-in) - #52

Closed
ForsunJay wants to merge 1 commit into
DesertGamer:mainfrom
ForsunJay:t21-lazy-host-textures
Closed

ForsunJay wants to merge 1 commit into
DesertGamer:mainfrom
ForsunJay:t21-lazy-host-textures

Conversation

@ForsunJay

Copy link
Copy Markdown
Contributor

What this changes

Related: T21 (#29).

Every title texture gets its host texture when the title creates it, and every D3D12 resource is charged to the process commit when it is created, resident or not. The title creates far more textures than it draws with.

With VIPORT_LAZY_HOST_TEXTURES set, a title texture only records the state and clear value it would be made with. The host texture is made the first time something asks for it: host_copy, host_resource, host_transition, or a placed texture over the same memory.

A shader or unordered-access view of a texture not made yet is parked in its heap slot and made, with the texture, when a shader reads the slot, as views of placed textures already are. Without this the change does nothing: the title writes a view of every texture it streams in, so making the view at once would make every texture.

Off by default: without the variable nothing changes.

Measured in the menus: 22.9 GB without the variable, 11.7 GB with it.

Only resource.rs and descriptor/host.rs change. No diagnostics counters and no README row for the variable are in this pull request.

Checked

  • No game data of any kind (files, extracts, screenshots, dumps, saves): see docs/asset-policy.md
  • No binary files or archives
  • No new dependency, build.rs, git hook, .cargo config, CI change or script (or an issue explains why)
  • No download, no started program, no network connection added (or an issue explains why)
  • cargo test --workspace passes (with --test-threads=1; see below for parallel runs)
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes
  • The code I wrote is formatted with rustfmt; I did not reformat lines I did not change

What I ran

On Windows, on this branch (base 15ad9a3):

  • cargo test --workspace --locked -- --test-threads=1: no failures (viport-gpu: 226 passed).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --features viport-gpu/diagnostics: clean.

Two failures I saw are on main too and are not from this change:

  • frame::tests::waits_end_on_ticks_and_count_frames fails in some parallel runs of cargo test -p viport-gpu: 4 of 20 runs on this branch, 4 of 20 on main (15ad9a3). It does not fail with --test-threads=1.
  • copystat::tests::counter_enum_matches_array_length fails with --features diagnostics on main (15ad9a3) and on this branch alike.

No unit test for the change itself: the variable is read once per process and the effect needs a real device and the title. The figure above is from the menus only.

Overlaps

None that I know of among the open pull requests.

🤖 Generated with Claude Code

Every title texture got its host texture when the title created it, and
every D3D12 resource is charged to the process commit when it is created,
resident or not. The title creates far more textures than it draws with.

With VIPORT_LAZY_HOST_TEXTURES set, a title texture only records the
state and clear value it would be made with, and the host texture is made
the first time something asks for it (host_copy, host_resource,
host_transition, a placed texture over the same memory). A shader or
unordered-access view of a texture not made yet is parked in its heap
slot and made, with the texture, when a shader reads the slot, as views
of placed textures already are: the title writes a view of every texture
it streams in, so making the view at once would make every texture.

Off by default: without the variable nothing changes. Measured in the
menus: 22.9 GB without the variable, 11.7 GB with it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@DesertGamer

Copy link
Copy Markdown
Owner

Merged into main by hand: the original commit by ForsunJay (d7d0e6d, message without the AI co-author line) plus f88b22b, which lets a parked heap view be made once its texture exists and removes the added doc comments. Measured on one base with VIPORT_LAZY_HOST_TEXTURES=1: video memory 13066 MB (over the budget) -> 7203 MB, host textures 8111 -> 5724, textures used by lists unchanged (4875 -> 4993 MB), no errors. Thank you.

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