Skip to content

d3d12: GetCopyableFootprints aligns from BaseOffset; d3d12_vulkan_device_test passes on an RX 7600 / Windows 10 - #2498

Open
iasmitionsalvatore wants to merge 3 commits into
ItsNotRexed:mainfrom
iasmitionsalvatore:pr/footprint-base-offset
Open

iasmitionsalvatore wants to merge 3 commits into
ItsNotRexed:mainfrom
iasmitionsalvatore:pr/footprint-base-offset

Conversation

@iasmitionsalvatore

Copy link
Copy Markdown

Claimed in the coordination issue as: #2300 (comment)

What and why

Problem. GetCopyableFootprints returns the wrong offsets and total when BaseOffset is not a multiple of
D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT (512). Against the PC runtime on an RX 7600:

base 513, R8G8B8A8_UNORM 8x6x16 volume, 5 mips subresource 0 subresource 1 subresource 2
host (PC runtime) 513 25089 31233
layer before 1024 25600 31744
layer after 513 25089 31233

TotalBytes was off by the same gap. An application that sizes an upload buffer from the total and writes at the
returned offsets would write past what it allocated whenever its base is not a multiple of 512.

Cause. The layout started at BaseOffset and each subresource was aligned to 512 as an absolute address. The PC
runtime 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 base to each Offset, return the total without the base.
compare_footprints now also runs bases 513 and 2^32 + 1 next to 0 and 1024. Before the fix that gives 346
mismatching 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 GetCopyableFootprints1 wrapper, and no
runtime code passes an unaligned base. docs/d3d12_vulkan.md records the rule.

