Skip to content

D3D12.X: a title texture whose memory is as at its last upload is not uploaded again - #486

Merged
theaustinayers merged 1 commit into
ivall:mainfrom
theaustinayers:texture-skip-unchanged
Nov 24, 2026
Merged

theaustinayers merged 1 commit into
ivall:mainfrom
theaustinayers:texture-skip-unchanged

Conversation

@theaustinayers

Copy link
Copy Markdown
Collaborator

Title textures are uploaded again whenever the write watch reports a written page under them. The watch is per page, and a title writes next to its textures and rewrites what it wrote, so textures whose bytes had not changed were detiled and uploaded again before every submit. This PR hashes a texture's memory first and leaves the upload out when the hash is the one from that texture's last upload.

I searched open and closed PRs for "unchanged texture upload", "content hash texture", "write watch upload again" and "title textures upload" before writing it. #440, #451, #455, #458 and #465 make the detile and the upload faster; none of them skips an upload. This is independent of them and should stack: it removes work, they make the remaining work cheaper.

Reproduced on main (2997c9a), a retail title, scripts/smoke.ps1 -Game <folder> -Seconds 75 with XCL_PRESS_AT=20:A in the shell (one scripted A press on the first screen starts the title's intro video): from 24 s to 40 s the activity lines show 7 – 8 presents per 2 s, with the title's submits waiting in title_textures::refresh. With a temporary counter on a local build, the refresh detiled and uploaded about 25 MB per presented frame over 14 textures, all of them "written" by the watch and none new; about 3 MB of that had changed.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: upload_all hashes the texture's memory (content_hash: four multiply-rotate lanes over 8-byte words, about 4.5 GB/s measured here) and skips the texture when same_as_last_upload says the hash is that of its last upload. forget and register drop the remembered hash, so a released texture or an address registered again gets a first upload. XCL_TEXTURE_SKIP_UNCHANGED=0 turns it off. One info line reports the count (the first, then at powers of two from 1024).
  • Unit test a_texture_with_unchanged_memory_is_left_out_until_it_is_forgotten: first upload not skipped, same bytes skipped, another texture over the same bytes not skipped, a changed byte anywhere (also in the tail) changes the hash, the length is part of the hash, and a forgotten texture is uploaded again.

Tested

  • Ryzen 9 9950X3D, NVIDIA GeForce RTX 5090 (driver 32.0.16.2114), Windows 11 Pro 26300, Rust 1.100.0.
  • cargo build --workspace then cargo test --workspace -- --test-threads=4 on 69f0635 (debug): 677 passed, 0 failed, 41 ignored (lib 637 / 0 / 21).
  • SKIPPED on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64).
  • The retail title with the command under "Reproduced on main", 75 s:
main 2997c9a this PR 69f0635
presents per 2 s during the video (24 – 40 s) 7 7 7 7 7 8 7 7 7 11 10 11 11 11 11 10 11 11
frames shown in 75 s 434 542
uploads left out – 2048+ (the last count logged)
crashes / device removals 0 / 0 0 / 0
peak commit 14,921 MB 14,839 MB
  • On my fork, with this change on top of Textures: linear levels are detiled a row at a time #440 and a threaded detile of tiled levels, the same video runs at 55 – 59 presents per 2 s. I looked at frame captures of the video from the fork's runs: the picture is the title's video, as before the change.

Regression run

Standard run, no input (the title stays on its first screen, which also goes through the refresh):

main:

xcl-smoke v1
commit: 2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1450 (PresentX 1450)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14417 MB

this PR's head:

xcl-smoke v1
commit: 69f06357bc13ae1cba7e291671f56d64ae73074a
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1428 (PresentX 1428)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14326 MB

The two 75 s runs with the button press, for the table above:

main:

xcl-smoke v1
commit: 2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 75
exit: 0x0
frames shown: 434 (PresentX 434)
presents per 2 s (last 3): 8 7 7
device removals: 0
crashes: 0
peak commit: 14921 MB

this PR's head:

