Repository navigation
D3D12.X: a title texture whose memory is as at its last upload is not uploaded again - #486
Conversation
… 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)
shdann
left a comment
There was a problem hiding this comment.
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).
|
One case the hash check undoes, not in the review above: Static review, not run. AI-assisted: Claude Code (Claude Opus 5.5). |
|
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:
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. |
|
Test report on AMD (listed under Not tested): the merge of this PR against its first parent, same title, same command. Tested
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.
Not tested
AI use
|
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! ❤❤ |
AMD Radeon RX 7900 XTX – XCL Smoke Test ResultsHardware:
Test details:
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. |
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 75withXCL_PRESS_AT=20:Ain 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 intitle_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_allhashes 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 whensame_as_last_uploadsays the hash is that of its last upload.forgetandregisterdrop the remembered hash, so a released texture or an address registered again gets a first upload.XCL_TEXTURE_SKIP_UNCHANGED=0turns it off. One info line reports the count (the first, then at powers of two from 1024).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
cargo build --workspacethencargo test --workspace -- --test-threads=4on69f0635(debug): 677 passed, 0 failed, 41 ignored (lib 637 / 0 / 21).gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).2997c9a69f0635Regression run
Standard run, no input (the title stays on its first screen, which also goes through the refresh):
main:
this PR's head:
The two 75 s runs with the button press, for the table above:
main:
this PR's head:
Not tested
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.note_gpu_writeseeing 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.AI use