d3d12: stage title textures when their format or usage rules out host copies #1894
Open
github-bot
wants to merge 3 commits from
github-bot/gh-1894 into main
AGit
pull from: github-bot/gh-1894
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
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 rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
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!1894
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1894"
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?
@ecox982745 on GitHub · 2026-11-25 14:52 UTC · original
ecox982745:ecox/title-staged-per-format→main· +128 −23 · 3 files · 3 commits · openClaimed as
RT-TITLE-STAGED-PER-FORMATin the coordination issue. This addresses the format-specific follow-up from the #1827 merge note.Depends on: #1827 (merged).
What and why
A Vulkan device can expose host image copy and still refuse it for a particular format or combination of image usages. In that case the runtime successfully created the image without host-transfer usage, but a subsequent title-texture refresh skipped its upload. Both a linear movie-plane fixture and a tiled compressed image returned incorrect bytes.
The runtime selects mandatory staging when the format, image usage or compatible memory types rule out host transfer. A GTX 1050 Ti reported no bindable memory type for a host-transfer R8 movie plane. Pascal hardware report A CPU-visible, single-sampled colour title image can use ordinary image memory and queue the upload when host transfer is unavailable. Images that can use either path retain the existing placement heuristic and host-backing retry. An allocation failure on an image that requires staging propagates normally.
Tested
Windows 11, NVIDIA GeForce RTX 4090 (616.64), MSVC 19.44. The test keeps host image copy enabled on the real device. A test shim masks the R8 format feature and separately rejects host-transfer usage in the BC1 image-support query.
446574e76with only the new test,d3d12_existing_heapfailed both readbacks: the persistently mapped R8 plane and the four-mip, two-slice BC1 array.14f04ce2d, both readbacks pass. All three existing heap CTests passed (default, write watch disabled, write watch enabled), including the unmasked controls.06ba2eb2d, a test shim reproduced the Pascal driver's empty memory type mask for a 256×8 R8 image. The previous head failed the pixel check. All three existing-heap CTests passed on the RTX 4090 with the fix, both with and without Vulkan validation. RTX 4090 test details2d258c8cd, the fallback logs the Vulkan format once per process for each affected format. The same three tests passed on the RTX 4090 with validation enabled and disabled (6/6). The shim produced exactly one format 9 (R8) fallback message in each test process.git diff --checkpassed.All texture inputs are synthetic. These tests exercise format-specific uploads and pixel readback on the reported GPUs.
AI-assisted: OpenAI Codex (
gpt-6.2-astra).Checklist
@Tyrannys on GitHub · 2026-11-25 18:12 UTC · original · edited 2026-11-25 18:55 UTC
Test report from a combined build on a second NVIDIA machine. Counts only.
Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy.
Build:
mainfe1553456(already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts.Shaders: translated on
3de22a190+ #674 + #1662 with--wave64-emulate. 29,279 of 29,280 translated, and all 29,279 passspirv-val. That is 2,683 library programs and 29 of 29 FSPX.main's translator changes since then are correctness fixes only.Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).
ActivateRays,ActivateProbesandActivateProbesTargetprograms of indirect diffuse lighting.Recipe:
scripts/windows-boot/boot.ps1 -Seconds 480,LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1,LEONIDA_PIPELINE_CACHE_DIRpointing at the offline cache. Host image copy:off (auto: NVIDIA)from #1851. One run per row.LEONIDA_TITLE_WATCHDOG=0)game_scarlett_master.exe+0x23cf683)main42537e7b6+ #1631; my run table of 07:54 in #1608).AI-assisted (Claude Code).
@ecox982745 on GitHub · 2026-11-25 18:46 UTC · original · edited 2026-11-25 20:24 UTC
Updated for
06ba2eb2d(Pascal memory-type fix). I rebuilt this head with #2020e500e9949. There is still one conflict inResource::create_texture. Keep #1894's side of the conflicting hunk and useconst bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy);. All three existing-heap CTests passed on the RTX 4090 with Vulkan validation enabled, including the new zero-memory-type R8 fixture and #2020's shared BC placement checks.I tested this PR (
14f04ce2d) together with DadaCap's #2020 (e500e9949) on an RTX 4090, Windows 11, NVIDIA 616.64. The two heads have one merge conflict, inResource::create_texture. Git merged the documentation and test changes cleanly.For whoever rebases the second PR, the resolution I tested was to keep #1894's side of the conflicting hunk and replace
!shared_zero_incan_stagewith(!shared_zero_ || no_host_copy). The resulting declaration is:This keeps #2020's shared zero image eligible for a later staged upload when host image copies are disabled. It also keeps #1894's fallback when the device supports host image copies but the particular texture cannot use them. The rest of the source merged automatically.
All three existing-heap CTests passed on that resolution (default, write watch off, write watch on). They exercised the R8 format restriction, the BC1 image-usage restriction, and the device-wide host-copy-off case. With deferral enabled, the compressed placements shared the initial image and retained all 512 checked bytes after a CPU write and GPU copy. With
LEONIDA_PLACED_IMAGE_DEFER=0, the default CTest also passed and reported eager allocation with the same 512 bytes intact. These are synthetic GPU readbacks. AI-assisted verification with OpenAI Codex.@qhukz13 on GitHub · 2026-11-25 19:57 UTC · original
Ran this on a GPU where the driver itself takes host image copy for the format but gives the HOST_TRANSFER image no memory type: Windows 10 Pro 19045, GeForce GTX 1050 Ti (Pascal, 4 GB, no Resizable BAR), NVIDIA 582.66, MSVC RelWithDebInfo. Base main
9f9a7c5f3, with and without this PR (14f04ce2d, merged cleanly),d3d12_existing_heap*3x each, plain and withLEONIDA_VK_VALIDATION=1.Result is the same on both sides:
d3d12_existing_heap,_no_write_watchand_write_watchfail,d3d12_host_prefixpasses, no validation messages. The failure is the persistent slot-133 plane on the real (unmasked) device:The PR's own masked-R8 device and the
host_image_copy = falsedevice pass the same check here, so the new path works; it is just not taken for this case. ReadingResource::create_textureat14f04ce2d: for a placed LINEAR title image whose format does take host transfer,host_transfer_stays true, soneeds_stagingis false; the placement heuristic is skipped by!linear_placement; the image is created with HOST_TRANSFER;bind_texture_memorygetsmemoryTypeBits == 0; andcan_retry_hostis false, socreate_texturereturnsE_OUTOFMEMORY. The recreate-without-HOST_TRANSFER fallback from #1364 lives only in theorigin == ordinarybranch, so it never runs for title images.This predates the PR, but the PR is the natural place for it: treat "HOST_TRANSFER leaves no memory type" like "the format refuses host transfer". For example, when
can_stage && host_transfer_, checkdevice_.memory_requirements(info, with)up front and, ifwith.memoryTypeBits == 0, dropVK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT, sethost_transfer_ = falseand take theneeds_stagingbranch (any compatible type). This is the case Pascal hits for a movie plane, which is on the boot path. Happy to rerun a fix here.AI-assisted (Claude Code).
@ecox982745 on GitHub · 2026-11-25 20:22 UTC · original
@qhukz13, could you rerun
d3d12_existing_heap,d3d12_existing_heap_no_write_watchandd3d12_existing_heap_write_watchon the GTX 1050 Ti at06ba2eb2d? Your unmasked device is the check that matters here.The runtime now checks which memory types the host-transfer image can bind before choosing its backing. If the driver returns zero types, a CPU-fillable colour title image takes the staged upload path. This includes the mapped linear R8 plane from your report.
On the RTX 4090 (Windows 11, NVIDIA 616.64), a Vulkan test shim made only the 256×8 R8 host-transfer image report zero memory types. The previous PR head reproduced your 2,048-byte allocation failure and failed the pixel check. At the new head, all three CTests passed with validation off and all three passed with
VK_LAYER_KHRONOS_validationenabled. The original format and usage restrictions are also covered in those runs. All inputs were synthetic.AI-assisted with OpenAI Codex (
gpt-6.2-astra).@qhukz13 on GitHub · 2026-11-25 21:01 UTC · original
Rerun at
06ba2eb2don the GTX 1050 Ti (Windows 10 Pro 19045, NVIDIA 582.66, MSVC RelWithDebInfo), merged onto main9f9a7c5f3, 3 runs each, plain and withLEONIDA_VK_VALIDATION=1:14f04ce2d06ba2eb2dd3d12_existing_heaptexture memory unavailable: 2048 bytes ... type bits 0x0 (vk format 9 256x8), plane check at line 1395)d3d12_existing_heap_no_write_watchd3d12_existing_heap_write_watchd3d12_host_prefix,d3d12_subresource_copyNo validation messages. So the real unmasked device is fixed, thanks.
One more data point for the docs or the comment: on this driver it is not only the R8 plane. A variant of the same check that logs (a local commit of mine on top of
14f04ce2d, same tests) took that branch for title images ofvk format 9(R8_UNORM),37(R8G8B8A8_UNORM) and133(BC1_RGBA_UNORM_BLOCK), so "Pascal gives a HOST_TRANSFER image no memory type" is the general case here, not an R8 quirk. Your head does not log that branch, so I could not count it there; alog_onceon it would make the next report easier.AI-assisted (Claude Code).
@qhukz13 on GitHub · 2026-11-26 19:05 UTC · original
One more data point for this PR, from a full
ctestbaseline on Pascal. On current main the title-placed texture tests fail, and with this PR they pass. GTX 1050 Ti, NVIDIA 582.66, Windows 10, both sides built from maine57bc63bc, the PR merged in cleanly:2d258c8cd)d3d12_existing_heapline 1530(pixels not61 * pass)d3d12_existing_heap_no_write_watchd3d12_existing_heap_write_watchd3d12_mapped_plane_asyncfirst use line 1584: filledd3d12_vulkan_deviceline 7362: heap_mismatches <= 0On main the log shows
slot 133 texture not created (hr 0x80070057, layout 6): dim 3 format 28 64x64x1 mips 12: an R8G8B8A8 texture the title places in its own memory is refused on this card, the HOST_TRANSFER case this PR handles. So the PR matters on Pascal for title-placed textures on that path in general, not only for the movie plane. Thed3d12_vulkan_devicefailure is unrelated: it fails identically on both sides.AI-assisted (Claude Code).
@robot00f on GitHub · 2026-11-27 05:57 UTC · original
Independent check on real Pascal hardware of head
2d258c8c, for the case @qhukz13 reported on14f04ce2d(that commit predates the memory-type fix, so it could not have covered it).Machine: Windows 10 Pro 22H2 (19045), Intel Core i7-2600, 4 GB GeForce GTX 1050 Ti, NVIDIA 582.28, MSVC 19.44 RelWithDebInfo.
Setup:
maind1dff794, with only the two runtime files of this PR applied (clean 3-way apply; no commit, nothing pushed). The test binary was rebuilt from both trees with the same build directory.Before (
maind1dff794):d3d12_existing_heapfailed 3 of 3 runs, exit 1, at the persistent slot-133 plane check (std::all_of(pixels..., value == 61 * pass)), with this line twice per run:That is the real driver's
memoryTypeBits == 0for the 256x8 R8 plane, not the test shim, and it lands on the title-image branch (d3d12_vulkan_device.cpp, theorigin != TitleImageOrigin::ordinarypath) that had no recreate-without-host-transfer step.After (
2d258c8c): the same test passed 3 of 3 runs, exit 0, and the new line appeared 3 times per run:ctest -R "^d3d12_existing_heap"then reported 3 of 3 passed (the default,_no_write_watchand_write_watchentries). I stopped the repeated CTest iterations there, so the three CTest entries have one full pass each rather than three.Not covered by this check: validation layers were not enabled, other tests were not run, and only the memory-type branch above was exercised (the shim-forced paths were left alone).
AI-assisted (OpenCode, DeepSeek).
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.