xcl-smoke v1
commit: 69f06357bc13ae1cba7e291671f56d64ae73074a
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 75
exit: 0x0
frames shown: 542 (PresentX 542)
presents per 2 s (last 3): 11 11 11
device removals: 0
crashes: 0
peak commit: 14839 MB

Not tested

  • AMD GPUs; any other title.
  • Two textures of different layouts over the same shared video-memory pages (placed): the one that is left out keeps what the other's upload wrote there. I have not seen it happen and there is no test for it.
  • A texture the title's GPU work changes without note_gpu_write seeing it (a draw into a small render target that is also kept in step, Title textures: small render targets the CPU fills are kept in step (retail game's menu text is complete) #211) and whose CPU bytes then stay the same: it is not uploaded over, where before it was. I think that is the better outcome, but it is a behaviour change.
  • I did not compare frame captures between the two runs on this branch; the captures I looked at are from the fork.
  • The standard run shows 22 fewer frames on the PR (1428 vs 1450, 98.5 %), one run each.

AI use

  • Claude Code with Claude Fable 5.2: measured the refresh, wrote the change, the test and this description, and ran the commands above on my machine.

… uploaded again

The write watch is per page, and a title writes next to its textures and rewrites what it wrote: every texture with a written page was detiled and uploaded again before each submit. With a retail title's intro video that was about 25 MB a presented frame where about 3 MB had changed, and the title's submits spent their time in the refresh. The texture's memory is hashed first (four multiply-rotate lanes over 8-byte words, ~4.5 GB/s measured); the same hash as at the last upload of that texture object leaves it out. A texture that is released, or whose address is registered again, starts over. XCL_TEXTURE_SKIP_UNCHANGED=0 turns it off.

Assisted-by: Claude Code (Claude Fable 5.2)
@theaustinayers
theaustinayers merged commit 7ebf1b8 into ivall:main Nov 24, 2026
2 checks passed

@shdann shdann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At title_textures.rs:833, the cache records the hash before the upload. subresources then reads title memory again (line 1055). If the title writes between reads, snapshot A can be cached while snapshot B is uploaded. A later write restoring A will then skip the upload and leave B on the GPU. The cache can also survive an unsuccessful upload. Please hash and detile the same byte snapshot and record the hash only after the upload succeeds. This also removes a full texture read on cache misses. Static review with OpenAI Codex (GPT-6).

@CIS-C0

CIS-C0 commented Nov 24, 2026

Copy link
Copy Markdown

One case the hash check undoes, not in the review above: Table::remove (title_textures.rs:259-265) sets pending = true on a shadowed placed texture whose tiles were unmapped, and forget then calls vram::remap_if_unmapped, which binds tiles again (vram.rs:540). Those tiles hold what the newer texture wrote, so that upload is what restores the old texture. Its LAST_CONTENT entry survives being shadowed (only register/forget of the same resource clear it), so when its CPU memory is unchanged since its last upload, upload_all skips it and the GPU samples the other texture's bytes. Fix: remove LAST_CONTENT for sres where remove sets pending on remap.

Static review, not run. AI-assisted: Claude Code (Claude Opus 5.5).

@steezdis1

Copy link
Copy Markdown

Hey (IRRELEVANT abit) Just a quick feature request in relation to GPU support in XCL specifically with regard to AMD RDNA 1 GPUs (e.g. the Radeon RX 5500 XT 8GB ☹️ ).

As far as I'm aware RDNA 1 doesn't have hardware mesh shaders so anything that's routed through XCL's mesh shader render pass won't actually get rendered on those GPUs.

I was wondering if a traditional rendering fallback could be implemented.

Some possible approaches:

  1. Traditional vertex/index buffer pipeline: rather than going fully mesh shader, convert the generated geometry into a conventional vertex/index buffer and render it via a standard vertex/pixel shader pipeline.

  2. Use compute shaders as a fallback where appropriate to do the mesh processing, culling and indirect draw command generation and then just submit the resulting geometry via the normal draw calls.

  3. Capability detection: at runtime detect whether the GPU supports the required mesh shader capability and automatically pick the appropriate rendering path.

  4. Alternative geometry processing: can the existing GS/NGG geometry processing be moved into a conventional pipeline without the need for hardware mesh shader?

