texture: keep what a GPU copy wrote from uploads asked for before it #47
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!47
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-47"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Unverifiedd on GitHub · 2026-11-30 22:55 UTC · original
Unverifiedd:keep-gpu-written→main· +644 −13 · 4 files · 1 commits · closed without mergingWhat it fixes
Graphical glitches (nicknamed "confetti") on people's faces, necks and shirts, which can stay for the whole session. It shows up most once decorations are baked (tattoos, prints, make-up). The cause is a race between a GPU copy and a texture upload from title memory.
The title records its command lists on many threads and submits them in its own order. A draw list recorded before a bake list, but submitted after it, still has a prelude upload pending for the baked decoration texture. That texture is BC3 256x256 with nine levels; its blocks are encoded on the GPU and copied in level by level. At that later submission, the upload copied title memory over what the bake's copies had just written. Title memory never receives a GPU copy's bytes, because on the console the copy writes that memory itself. So the decoration got whatever the memory held before: other textures and streaming data, decoded as BC3. The existing
host_writtenshortcut inupload_fromonly covers lists recorded after the copy.How it was pinned down: GPU read-backs of the BC3 encoder's input (the atlas level) and its output matched block for block, so the bake was right. The garbage came from an upload of the decoration texture's title memory that landed after the copy. Decoded as BC3, that memory reproduced the graphical glitch exactly.
What it does
HostTexture::gpu_written,texture::GpuWritten). There is no table and no lock.PreludeUpload::finish_refreshleaves those levels out of the upload.VICTORY_KEEP_GPU_WRITTEN=0turns it all off, and does no work then.Cost
Measured with the same commit, warm caches, the same machine and a similar spot:
This version replaces those tables with per-texture atomics, so it costs less than the measured one. The upload is skipped about 20–40 times per play session, mostly while people stream in and their decorations are baked.
Tests
texture::gpu_written_tests: five tests of the level bits (the bake, a texture streamed bigger, layers and planes, long arrays, staging parts past the changed-levels mask).resource::tests::what_the_host_copied_in_is_kept_from_an_upload_asked_for_earlier: reproduces the race on the host GPU through the title's own list and queue calls, then reads the texture back. It passes with the fix. Without it (the switch off and the test's early return removed), it reads the changed title memory (0x22) instead of what the copies wrote (0xaa).All six pass on
37bb30funder Wine with the project's vkd3d and Mesa (RX 7900 XTX). The release build is clean, andcargo xtask policyreports 4 files ok.Noticed while doing this, not changed here
copy_texture_regionandresolvepass the title's subresource index unchanged to a host copy whose level 0 may be a later title level (copy.base), while views are translated. This may misplace copies into placed textures over 1024 texels, or into textures first viewed from a later level.🤖 Generated with Claude Code
@Fran-co-F on GitHub · 2026-12-01 14:02 UTC · original · edited 2026-12-01 14:06 UTC
A data point from an RX 9070 XT (RADV, CachyOS, GE-Proton11-14, 2560x1440):
37bb30f, ray tracing off: a character's face in an office cutscene had the coloured "confetti" noise.37bb30f+ this PR + #45 #44 #43 #38 #31, ray tracing on: the face was clean when I replayed that cutscene.Before:


After:
That fits this fix, but it isn't an A/B of this PR alone: the other five PRs and ray tracing changed too.
A separate problem remains: in another scene, a face still turns black for a moment, even with this PR in the build. It also happens on plain
37bb30f, so it doesn't come from this PR. Details in #69.AI use: Claude Code (Claude Opus 5.5) made the builds and wrote this. I played the sessions and compared the images.
@BlueCatsz on GitHub · 2026-12-01 16:03 UTC · original
Tested #47 on CachyOS + RX 9070 XT 16 GB as part of a combined local stack (
main37bb30f+ #44 + #47 + #67 + #31 + #43 + opt-inVICTORY_AMBIENT_RT, withVICTORY_POOL_MOVE=1andVICTORY_PLACED_COPIED=1).26.3.1+ #44/#43mesa.patch), CachyOS (kernel7.3.6),proton-cachyos-slr+ RB-treewineserver, Series X (1706x960 -> 2560x1440, HW RT on, FG off).0crashes,0device loss,0dropped draws). (Note: #47 and #67 were tested together rather than in isolation.)@YaBulochka on GitHub · 2026-12-01 16:23 UTC · original
This fixes the confetti here, but it tears character meshes on RDNA3 — worth knowing before it reaches an 8 GB card.
Setup. RX 7600 XT 8 GB (RDNA3), Ryzen 5 9600X, 30 GB, RADV 26.3.1, GE-Proton11-16,
series-s,VICTORY_FSR_HOST=1,VICTORY_OUTPUT=1920x1080,VICTORY_BVH_HARDWARE=0, ray tracing otherwise on. Merged on top of4cea493(our branch with #51/#52/#58/#60/#63 and three local switches:VICTORY_SHADER_OPT=0xffffffff,VICTORY_LOW_MEMORY=0,VICTORY_PROCESS_PRIORITY=high). Its own line shows up as expected:uploads over textures the host GPU wrote since they were asked for are left out.What happens. With the fix merged, characters' meshes start tearing: triangles stretching between limbs and the ground, pieces of arms and torsos left behind, most visible on people close to the camera. The confetti on shirts and necks is gone in the same runs. Reverting the merge (
git resetto the same tree without the four commits) and rebuilding brings the meshes back intact and the confetti back with them, so it is the fix and not a scene.Not ruled out. Only one save, one scene (city, close to the camera, on foot and in a car), one build, two runs each way. The tearing could be specific to 8 GB: the per-level rule leaves uploads out, and on a card where levels are streamed out and back constantly the levels a mesh bind depends on may be the ones skipped.
Happy to run whatever diagnostic you point at, or to repeat on a switch that turns only part of it on, since
VICTORY_KEEP_GPU_WRITTENis all-or-nothing today.No game files, screenshots or captures included.
@Luxuride on GitHub · 2026-12-04 12:03 UTC · original · edited 2026-12-05 11:24 UTC
As I read it, this is already in
main: main carries this change verbatim. Your commit1eac332has the same patch-id (2c999946…) as main'sdbd059f— same subject, same author, same 4 files +644/−13 — and main then built on it (LateView/twin_copycallingnote_gpu_written, exactly as the hook was asked for).VICTORY_KEEP_GPU_WRITTENis documented in bothdocs/SETTINGS.mdandrun.conf.defaulton main, so it is not an undocumented escape hatch either. The only caveat that survives is the >64-subresource limit of theGpuWrittenwhole-word bitmask incrates/victory-gpu/src/texture.rs, which main already accepts.Nothing to land — the branch is now a stale fork of code you own. Take the credit in
git log.Whether it still has work of its own is the maintainer's call, not mine.
Pull request closed