Second commit (test only). With the footprints fixed, compare_invalid_arguments stopped on this machine on one
case: R9G9B9E5_SHAREDEXP with ALLOW_RENDER_TARGET, ours S_OK, host E_INVALIDARG. The host does not advertise
D3D12_FORMAT_SUPPORT1_RENDER_TARGET for the format (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 (#1375, #1466; check_rgb9e5_resolves checks that against the
Vulkan 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_test before the later checks (the footprints among them) run:

On a host with a current runtime, every comparison touched here runs exactly as before.

Related. Independent of the open #1991 (MULTISAMPLE_QUALITY_LEVELS with TILED_RESOURCE): main already skips
the RGBA32F tiled row when the host reports 0 levels, so this test passes here without it. #1995 (merged) fixed the
d3d12_draw fence; 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 main 4947579:

  • d3d12_vulkan_device_test, hardware host: passes (exit 0). With the first commit reverted: 346 footprint
    mismatches and the test stops at footprint_mismatches. On main as is, it stops earlier, at
    new_format_round_trips (A4B4G4R4 on the host). With the first two commits and the A4B4G4R4 gate, it stopped next at
    heap_mismatches (HARDWARE_PROTECTED), which the third commit gates too.
  • d3d12_vulkan_device_test with LEONIDA_HOST_ADAPTER="Microsoft Basic Render Driver" (WARP host): passes; the
    R9G9B9E5 case and the Windows 10 gates print the same way.
  • Full ctest, 125 registered: 118 passed, 0 failed, 6 skipped, 1 disabled. Skipped: shader_library_corpus,
    bink_decode, fsr_dispatch, bvh_builder, bink_audio (no retail package) and vk_sync_validation
    (validation off). Disabled: gameinput (no SDL3).
  • Full ctest with LEONIDA_VK_VALIDATION=1 (Vulkan SDK 1.4.363.1, synchronization validation on): 119 passed,
    0 failed, 5 skipped, 1 disabled. vk_sync_validation passes, so the layer was active and catching hazards; no test
    reported a validation error, including d3d12_present, d3d12_translated_draw, d3d12_m2_textured,
    d3d12_m3_frame and d3d12_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

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not a translator change.)

iasmitionsalvatore and others added 3 commits November 22, 2026 13:54
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>
@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Independent Windows 11 build 26300 / RTX 5070 / driver 621.24 check of 750cf45. The stock d3d12_vulkan_device CTest passed against native NVIDIA D3D12. I used the local #2453 compatibility patch to build with SDK 10.0.26100.0.

I added a temporary comparison for the same 8×6×16 RGBA8 volume, asking for three subresources starting at index 1. For each of GetCopyableFootprints and GetCopyableFootprints1 (Device8), I swept all 512 offsets at 2^48 + residue, plus UINT64_MAX - 255. I compared offsets, dimensions, format, row pitches, row counts, row sizes and total bytes against the host. All 513 cases matched for both methods. At the wrap boundary both native and patched calls returned a first offset of 18446744073709551360 and a second offset of 5888.

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.

@MeNoSkills

Copy link
Copy Markdown
Contributor

Heads-up on overlap: the second commit here (the A4B4G4R4 / new_format_round_trips host comparison on a Windows 10 host) is the same test-only change as #2438, which I claimed at #2300 (comment) and opened earlier. Mine compares with the host only when CheckFeatureSupport(FORMAT_SUPPORT) succeeds and reports TEXTURE2D, so it also covers the E_INVALIDARG answer you describe, and a host that reports the format and still refuses it keeps failing. Suggestion: keep this PR to the GetCopyableFootprints fix and add Depends on: #2438, or drop that commit if #2438 lands first. Your GetCopyableFootprints base-offset finding looks separate and useful; I have not tested it. AI-assisted (Claude Code).

@towade

towade commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 750cf457 on Windows 11 26H2 (26300.10075), MSVC 19.44 Release, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, AMD Radeon RX 9070 XT (driver 32.0.32029.2010): pass.

ctest -R '^d3d12_vulkan_device$' passed with Vulkan validation enabled, including the native D3D12 comparisons at unaligned BaseOffset values.

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 R8G8B8A8_UNORM texture with BaseOffset=513, the old layer returned 1024, while native D3D12 returned 513.

Synthetic tests only. AI-assisted (Codex).

@CharlyRien

Copy link
Copy Markdown

Tested 750cf45 (merged on current main) on RTX 3090, driver 616.56, Windows 11 23H2 (22631, in-box d3d12.dll 10.0.22621.5415): fail. This is the NVIDIA/older-Windows-11 data point the PR's limitations mention. MSVC 19.44 / Ninja, Vulkan SDK 1.4.363.

What the gates fix here: new_format_round_trips now reports A4B4G4R4 render target not reported, skipped, 0 failures, and GetResourceTiling cases 2, 6 and 8 are skipped because the host refuses them. FORMAT_INFO, CheckFeatureSupport (37 queries) and FORMAT_SUPPORT (93 formats) show 0 mismatches.

What still fails: d3d12_vulkan_device stops at line 4244: argument_mismatches <= 0 on four cases where this runtime refuses and the layer accepts:

invalid arguments committed: heap flag HARDWARE_PROTECTED on a texture: ours 0x00000000, host 0x80070057
invalid arguments committed: resource flag 0x400 on a buffer: ours 0x00000000, host 0x80070057
invalid arguments committed: resource flag 0x400 on a texture: ours 0x00000000, host 0x80070057
invalid arguments descriptor heap: shader-visible 2049 samplers: ours 0x00000000, host 0x80070057
  • HARDWARE_PROTECTED is gated by +device10, but the 23H2 runtime does expose ID3D12Device10 and still refuses the flag, so that gate isn't enough here.
  • resource flag 0x400 and the 2049-sampler heap have no gate. The first is probably a flag the 22621 runtime doesn't know.
  • The 2049-sampler case may be worth checking against the spec rather than only gated. 2048 is the documented shader-visible sampler heap limit, so the layer accepting 2049 could be a real difference, not just a runtime-version one.

The format NN RT/DS: the host accepts it, this Vulkan driver can't lines (40–43, 54–59, 65) are informational here and not counted.

d3d12_typeless_rtv also fails on this runtime, at its MSAA castable CreateCommittedResource3 (line 301). That's outside this PR, but it's the same "older host runtime" class if you want to gate it too. run_gpu_tests.py: 139/185 passed, 46 skipped (wave64 on a 32-wide GPU).

AI-assisted test run.

@FaKL-Code

Copy link
Copy Markdown
Contributor

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

  • Clean configure + build of runtime/ (Visual Studio generator, RelWithDebInfo): no new warnings (same C4201/C4456/C4996 counts as main).
  • ctest -C RelWithDebInfo -j 4: 116/116 passed (loader run on its own; 7 skipped for missing inputs or optional components, gameinput disabled, as on main).
  • d3d12_vulkan_device, command_list, d3d12_com and d3d12_msaa_draw also pass with LEONIDA_VK_VALIDATION=1.
  • d3d12_vulkan_device, which includes the GetCopyableFootprints BaseOffset cases, passes against the host NVIDIA D3D12 runtime. That adds an NVIDIA/Windows 11 data point to the RX 7600/Windows 10 one in the title.

AI-assisted (Claude).

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 750cf45 (on main 4947579) on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, fresh RelWithDebInfo build:

  • d3d12_vulkan_device: passes 20 of 20 runs, and passes under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Full ctest: 125/125. No new /W4 warnings.

AI-assisted (Claude Code).

@marquezinii

Copy link
Copy Markdown
Contributor

Tested 750cf45 (on main 4947579) on RTX 5070, driver 621.24, Windows 11 26H2 (26300), MSVC 14.52 (VS Build Tools 18), RelWithDebInfo, with VK_LAYER_KHRONOS_validation on (LEONIDA_VK_VALIDATION=1): pass. Full ctest 116/116.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants