Repository navigation
Depth/stencil region resolves keep the texels around the rectangle (MoltenVK resolves the whole subresource) - #1971
Conversation
A ResolveSubresourceRegion of a depth or stencil plane runs in a rendering scope whose render area is the source rectangle, and Vulkan resolves only inside it. MoltenVK (1.4.2 and 1.4.3) resolves the whole destination subresource: it resolves through Metal's store action, which has no render area. d3d12_depth_resolve failed its eight MIN/MAX rectangle cases under Wine on an M3 Max for that reason. The texels around the rectangle now go into copy_scratch before the scope and back after it, in up to four bands, on every GPU: no device property reports the behaviour. vk_command_replay_test part I resolves a D32 rectangle natively and checks the texels around it; it failed on MoltenVK before this change (all 28 overwritten) and passes on MoltenVK and KosmicKrisp, with no validation errors on KosmicKrisp. AI-assisted.
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression from this PR. RTX 4080 SUPER: 111/113 pass. On current |
|
Tested
|
|
Tested ef4d305 natively on Windows with NVIDIA and AMD: pass, no regressions, no validation errors. This covers the "not run: native Windows" row in the description. Setup: Windows 11 Pro 10.0.26300, MSVC 19.44.35230 (VS 2022 Build Tools), Vulkan SDK 1.4.363.0,
On these drivers the resolve already honours the render area, so the extra band copies only preserve texels that were never at risk, as the description says. The cost is two transfers per partial depth/stencil resolve. AI-assisted (Claude Code). |
|
Tested ef4d305 on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo): pass.
AI-assisted (Claude Code). |
|
Filed upstream: KhronosGroup/MoltenVK#2919. |
Claimed in the coordination issue as: item 1 of #1745 (comment) (
d3d12_depth_resolveon a Mac under Wine)What and why
On a Mac,
d3d12_depth_resolvefailed every "rect 1" MIN/MAX case (8 of them, depth and plane formats) withdestination differs from the clears.The layer replays a depth or stencil
ResolveSubresourceRegionas an empty dynamic-rendering block, with the destination as the resolve attachment andrenderAreaset to the source rectangle (runtime/src/vulkan_replay.h). Vulkan limits a render pass's resolve to the render area. MoltenVK resolves through Metal's store action (MTLStoreActionMultisampleResolve/StoreAndMultisampleResolve,MVKAttachmentDescription::getMTLStoreAction), which has no render area, so it overwrites the whole destination subresource.Native reproduction, plain Vulkan on arm64: a 4x D32 source, an 8×6 destination, render area (2,1) of size 5×4.
NONEandSTORE, and for 2D and 2D_ARRAY views.I re-ran the repro: MoltenVK
28 texels outside the render area written: FAIL, KosmicKrisp0 … ok.The fix is
keep_around_resolveinvulkan_replay.h. When the rectangle is smaller than the subresource, the texels around it (up to four bands) are copied tocopy_scratchbefore the resolve and back after it, with the transitions and barriers of the existinground_trip. No Vulkan property reports this behaviour and MoltenVK doesn't document it, so the path runs on every device rather than on a vendor check. On conformant drivers it costs two extra transfer copies, only for region resolves of depth/stencil. If reviewers prefer a gate, the only option isdriverID == VK_DRIVER_ID_MOLTENVK.docs/d3d12_vulkan.mddescribes it, with the measurements.Native test: part I of
vk_command_replay_testis a 4x D32 MIN resolve of a 5×4 rectangle through the replay. The 28 texels around it must be kept, and a list withoutcopy_scratchmust be refused.Tested
Apple M3 Max, macOS 27.3.
vk_command_replay_testpart I, MoltenVK 1.4.2 / 1.4.3 (direct load)d3d12_depth_resolveunder Wine 11.0 (CrossOver 26.3's loader) + MoltenVK 1.4.3run_wine_tests.pylist (114 tests), main 6a6704d vs branchIn the full list only
d3d12_depth_resolvechanged. The Windows build is cross-compiled with clang-cl 23.1.6, lld-link 22.1.8 and the xwin 10.0.26100 SDK.ctest(runtime/build/mac): 35/36.xdxr_build_checkfails on plainmaintoo.vk_test_devicedoesn't create a MoltenVK device through the loader, onmaineither.vkCmdResolveImage, so they don't take this path.A ready-to-file MoltenVK report (repro source, outputs, and the suggestion to resolve only the area through the
resolveUnresolvableAttachmentspath) is prepared and will be linked here once filed.No game files. AI-assisted.
Checklist
docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code