We'd obviously need a lot of engineering effort for this, particularly as the fallback would need to maintain the original geometry, vertex processing, culling and rendering.

I also know that performance is likely to be worse than the native mesh shader implementation, but having a compatibility mode would be a lot better than just having no geometry at all.

Would something like that be technically possible within XCL's current architecture?

I'd be very interested to hear the developers' views on this. Many thanks for your time

@Prime1997

Copy link
Copy Markdown
Contributor

Hey (IRRELEVANT abit) Just a quick feature request in relation to GPU support in XCL specifically with regard to AMD RDNA 1 GPUs (e.g. the Radeon RX 5500 XT 8GB ☹️ ).

As far as I'm aware RDNA 1 doesn't have hardware mesh shaders so anything that's routed through XCL's mesh shader render pass won't actually get rendered on those GPUs.

I was wondering if a traditional rendering fallback could be implemented.

Some possible approaches:

  1. Traditional vertex/index buffer pipeline: rather than going fully mesh shader, convert the generated geometry into a conventional vertex/index buffer and render it via a standard vertex/pixel shader pipeline.
  2. Use compute shaders as a fallback where appropriate to do the mesh processing, culling and indirect draw command generation and then just submit the resulting geometry via the normal draw calls.
  3. Capability detection: at runtime detect whether the GPU supports the required mesh shader capability and automatically pick the appropriate rendering path.
  4. Alternative geometry processing: can the existing GS/NGG geometry processing be moved into a conventional pipeline without the need for hardware mesh shader?

We'd obviously need a lot of engineering effort for this, particularly as the fallback would need to maintain the original geometry, vertex processing, culling and rendering.

I also know that performance is likely to be worse than the native mesh shader implementation, but having a compatibility mode would be a lot better than just having no geometry at all.

Would something like that be technically possible within XCL's current architecture?

I'd be very interested to hear the developers' views on this. Many thanks for your time

Would work, but we have to make sure that whatever we translate from Vulkan would be able to be ran on older hardware or NVIDIA hardware as well.

@vibryxcx

Copy link
Copy Markdown

Test report on AMD (listed under Not tested): the merge of this PR against its first parent, same title, same command.

Tested

  • AMD Radeon RX 6800 (RDNA2, driver 32.0.21045.5002), Intel Core i5-10600KF (Comet Lake: XCL emulates the console-only instructions), Windows 11 build 26200, Rust 1.100.0, release build.
  • Commits: 2997c9a (main before this PR) and 7ebf1b8 (the merge of this PR; its first parent is 2997c9a). cargo clean --release -p xcl before each build.
  • Command, as in the PR: XCL_PRESS_AT=20:A, scripts/smoke.ps1 -Game <folder> -Seconds 75 (the press starts the intro video).
2997c9a 7ebf1b8 (this PR)
presents per 2 s once the video runs (35 – 42 s) 42 44 43 44 60 61 60 60
frames shown in 75 s 1166 1584 (+36 %)
uploads left out – 1024+ (last count logged, at 60.8 s)
crashes / device removals 0 / 0 0 / 0
peak commit 15,158 MB 15,178 MB

On this machine the title reaches its 30 fps cap with the PR, where it stayed at about 22 fps without it. Between 27 s and 33 s both runs show 0 – 16 presents per 2 s while the video loads.

2997c9a:

xcl-smoke v1
commit: 2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21
gpu: AMD Radeon RX 6800
title: GTA6
seconds: 75
exit: 0x0
frames shown: 1166 (PresentX 1167)
presents per 2 s (last 3): 43 43 44
device removals: 0
crashes: 0
peak commit: 15158 MB

7ebf1b8:

xcl-smoke v1
commit: 7ebf1b8044bef8f0ef296eb36e85010cceb4633a
gpu: AMD Radeon RX 6800
title: GTA6
seconds: 75
exit: 0x0
frames shown: 1584 (PresentX 1584)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15178 MB

Not tested

  • One run of each; no frame captures compared, so the picture was not checked.
  • The placed and render-target cases from the PR's list.

AI use

  • Claude Code (Claude Opus 5.5): ran the tests and wrote this report.

@steezdis1

Copy link
Copy Markdown

Hey (IRRELEVANT abit) Just a quick feature request in relation to GPU support in XCL specifically with regard to AMD RDNA 1 GPUs (e.g. the Radeon RX 5500 XT 8GB ☹️ ).
As far as I'm aware RDNA 1 doesn't have hardware mesh shaders so anything that's routed through XCL's mesh shader render pass won't actually get rendered on those GPUs.
I was wondering if a traditional rendering fallback could be implemented.

Some possible approaches:

  1. Traditional vertex/index buffer pipeline: rather than going fully mesh shader, convert the generated geometry into a conventional vertex/index buffer and render it via a standard vertex/pixel shader pipeline.
  2. Use compute shaders as a fallback where appropriate to do the mesh processing, culling and indirect draw command generation and then just submit the resulting geometry via the normal draw calls.
  3. Capability detection: at runtime detect whether the GPU supports the required mesh shader capability and automatically pick the appropriate rendering path.
  4. Alternative geometry processing: can the existing GS/NGG geometry processing be moved into a conventional pipeline without the need for hardware mesh shader?

We'd obviously need a lot of engineering effort for this, particularly as the fallback would need to maintain the original geometry, vertex processing, culling and rendering.
I also know that performance is likely to be worse than the native mesh shader implementation, but having a compatibility mode would be a lot better than just having no geometry at all.
Would something like that be technically possible within XCL's current architecture?
I'd be very interested to hear the developers' views on this. Many thanks for your time

Would work, but we have to make sure that whatever we translate from Vulkan would be able to be ran on older hardware or NVIDIA hardware as well.

We shouldn’t have to sacrifice cross-vendor portability or compatibility with NVIDIA and older cards. Still, a lot of people in the community are using older or non-mesh hardware and would like to know whether a fallback is planned. If the stages can be translated or emulated using standard compute, vertex, or indirect draws, an optional fallback path could help those users without penalizing modern GPUs or breaking existing compatibility. Even a rough indication of whether it’s in scope would be useful.

@Prime1997

Copy link
Copy Markdown
Contributor

Hey (IRRELEVANT abit) Just a quick feature request in relation to GPU support in XCL specifically with regard to AMD RDNA 1 GPUs (e.g. the Radeon RX 5500 XT 8GB ☹️ ).
As far as I'm aware RDNA 1 doesn't have hardware mesh shaders so anything that's routed through XCL's mesh shader render pass won't actually get rendered on those GPUs.
I was wondering if a traditional rendering fallback could be implemented.

Some possible approaches:

  1. Traditional vertex/index buffer pipeline: rather than going fully mesh shader, convert the generated geometry into a conventional vertex/index buffer and render it via a standard vertex/pixel shader pipeline.
  2. Use compute shaders as a fallback where appropriate to do the mesh processing, culling and indirect draw command generation and then just submit the resulting geometry via the normal draw calls.
  3. Capability detection: at runtime detect whether the GPU supports the required mesh shader capability and automatically pick the appropriate rendering path.
  4. Alternative geometry processing: can the existing GS/NGG geometry processing be moved into a conventional pipeline without the need for hardware mesh shader?

We'd obviously need a lot of engineering effort for this, particularly as the fallback would need to maintain the original geometry, vertex processing, culling and rendering.
I also know that performance is likely to be worse than the native mesh shader implementation, but having a compatibility mode would be a lot better than just having no geometry at all.
Would something like that be technically possible within XCL's current architecture?
I'd be very interested to hear the developers' views on this. Many thanks for your time

Would work, but we have to make sure that whatever we translate from Vulkan would be able to be ran on older hardware or NVIDIA hardware as well.

