d3d12: render targets laid out linearly go back into title memory (black photos) #2915
Open
github-bot
wants to merge 2 commits from
github-bot/gh-2915 into main
AGit
pull from: github-bot/gh-2915
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2915
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2915"
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?
@kurrutako on GitHub · 2026-12-01 17:57 UTC · original
kurrutako:fix/d3d12-linear-targets-back→main· +82 −5 · 4 files · 2 commits · openClaimed in the coordination issue as: D3D12-LINEAR-TARGETS-BACK (#2570)
What and why
A title lays a render target out linearly in its memory (layout 1, or
0x100 |the linear swizzle mode) when its CPU reads what is drawn there, for example a photo it encodes to an image file from that memory. On the D3D12 runtime the host texture was the target's only picture: nothing copied it back, so the memory under it stayed zero and such photos were saved black.This PR:
resource::linear_target(linear_target_descfor the description): a 2D, single-sample texture with the render-target flag in a linear layout;texback::wantedalso take such targets, so the existing copy-back path (texback) returns them to title memory when the list closes;draw.rs(list.texture_written), so the copy-back sees draws into it;LEONIDA_TARGET_BACK_LINEAR=0to turn it off (as before).Targets in the library's own tiled layouts, MSAA targets and textures without the target flag are unchanged.
Tested
Played on Windows 11, RTX 5070 12 GB, NVIDIA 621.01. D3D12 runtime, diag build, Series X profile.
cargo test -p leonida-gpu --lib: 634 passed (new testresource::tests::only_linear_render_targets_go_back).cargo clippy -p leonida-gpu --all-targets -- -D warnings: nothing in the changed lines (the four lints it reports are inmainalready:host.rs,pipeline/host.rs,pipeline/known.rs).python -I scripts/check_no_game_data.pyon the three files: clean.GPUs tested: NVIDIA GeForce RTX 5070 12 GB, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code)
🤖 Generated with Claude Code
@merzleckeier on GitHub · 2026-12-01 18:17 UTC · original
Independent GPU readback of synthetic linear render targets at
8c8ae9b4+7fbdf851. I built the same 64×16 RGBA8 fixture on each tree. It registers the render-target state, performs a real D3D12 clear, callsHostList::texture_written, closes and submits the list, and checks CPU backing after synchronous landing (LEONIDA_TEXBACK_ASYNC=0).With the PR’s default setting, both linear layouts (
0x1and0x100) returned all 1,024 red RGBA pixels on both Radeon RADV (Mesa 26.3.1) and GeForce RTX 4070 SUPER (620.73.04), using Wine 11.22 / VKD3D-Proton 3.1.0. Main and the PR withLEONIDA_TARGET_BACK_LINEAR=0both retained zero-filled CPU backing. Layout0x0retained zero-filled backing in every run. The existing texture-back test selection passed all eight on main and all nine on the PR, including the new eligibility test.The fixture covers selection and the production close, copy, and landing path after explicit write registration. MEASURED with synthetic textures. AI-assisted (Codex).
@KelboLive on GitHub · 2026-12-01 18:46 UTC · original · reviewed
Tested
8c8ae9b4: 634 lib tests pass including the new predicate test, forcing theRENDER_TARGETguard makes it fail, clippy keeps only the four pre-existing warnings, andmerge-treeagainst current main is clean. The hook is right: targets are!fills(resource.rs:1884-1888), so the host copy is the only picture, and close-time registration (draw.rs:3063→host.rs:8878,:9295) runs after the list's resolves with oneback_wantedentry per owner, so there is no double copy.Two scope issues:
linear_target_descacceptsmip_levels > 1/depth_or_array_size > 1(resource.rs:3959), whiletexture_writtenmarks every subresource (host.rs:9265,texback.rs:164) and non-copy tickets write the whole allocation (texback.rs:496-500). For a mip chain or array, that copies back mips/slices no draw touched, from a host copy that was never uploaded (targets are!fills). Please restrict it to the RTV's subresource, or at least single-mip/single-slice.ResolveSubresourceis still uncovered.texture_copiedis gated ontitle_written(texture.rs:1290-1294), which is false when the target flag is set, so an MSAA→linear-photo resolve stays black. Is the measured photo path a direct draw? A synthetic resolve fixture would settle it — and would also cover the case where an earlier list's whole-target copy-back lands pre-resolve pixels.Minor:
texback.rs:71is over rustfmt width.The in-tree test only checks the predicate plumbing — not
wanted(), the toggle, or the copy/land path — so the end-to-end claim still rests on the author's and the independent commenter's runs. No conflict with current main;resource.rsoverlaps #2908/#2765/#2658 only outside these hunks.@merzleckeier on GitHub · 2026-12-01 19:26 UTC · original
Asynchronous linear target readback with a held writer at
8c8ae9b4on60f7dcd9. I cleared a synthetic 64×16 RGBA8 D3D12 render target to red, explicitly registered the write withHostList::texture_written, and submitted throughexecute_sync_internal. The test held the productiontexture read-backsworker immediately before the CPU write. On both an RTX 4070 SUPER and Radeon RADV (Wine 11.22 / VKD3D-Proton 3.1.0), submission returned while the worker was held and CPU backing was still zero. After release both linear layouts (0x1and0x100) returned all 1,024 red pixels. Synchronous mode returned the same pixels on the submitting thread.Main and the PR with
LEONIDA_TARGET_BACK_LINEAR=0both retained zero backing for these targets. Nonlinear0x0stayed zero in all eight hardware runs. Focused existing tests passed 8/8 on main and 9/9 on the PR per GPU. The later main update93ffc482changes the launcher and its test in this merged tree.This covers explicitly registered single-subresource targets. The multi-subresource and resolve-only cases raised in review were outside this fixture. AI-assisted (Codex).
@merzleckeier on GitHub · 2026-12-01 19:37 UTC · original
Two linear-target edge cases reproduced on hardware at
8c8ae9b4on93ffc482, with synchronous landing. I compared main, the PR with linear readback on, and the same PR withLEONIDA_TARGET_BACK_LINEAR=0on an RTX 4070 SUPER (620.73.4) and Radeon RADV (26.3.1), using Wine 11.22 / VKD3D-Proton 3.1.0.ResolveSubresourceentry resolved a green 4× MSAA source into a linear single-sample target. An independent host readback found 1,024/1,024 green pixels in each of 24 resolves (both layouts, both GPUs, all three arms, with and without a separate earlier red clear). CPU backing had zero green pixels in all 24. With the PR on and a previously registered red clear, it retained all 1,024 red pixels. Fresh backing and the other controls retained zero-filled pixels.0x1,0x100) gave the same result.MEASURED with synthetic textures. The array fixture explicitly registers the write and the resolve fixture uses the console resolve entry directly. AI-assisted (Codex).
@kurrutako on GitHub · 2026-12-01 19:51 UTC · original
Thanks @KelboLive, and @merzleckeier for the hardware runs (the two-mip/two-slice one shows exactly the problem in point 1). Pushed
58e8535c:linear_target_descnow also requiresmip_levels == 1anddepth_or_array_size == 1, so a mip chain or an array is never copied back from host subresources no draw touched. The test covers both cases.resolve(list.rs) now also callstexture_copied(dst, Some(dst_sub))for a linear target whentargets_back()is on, as it already did for textures the title fills. The measured photo path is a direct draw: thedraw.rshook is what made the in-game photos come out. This covers the resolve case too.texback.rs:71is wrapped to rustfmt width.cargo test -p leonida-gpu --lib: 634 passed. clippy reports only the pre-existing warnings.check_no_game_data.pyon the changed files is clean, and the branch merges cleanly with currentmain. Not re-run in game after this push. The resolve change is covered only by the reasoning above, not by a fixture of mine.AI-assisted (Claude Code)
@merzleckeier on GitHub · 2026-12-01 20:00 UTC · original
Hardware recheck of the single-subresource and resolve update at
58e8535con99a29d10. Compared main, prior head8c8ae9b4, and the updated head on RTX 4070 SUPER and Radeon RADV (Wine 11.22 / VKD3D-Proton 3.1.0).LEONIDA_TARGET_BACK_LINEARorLEONIDA_COPY_BACKstill left the GPU resolve intact and suppressed CPU landing.All 10 synchronous matrix runs passed both diagnostics. Existing focused tests passed 8 on main and 9 on each PR head per GPU. MEASURED with synthetic textures and an instrumented async writer. AI-assisted (Codex).
@EdenBendheim on GitHub · 2026-12-02 00:07 UTC · original
Independent native Windows 11 + RTX 3090 verification (
VERIFY-2915-RTX3090, claimed in #2570): PASS58e8535cfmerged cleanly ontomain913b88b90(diagnostics,mimalloc,exe_sha16:1ebc71ceabfb0417).610.88).python -I scripts/check_no_game_data.pypassed on all changed files.cargo test -p leonida-gpu --locked -- only_linear_render_targets_go_back --test-threads=1):913b88b90with PR test overlaid: compile failure (linear_target_descmissing).--features diagnostics): 1 passed, 0 failed in both configurations.scripts/game-gate.ps1, Series X 1080–1440p,-NoFrameGen, upgraded 8-leg sprint/wide-turn/jumpgate_driver+LEONIDA_GAME_ACTIONS_RUN="150:time 23"):PASS(reasons=[],warnings=[],exit=clean,stop=target,cache_saved=true,GATE CONTROLfired withmoved=2.54 m, maxfrom_control_m=9.2 m,time 23confirmed PASS).world_s=304.2s,world+60s, 4,808 presents, 6,537 median draws):20.03 FPSmedian,15.54 FPSp5,64.37 msp95 frame time,0.430 slongest present gap,0missed pipeline waits,31,218 MBmax private memory,250 MBmin commit left,12,033 MBmax VRAM (0 sover budget).AI-assisted: yes (Gemini 4 Neon orchestrator; Codex GPT-6.2 Astra build, unit tests, and serialized RTX 3090 gate execution).
@MoonEyes on GitHub · 2026-12-02 12:31 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@Kal0s-design on GitHub · 2026-12-02 13:55 UTC · original
Ran natively on Windows 11, head
58e8535cfmerged into currentmain(128648cfe, clean merge). Earlier runs here were under Wine or were the in-game gate, so this one covers formats, row pitch and the end of a mapping on a native driver, with a throwaway test (not committed).cargo test -p leonida-gpu --lib --locked: 692 passed, 0 failed.only_linear_render_targets_go_backpasses. clippy on the merge reports one lint (host.rs:7633, unusedmut), andmainalone reports the same one, so nothing comes from this PR.Fixture. A title texture is created at an address inside committed memory, placed so it ends exactly at the end of the committed region with a no-access page right after it. Title memory is filled with
0xCDfirst. The host copy is filled with a different byte pattern per texel throughCopyTextureRegion. Thenensure_state(RENDER_TARGET),texture_written, close,execute_sync_internal, withLEONIDA_TEXBACK_ASYNC=0. I compared every texel atLayout::offsetand checked that bytes outside the texels (row padding, and memory before and after the texture) still hold0xCD. Layouts0x100and1gave identical results everywhere. Every case below ran on the NVIDIA card and on WARP. OnmainI ran the same fixture, wheretexture_writtendoesn't take these targets.Formats that match the host copy: all correct.
mainThe console's linear row pitch matched the copyable-footprint pitch in every case (both rounded up to 256 bytes), so the tiler never had to deal with a pitch mismatch. Writing the last byte of a texture that ends right at a no-access page did not fault. With
LEONIDA_TARGET_BACK_LINEAR=0(NVIDIA card, 33x7 and 64x16 sizes), every texel stayed0xCD.Finding 1: targets in a stand-in format get raw host bytes.
linear_targetdoesn't checkstands_in. When the host copy uses a wider stand-in format (target_format),texback::writetiles the host rows using the console's element size with no conversion. Each console texel then gets the next N raw bytes of the host row: console texel 1 holds bytes 4..7 of host texel 0, so the left half of every host row ends up across the whole console row.On
mainthis memory was untouched. With the PR it gets those bytes, but only on hosts that use the stand-in. Adding&& !stands_in(this)tolinear_target, or converting before tiling, would avoid it. I don't know whether the title ever makes a linear target in one of these formats.Finding 2: a draw that covers part of a linear target overwrites the rest from the host copy. Host and title memory both started as above. I copied only a 32x16 box into the left half of a 64x16 target, then registered the write:
0xCDbefore)main: right half00 00 00 00(the fresh host copy)Same on both GPUs. Targets are
!fills, so anything the title's CPU wrote into the target's memory never reaches the host copy, and a non-copy ticket rewrites the whole subresource. This is the in-subresource case of the mip/slice issue fixed in58e8535c. It doesn't matter for a full-screen photo, but it would for a target the CPU pre-fills and the GPU draws only part of. I'm noting it as a limit of scope, not asking for a change.Not checked: real draws or resolves (the fixture writes the host copy by a copy), asynchronous landing, a CPU write made between submission and landing, the cost of calling
texture_writtenfor every bound target on every draw, block-compressed formats (they cannot be render targets), and anything in game.GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:21 UTC · original
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:29 UTC · original
Verification triage of #2915
Head
58e8535cfis already verified on this exact head: EdenBendheim (VERIFY-2915-RTX3090) and Kal0s-design (native Windows 11). CI passes (6/6) and the PR merges cleanly. No new run here (Windows-only). Verdict: ready (already verified on this head).AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@fiestorra on GitHub · 2026-12-03 04:19 UTC · original
VERIFY-2915 — aplica limpio, uno de sus cuatro ficheros ya está en
main, y la suite no se rompeMétodo del
AGENTS.md: cherry-pick del commit sobreorigin/main—Y el 1 es la iGPU. Pero el detalle que vale la pena: el PR tiene 4 ficheros y el cherry-pick tocó 3 —
O sea que el cambio de
list.rsllegó amainpor otra vía (es el fichero delwith_capacityque revisé en#2952esta noche, y probablemente el mismo commit de origen). El cherry-pick aplica el resto sin conflicto y descarta lo que ya está, que es exactamente lo que debe hacer.Lo que el PR hace, por su título: los render targets con disposición lineal vuelven a la memoria del título — el caso de la foto que sale negra porque el destino se quedó en un recurso propio, y
resource.rs+58 es donde vive la nueva disposición.Lo que no verifiqué: la foto negra — necesita el título y su modo foto; los 716 verdes dicen que el cambio no rompe ninguna de las pruebas existentes, ni más ni menos.
Y la consecuencia para el merge: cuando alguien lo rebase,
list.rsno aparecerá en el diff, y eso es correcto — un revisor que espere cuatro ficheros y vea tres debería saber por qué antes de sospechar de la PR.@MoonEyes on GitHub · 2026-12-03 17:26 UTC · original
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #2915, #2896, #2893 and #2889 merged into main
09273248c; this PR tested at its current head58e8535cf. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s, screen kept on.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.