Repository navigation
d3d12: a 4x depth-only array is resolved slice by slice in a render pass; AMD's driver read slice 0 for every slice (D3D-417) - #3977
Conversation
# Conflicts: # docs/animation.md
# Conflicts: # docs/design.md
# Conflicts: # docs/design.md
# Conflicts: # docs/design.md
# Conflicts: # docs/character_skeleton.md
# Conflicts: # docs/design.md
# Conflicts: # docs/design.md
# Conflicts: # docs/design.md
# Conflicts: # docs/design.md
|
AI-assisted. No game files used. Tested d2e6b31 with and without the workaround on another AMD Windows driver build: Ryzen 5 7600X iGPU (RDNA2, AMD 32.0.21045.16010 / 26.10.1, against the 32.0.21042.62 in the description), Windows 11 build 26200, MSVC 19.50 Ninja Release,
Entries below are slice.mip indices judged cleared, not depth values; -1 is the printed UINT_MAX sentinel for all remaining slices.
This matches the described readback symptom for this depth-only array: clearing slice 0 appears to affect all four slices, while the selected clears above slice 0 appear to affect none. It does not independently show that the clear itself is wrong. The invalid-subresource diagnostics also occur in the zero-failure PR runs during the expected refusal checks. Not run: the D24S8/D32S8 case the description leaves open, an NVIDIA run (MKmajster covered one above), and the rest of |
0xTehuti
left a comment
There was a problem hiding this comment.
Tested and verified on NVIDIA hardware.
Hardware & Environment
- GPU: NVIDIA GeForce RTX 2070 SUPER (TU104, 8192 MB VRAM)
- Driver: 595.79 (Vulkan 1.4.329)
- OS: Windows 11 Pro x64 (Build 26100.3037)
- Toolchain: MSVC 19.44.35225 (VS 2022 Community), CMake 4.4, Ninja 1.13
Execution & Verification Results
-
Targeted Native & Validation Tests (
LEONIDA_VK_VALIDATION=1):d3d12_view_slices_test.exe:- Layer views: 24 clears on the layer, 42 on the host (RTX 2070 SUPER & WARP).
- Validation: 42 out-of-range views refused as expected.
- 0 failures, 0 Vulkan validation errors.
d3d12_typeless_rtv_test.exe:- 1584 mixed-format / automatic-mip / predicate cases.
- 1730 WARP readbacks matched, descriptor snapshots and format-cache order verified.
- 27 unsupported/invalid views rejected as expected; 0 failures.
d3d12_depth_resolve_test.exe:- 45 host comparisons matched, 9 refusals kept destination, 0 unsupported modes refused; 0 failures.
d3d12_vulkan_device_test.exe:- Full device features, creation, heap allocation, format support, and error paths matched; 0 failures.
- CTest Suite (
d3d12_vulkan_device,d3d12_typeless_rtv,d3d12_view_slices,d3d12_depth_resolve):4/4 passed (100%)in 20.61s with zero Vulkan validation layer warnings or VUID errors.
-
Static Documentation & Quality Tests:
tests/test_docs_links.py: 6/6 passed.tests/test_docs_repo_paths.py: 2/2 passed.tests/test_docs_list_items.py: 2/2 passed.tests/test_docs_design_rows.py: 2/2 passed.
-
Code Audit:
runtime/shims/d3d12_vulkan_device.cpp:view_slicescleanly resolvesUINT_MAX(-1) toresource.DepthOrArraySize - first_layerwhenfirst_layer < DepthOrArraySize, while leaving invalidfirst_layervalues unchanged so out-of-bound checks reject them. Applied consistently toTEXTURE2DARRAYandTEXTURE2DMSARRAYin RTV and DSV paths.runtime/src/vulkan_replay.h&runtime/src/vulkan_backend.h: TheVkRenderPass/VkFramebufferfallback for depth-only layer resolves > 0 addresses D3D-417 (AMD driver bug where dynamic rendering resolves layer 0) without regressions on NVIDIA. Framebuffers and passes are properly cached underviews_mutex_.- Clean-room audit: strictly synthetic tests; no game assets, captured shaders, or proprietary fixtures included.
Disclosure: Review and test verification performed with AI assistance.
|
Tested d2e6b31 on Windows 11, AMD Radeon iGPU gfx1036 (RDNA2, driver 26.10.1) and RTX 5080 (driver 616.92), MSVC RelWithDebInfo build of this head,
This is a second AMD Windows driver (26.10.1 on RDNA2 gfx1036). No negative control run; I did not rerun AI-assisted. |
|
Tested
Code read: the attachment layouts stay fixed through the pass (initial = reference = final), so the barriers recorded outside it are all the synchronization it needs, and the framebuffer cache is retired with either image under |
- replay_cpu_bench: ItsNotRexed#3693 moved a draw's render targets and vertex buffers into Draw::views (D3D-391); the bench builds a DrawViews block instead of writing the old inline arrays. - xgameruntime_user_test links file_system.cpp, which now defines rt::fs::game_dir that xgameruntime.cpp calls. - check_sparse_queue_family: a vkCreateInstance refused because the api_dump/validation layer is not installed is the documented "layer absent" skip (77), not a failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested d2e6b31 on NVIDIA GeForce RTX 4090 (driver 32.0.16.2101), Windows 11, MSVC 14.51: pass. I built the branch with CMake and Ninja, RelWithDebInfo. The build has no Vulkan SDK, thus no validation layers. Negative control: with I did not test the condition of the AMD driver. AI-assisted. |
- test_bary_fallback: ItsNotRexed#3647 (BUILD-1046) made a missing input folder exit 2 with "does not exist"; the test from ItsNotRexed#1379 still expected exit 1. - test_format_decode_branch: the f16 reference uses the interpreter's pinned half_to_float (a NaN half widens to the canonical quiet NaN) instead of struct's '<e', whose NaN payload changed in Python 3.14 (CPython gh-130317). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges that each passed alone but clash together: - v_cmp_class_f64: the earlier cmp_class_f64 (685d16e) (operand-form checks, test_cmp_class_f64) and the later f64 branch in cmp_class both handled the opcode; f64 goes to cmp_class_f64 again, f16 stays in cmp_class. - rdna2spirv CLI tests: spirv-as/spirv-val now run in the output folder with the staging file's bare name, so the test doubles resolve it against cwd; assemble_spirv decodes the output only when it is bytes. (The doubles had been writing .spirv-*.tmp files into the repository root.) - ps_w64 fixtures (TEST-722): an 18th fixture (ps_w64_a_discard) landed; its killed lanes export nothing and keep the clear value. - first_light: a run without an OBJ removes mesh.bin, and harness_env reads manifest["files"]; batch_glb's stats name failures and dropped textures; run_gpu_tests reports a frame never written as a missing readback (TEST-837). - make_game TRANSLATION_SOURCES and runtime.yml's paths include spirv_opt.py and report_paths.py (and wave64_emulate_opt.py), which the translator imports. Repo rules: stdout guard on six tools; encoding on two opens (gen_gdk_runtime_classes' helper is read_utf8); newline on one write; anim_skeleton_match's joaat encodes like hashdict.joaat; test_feature_scan's new test is listed with the others its globals() runner reaches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/runtime_imports.md # runtime/CMakeLists.txt # runtime/shims/xgameruntime.cpp # runtime/test/xmem_test.cpp # tools/rdna2spirv.py
- rdna2spirv: %fmt_size_tab (main's typed-load size table) registers its length and entry constants when a load
first uses it; created at assembly, %c128 came after the OpTypeArray naming it and spirv-val refused
buffer_store_format_d16 modules (test_u16_high_half).
- test_vs_packed_inputs matches main's wording of the same SHADER-644 rule ("mixed component types").
- test_mutations: the v_mul_legacy_f32 anchor follows the SHADER-340 flushes (it had stopped matching on main).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed#2887 added the fixture to the M2 build; with no entry in OTHER_HARNESS the GPU suite reported it as "no checker defined". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…che entries and the render pass ones Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Merged Re-run on the merged tree, Windows 11, built with MSVC (444 targets, no errors):
Not re-run: the rest of the ctest suite and the GPU fixture suite. AI-assisted; measured on my PC. |
|
Tested dddf6aa on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Tested MSVC 14.44 build of this head (
Details that differ between the two GPUs, none of them a failure:
Every test prints Not run: anything outside this ctest pattern (no full GPU suite on this head), D24S8/D32S8 arrays (the PR says those are not fixed), other AMD GPUs. Tools: llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363.0, Python 3.11.9, AI-assisted. Synthetic test programs and counts only, no game files. Created with Perplexity |
D3D-417, claimed in the coordination issue: #3796 (comment)
Depends on: #3835
What and why
On the Radeon iGPU, a 4x D32 2D-array texture read back slice by slice (
ResolveSubresourceRegionwithMIN, then a copy) showed slice 0 for every slice: a clear of slice 0 alone came back as all four slices, a clear of slice 1 alone as none. The clear is right. The readback is wrong: the layer resolves one depth layer in a dynamic-rendering scope whose multisampled attachment view starts at that layer, and the AMD driver resolves from layer 0 of the image instead. The calls are valid Vulkan as far as the validation layers can tell (no validation or synchronization-validation message about them), and the NVIDIA driver resolves the right layer, so this is a driver workaround, not a fix of wrong calls.The workaround: a depth resolve whose source is a depth-only image and whose source layer is above 0 runs in a
VkRenderPass(VkSubpassDescriptionDepthStencilResolve) with aVkFramebufferof the same two one-layer views, instead of the rendering scope. That path gives the right layer on the AMD driver. It is taken on every GPU, so both GPUs run the same code; layer 0, which every existing test uses, keeps the rendering scope. The render pass is cached by what it describes (format, sample count, the two layouts, the mode) and the framebuffer by its images and views; both are retired with the image, like its views (runtime/src/vulkan_backend.h). Layouts, barriers, the render area and the scratch copy around a rectangle are unchanged (runtime/src/vulkan_replay.h).Not fixed here: a depth-stencil source (D24S8, D32S8) above layer 0 still uses the rendering scope, so a 4x array of those formats is still read back as its slice 0 on that driver (measured). Its two planes can be in different layouts when the resolve is recorded, which one attachment description cannot express without knowing them, so it needs more than this change.
d3d12_view_slices_testnow reads the 4x D32 array back on the layer like every other kind (the descriptor-bytes check from #3835 is gone; it was only there because of this bug), and it has three more cases on that texture with a countedArraySize: slice 0 alone, slice 1 alone, slices 1-3.docs/d3d12_vulkan.mdrecords the driver behaviour next to the MoltenVK resolve note.Measured
A raw Vulkan program (no layer of ours), 4x
D32_SFLOATimage of 4 layers, 8x8, validation and synchronization validation on: no message about any command (one at exit, about objects the program does not destroy). AMD driver 32.0.21042.62 (Ryzen 7 9700X iGPU) against NVIDIA 610.74 (RTX 3070):vkCmdClearDepthStencilImage, aCLEARload orvkCmdClearAttachments, read withtexelFetchof every sample in a compute shadervkCmdCopyImageof the layer into a one-layer 4x image, then a rendering-scope resolve of thatvkCmdBeginRenderingwithpDepthAttachment= view {baseArrayLayer s, layerCount 1},resolveMode MIN,resolveImageView= one-layer view of the target,layerCount 1, thenvkCmdEndRendering2D, with storeSTOREinstead ofNONE, or with the whole image moved between layoutsVkFramebufferof aVkRenderPasswithVkSubpassDescriptionDepthStencilResolveThrough the layer,
d3d12_view_slices_testas changed here:ArraySize-1 read as none; slice 0 alone read as all four; slice 1 alone and slices 1-3 read as noneEach run: 24 clears on the layer, 42 on the host (same adapter and WARP), 42 out-of-range views refused. With the fix both GPUs also pass with
LEONIDA_VK_VALIDATION=1.The runs above and the two
ctestlines below were made on the branch beforemainaa2988ccwas merged into it (basef847748cplus #3835). After the merge (d2e6b31d, full rebuild):d3d12_view_slices_testagain 0 failures on both GPUs, plain and withLEONIDA_VK_VALIDATION=1, andctest -R "^d3d12_(depth_resolve|msaa_draw|view_slices|typeless_rtv|vulkan_device|copy_xfmt|resource_desc)$"7 of 7 on both. The two fullctestruns were not repeated after the merge.ctest -R "^d3d12_": 58 of 58 pass on both GPUs, the same result test by test as on #3835,d3d12_depth_resolveandd3d12_msaa_drawincluded. The other tests (ctest -E "^d3d12_"): 83 of 83 pass on both GPUs.Tested
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Each command once with
LEONIDA_VK_DEVICE=radeonand once withLEONIDA_VK_DEVICE=3070,LEONIDA_HOST_ADAPTERunset.Checklist
docs/design.md, with how it was confirmed. (Not a translator rule.)Not checked: a resolve of a rectangle from a layer above 0 (the render area and the scratch copy around it are the same code as before, but no test resolves a rectangle from such a layer);
MAXandAVERAGEthrough the render pass (onlyMINran); D16; a stencil resolve; any other AMD driver version or GPU, RADV, Wine. Depth-stencil arrays are not fixed (above). The raw Vulkan program is not part of this pull request.AI-assisted.