We shouldn’t have to sacrifice cross-vendor portability or compatibility with NVIDIA and older cards. Still, a lot of people in the community are using older or non-mesh hardware and would like to know whether a fallback is planned. If the stages can be translated or emulated using standard compute, vertex, or indirect draws, an optional fallback path could help those users without penalizing modern GPUs or breaking existing compatibility. Even a rough indication of whether it’s in scope would be useful.

I'm currently working on this with my own branch, and I have been pushing some stuff for compatibility with older cards as well.

I'll keep this in mind for the next push, but for right now, the main goal is to get XCL running some newer titles with full support.

@steezdis1

Copy link
Copy Markdown

Hey (IRRELEVANT abit) Just a quick feature request in relation to GPU support in XCL specifically with regard to AMD RDNA 1 GPUs (e.g. the Radeon RX 5500 XT 8GB ☹️ ).
As far as I'm aware RDNA 1 doesn't have hardware mesh shaders so anything that's routed through XCL's mesh shader render pass won't actually get rendered on those GPUs.
I was wondering if a traditional rendering fallback could be implemented.

Some possible approaches:

  1. Traditional vertex/index buffer pipeline: rather than going fully mesh shader, convert the generated geometry into a conventional vertex/index buffer and render it via a standard vertex/pixel shader pipeline.
  2. Use compute shaders as a fallback where appropriate to do the mesh processing, culling and indirect draw command generation and then just submit the resulting geometry via the normal draw calls.
  3. Capability detection: at runtime detect whether the GPU supports the required mesh shader capability and automatically pick the appropriate rendering path.
  4. Alternative geometry processing: can the existing GS/NGG geometry processing be moved into a conventional pipeline without the need for hardware mesh shader?

We'd obviously need a lot of engineering effort for this, particularly as the fallback would need to maintain the original geometry, vertex processing, culling and rendering.
I also know that performance is likely to be worse than the native mesh shader implementation, but having a compatibility mode would be a lot better than just having no geometry at all.
Would something like that be technically possible within XCL's current architecture?
I'd be very interested to hear the developers' views on this. Many thanks for your time

Would work, but we have to make sure that whatever we translate from Vulkan would be able to be ran on older hardware or NVIDIA hardware as well.

We shouldn’t have to sacrifice cross-vendor portability or compatibility with NVIDIA and older cards. Still, a lot of people in the community are using older or non-mesh hardware and would like to know whether a fallback is planned. If the stages can be translated or emulated using standard compute, vertex, or indirect draws, an optional fallback path could help those users without penalizing modern GPUs or breaking existing compatibility. Even a rough indication of whether it’s in scope would be useful.

I'm currently working on this with my own branch, and I have been pushing some stuff for compatibility with older cards as well.

I'll keep this in mind for the next push, but for right now, the main goal is to get XCL running some newer titles with full support.

Appreciate that you're already tinkering with older card compatibility on your own branch for later! ❤❤

@Sauko2000

Copy link
Copy Markdown

AMD Radeon RX 7900 XTX – XCL Smoke Test Results

Hardware:

  • CPU: AMD Ryzen 9 9800X3D
  • GPU: AMD Radeon RX 7900 XTX (RDNA 3)
  • RAM: 32 GB
  • OS: Windows 11

Test details:

  • XCL commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f
  • Title: GTA 6
  • Test duration: 75 seconds
  • Approximate observed performance: 7.5 FPS
  • Frames shown: 712
  • PresentX: 712
  • Presents per 2 seconds (last 3 intervals): 15 / 14 / 15
  • Peak commit: 15,291 MB
  • Exit code: 0x0 (success)
  • GPU device removals: 0
  • Crashes: 0

The test completed successfully on an AMD Radeon RX 7900 XTX, with no crashes or GPU device removals observed during the 75-second run.

This provides an additional AMD RDNA 3 hardware test result. Hopefully, it helps expand the project's GPU compatibility and testing coverage.

I'm happy to run further tests or collect additional logs if needed.

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.

7 participants