Repository navigation
d3d12: GetCopyableFootprints aligns from BaseOffset; d3d12_vulkan_device_test passes on an RX 7600 / Windows 10 - #2498
Conversation
GetCopyableFootprints started the layout at BaseOffset and aligned every subresource to D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT as an absolute address. The PC runtime lays the subresources out from 0 and adds the base afterwards: with base 513 the host returns offset 513 for subresource 0, ours returned 1024, and the totals differed by the gap. compare_footprints now also runs bases 513 and 2^32 + 1 (both unaligned) next to 0 and 1024. Against the hardware host device on an AMD Radeon RX 7600 the old code gives 346 mismatching fields (offsets and totals), all at the two new bases: with only 0 and 1024 it gives none, which is why this went unnoticed. With the fix there are none at any base. No caller in the runtime passes an unaligned base (the only internal caller is GetCopyableFootprints1). AI-assisted. Tested on AMD Radeon RX 7600, drivers 26.11.1 and 26.11.2 (LLPC), Windows 10 22H2 (in-box d3d12core 10.0.19041.5794), MSVC 14.44. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On an AMD Radeon RX 7600 (driver 26.11.2) d3d12_vulkan_device_test stopped at argument_mismatches on one case: format 67 RT, ours S_OK, host E_INVALIDARG. The host does not advertise D3D12_FORMAT_SUPPORT1_RENDER_TARGET for R9G9B9E5_SHAREDEXP (Support1 0x008013f0, measured with a standalone D3D12 program) and refuses the flag; WARP on the same Windows 10 runtime answers the same. The layer offers R9G9B9E5 render targets when its Vulkan device can make the attachment (ItsNotRexed#1375, ItsNotRexed#1466; check_rgb9e5_resolves checks that against the Vulkan sample counts), so the two can't agree on every host, as for R32G32B32. That one case is now printed instead of counted when the host does not advertise RENDER_TARGET for the format and ours does. A layer that created an R9G9B9E5 render target without advertising it is still a mismatch, and every other format and flag is compared as before. AI-assisted. Tested on AMD Radeon RX 7600, driver 26.11.2 (LLPC), Windows 10 22H2, MSVC 14.44, against the hardware host and against WARP (LEONIDA_HOST_ADAPTER): d3d12_vulkan_device passes on both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two checks merged after ItsNotRexed#1737 compare with the host without its gate, and on a Windows 10 host (in-box d3d12core 10.0.19041.5794, an AMD Radeon RX 7600 with driver 26.11.2) each stops d3d12_vulkan_device_test before the later checks run: - new_format_round_trips (D3D-259, ItsNotRexed#1914) creates every new format on the host as well. That runtime does not know A4B4G4R4_UNORM: FORMAT_SUPPORT answers E_INVALIDARG and the texture is refused. The host creation is now compared only when the host's FORMAT_SUPPORT reports TEXTURE2D for the format, as the render-target clears in the same function already ask the host first. The layer's own creation, footprint and copy checks still run for every format. - compare_heap_neighbours (D3D-238, ItsNotRexed#1820) expects the host to accept a HARDWARE_PROTECTED heap. The same runtime refuses it, as it refuses HARDWARE_PROTECTED on a committed texture, which compare_invalid_arguments already compares only on a host with ID3D12Device10. The heap case now takes the same gate. On a host with a current runtime both are compared exactly as before. AI-assisted. Tested on AMD Radeon RX 7600, driver 26.11.2 (LLPC), Windows 10 22H2, MSVC 14.44: d3d12_vulkan_device passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows 11 build 26300 / RTX 5070 / driver 621.24 check of 750cf45. The stock I added a temporary comparison for the same 8×6×16 RGBA8 volume, asking for three subresources starting at index 1. For each of Reversing only the footprint implementation hunk left the same test running and produced 512/513 mismatches per method. Only residue zero matched. The CTest then failed at the expected footprint gate. I restored the temporary compatibility, probe, and reversal changes. Synthetic descriptors only. AI-assisted review. |
|
Heads-up on overlap: the second commit here (the A4B4G4R4 / |
|
Tested
In a separate build I kept the PR tests and restored the old runtime implementation. The footprint comparison failed as expected: for the first subresource of the 8×6×16 Synthetic tests only. AI-assisted (Codex). |
|
Tested 750cf45 (merged on current main) on RTX 3090, driver 616.56, Windows 11 23H2 (22631, in-box What the gates fix here: What still fails:
The
AI-assisted test run. |
|
Tested 750cf45 (merged onto main 4947579) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass
AI-assisted (Claude). |
|
Tested 750cf45 (on
AI-assisted (Claude Code). |
Claimed in the coordination issue as: #2300 (comment)
What and why
Problem.
GetCopyableFootprintsreturns the wrong offsets and total whenBaseOffsetis not a multiple ofD3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT(512). Against the PC runtime on an RX 7600:TotalByteswas off by the same gap. An application that sizes an upload buffer from the total and writes at thereturned offsets would write past what it allocated whenever its base is not a multiple of 512.
Cause. The layout started at
BaseOffsetand each subresource was aligned to 512 as an absolute address. The PCruntime lays the subresources out from 0 and adds the base afterwards, so the whole layout moves by the base and the
total does not depend on it.
Fix (first commit). Lay out from 0, add
baseto eachOffset, return the total without the base.compare_footprintsnow also runs bases 513 and 2^32 + 1 next to 0 and 1024. Before the fix that gives 346mismatching fields (offsets and totals) over its cases, all at the two new bases; with only 0 and 1024 the old code
gives none, which is why this went unnoticed. The only internal caller is the
GetCopyableFootprints1wrapper, and noruntime code passes an unaligned base.
docs/d3d12_vulkan.mdrecords the rule.Second commit (test only). With the footprints fixed,
compare_invalid_argumentsstopped on this machine on onecase:
R9G9B9E5_SHAREDEXPwithALLOW_RENDER_TARGET, oursS_OK, hostE_INVALIDARG. The host does not advertiseD3D12_FORMAT_SUPPORT1_RENDER_TARGETfor the format (Support10x008013f0, measured with a standalone D3D12program) and refuses the flag; WARP on the same Windows 10 runtime answers the same. The layer offers R9G9B9E5 render
targets when its Vulkan device can make the attachment (#1375, #1466;
check_rgb9e5_resolveschecks that against theVulkan sample counts), so the answers can't agree on every host, as for R32G32B32. That one case is now printed, not
counted, only when the host does not advertise RENDER_TARGET for the format and ours does. A layer that created one
without advertising it is still a mismatch, and every other format and flag is compared as before.
Third commit (test only). Two checks merged after #1737 compare with the host without its gate, and on a Windows 10
host each stops
d3d12_vulkan_device_testbefore the later checks (the footprints among them) run:new_format_round_trips(D3D-259, d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates (D3D-259) #1914): the Windows 10 runtime does not knowA4B4G4R4_UNORM(FORMAT_SUPPORTanswers
E_INVALIDARG) and refuses the texture. The host creation is now compared only when the host'sFORMAT_SUPPORT reports
TEXTURE2D, as the render-target clears in the same function already ask the host first. Thelayer's own creation, footprint and copy checks still run for every format.
compare_heap_neighbours(D3D-238, D3D-238: refuse the heap descriptions the host refuses in CreateHeap/CreateHeap1 #1820): the same runtime refuses aHARDWARE_PROTECTEDheap, as it refusesHARDWARE_PROTECTEDon a committed texture, whichcompare_invalid_argumentsalready compares only on a host withID3D12Device10(d3d12_vulkan_device_test: skip invalid-argument cases a Windows 10 or elevated host can't compare #1737). The heap case takes the same gate.On a host with a current runtime, every comparison touched here runs exactly as before.
Related. Independent of the open #1991 (
MULTISAMPLE_QUALITY_LEVELSwithTILED_RESOURCE): main already skipsthe RGBA32F tiled row when the host reports 0 levels, so this test passes here without it. #1995 (merged) fixed the
d3d12_drawfence; on this machine it was 10 of 10 failures before and 0 of 10 after.Tested
AMD Radeon RX 7600 (gfx1102, 8 GB, no Resizable BAR), driver 26.11.2 (32.0.32029.2010, LLPC, Vulkan 1.4.359),
Windows 10 22H2 (19045, in-box d3d12core 10.0.19041.5794), Ryzen 5 5600, MSVC 14.44, Ninja, RelWithDebInfo;
llvm-mc 21.1.8 (AMDGPU), SPIRV-Tools v2026.4, glslang 16.6.0, Vulkan SDK 1.4.363.1. On
main4947579:d3d12_vulkan_device_test, hardware host: passes (exit 0). With the first commit reverted: 346 footprintmismatches and the test stops at
footprint_mismatches. Onmainas is, it stops earlier, atnew_format_round_trips(A4B4G4R4 on the host). With the first two commits and the A4B4G4R4 gate, it stopped next atheap_mismatches(HARDWARE_PROTECTED), which the third commit gates too.d3d12_vulkan_device_testwithLEONIDA_HOST_ADAPTER="Microsoft Basic Render Driver"(WARP host): passes; theR9G9B9E5 case and the Windows 10 gates print the same way.
shader_library_corpus,bink_decode,fsr_dispatch,bvh_builder,bink_audio(no retail package) andvk_sync_validation(validation off). Disabled:
gameinput(no SDL3).LEONIDA_VK_VALIDATION=1(Vulkan SDK 1.4.363.1, synchronization validation on): 119 passed,0 failed, 5 skipped, 1 disabled.
vk_sync_validationpasses, so the layer was active and catching hazards; no testreported a validation error, including
d3d12_present,d3d12_translated_draw,d3d12_m2_textured,d3d12_m3_frameandd3d12_subgroup.Limitations. One GPU (AMD) and one host runtime (Windows 10 in-box); not run on an NVIDIA or Intel GPU or on a
Windows 11 host here, where the gated comparisons run as before. Whether the R9G9B9E5 refusal comes from the driver or
from the Windows 10 runtime is not settled (both hosts measured run that runtime); the test follows what the host
advertises either way. Tests that need the retail package were skipped, as designed.
AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed. (Not a translator change.)