Repository navigation
Native D3D12: opt-in answers for a consistent feature level 12_0 survey - #165
Merged
Merged
Conversation
Branch: `pr/d3d12-fl12-caps` (one commit, on `main`). ## Problem GTA V Enhanced creates its D3D12 devices, runs a `CheckFeatureSupport` survey, destroys the device and shows `ERR_GFX_D3D_NOD3D12`: "Failed to initialize DirectX 12 adapter ... supports DirectX 12 (feature level 12_0)". No call is refused; the verdict comes from the answers. ## Cause The runtime claims feature level 12_0, but several answers contradict it: - `OPTIONS.TiledResourcesTier` is 0. Windows requires Tier 2 for 12_0, and the runtime has no reserved resources (the `CreateReservedResource*`, `GetResourceTiling` and tile-mapping methods are generated stubs). - `OPTIONS.MaxGPUVirtualAddressBitsPerResource` is 0, while `GPU_VIRTUAL_ADDRESS_SUPPORT` says 40. - `FORMAT_SUPPORT` fails for `R32G32B32_FLOAT/UINT/SINT`. Every 11_0+ device takes them as vertex formats, and so do this runtime's input layouts. - `MULTISAMPLE_QUALITY_LEVELS` has no 8x for `R8G8B8A8_UNORM` (Apple GPUs stop at 4x). This was the game's last read on its real device before it gave up. - `ARCHITECTURE.TileBasedRenderer` is TRUE. Desktop GPUs and vkd3d-proton say FALSE. ## Change `madeira-d3d12/src/pe/madeira_d3d12.c`, three madeira.cfg keys, all **off by default**. Without them every answer and every method is unchanged. - **`d3d12-tiled-resources = 1`:** - `OPTIONS` reports `TiledResourcesTier` 2 and 40 address bits per resource. - `FORMAT_SUPPORT` gives the three R32G32B32 formats `IA_VERTEX_BUFFER`, and nothing else: Metal has no 96-bit texture format. - `CreateReservedResource` / `1` / `2` create the resource **fully backed**, exactly like a committed resource in a DEFAULT heap. - `d3d12-reserved-max-mb` (default 1024) refuses larger ones with `E_OUTOFMEMORY` before anything is allocated. A NULL `out` returns `S_FALSE`, the documented capability test. - `GetResourceTiling` answers D3D12's standard tiling: 64 KB tiles, the standard 2D/3D/BC/MSAA shapes, Tier 2 mip packing, and packed mips per array slice. - `UpdateTileMappings` / `CopyTileMappings` are no-ops, because every tile is backed. - **`d3d12-msaa8 = 1`:** 8x reports one quality level. Resources and pipelines still go through `mad_clamp_sample_count`, so 8x renders at 4x and the answer never reaches Metal. - **`d3d12-tile-based = 0`:** `ARCHITECTURE` / `ARCHITECTURE1` report `TileBasedRenderer` FALSE. Also in this PR: - One `[d3d12-caps]` line when a key is on, and bounded `[d3d12-tiled]` lines for refused reserved resources, in the style of the existing ml1970 line. - New host test `tests/host/check-d3d12-tiled.py`. It checks the static wiring: each key defaults off, each method falls back to its stub, and everything is in the vtables. It also compiles the tiling code on the host and checks it against D3D12's tables: tile shapes, Tier 2 packing, array slices, buffers, and the formats with no tiling. - Catalog regenerated (four new keys). ## Evidence From the fork, GTA V Enhanced on an iPhone 17 Pro Max (iOS 27): - **Each key took effect.** The `[d3d12-caps]` survey trace showed `OPTIONS` byte 12 = 02 and byte 36 = 0x28, the R32G32B32 formats leaving the failure list, 8x answering 1, and `TileBasedRenderer` 0. - **With all of them**, plus typed UAV loads, DXGI `IDXGIFactory7`, the Agility SDK layout (`d3d12-core-dll`), the D3DKMT adapter and NVAPI driver 581.57, the game created a third device, kept it, and played its intro video. - **What was not isolated:** each of these answers removed one contradiction the game's survey could see, but which of them were *necessary* was not tested. That is why they stay opt-in and game-specific. - **Other games:** Ghost of Tsushima and God of War run without the keys, unchanged. ## Notes / risks - **Reserved resources are not real Tier 2.** A tile the application never mapped reads what the backing holds, not zeros, and costs its full memory. Real residency could later come from Metal sparse textures or Metal 4 placement sparse heaps. - **No per-game config file upstream.** The fork set these keys in GTA's own config file. In willfaust/Madeira madeira.cfg is global, so while testing GTA the keys apply to every game. A library-entry option may be wanted later. - **Not ported:** - the fork's `d3d12-raytracing-tier` experiment, which reported DXR with nothing behind it; - the `d3d12-caps-log` survey trace. The DXR switch was on in the passing run but did not help on its own (the box stayed with it on), and a DXR claim without DXR is not something to offer upstream. - **Needs a rebuild** of `arm64ec-windows/madeira_d3d12.dll` / `d3d12.dll` (`build/madeira-d3d12/build-pe.sh`). Checked: arm64ec `-c -O2 -Wall` with llvm-mingw 20260421, no new warnings; `check-d3d12-tiled.py` PASS. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0189oLHghpaYKLk4f786a6bc Signed-off-by: bahacan16 <190844990+bahacan16@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch:
pr/d3d12-fl12-caps(one commit, onmain).Problem
GTA V Enhanced creates its D3D12 devices, runs a
CheckFeatureSupportsurvey, destroys the device and showsERR_GFX_D3D_NOD3D12: "Failed to initialize DirectX 12 adapter ... supports DirectX 12 (feature level 12_0)". No call is refused; the verdict comes from the answers.Cause
The runtime claims feature level 12_0, but several answers contradict it:
OPTIONS.TiledResourcesTieris 0. Windows requires Tier 2 for 12_0, and the runtime has no reserved resources (theCreateReservedResource*,GetResourceTilingand tile-mapping methods are generated stubs).OPTIONS.MaxGPUVirtualAddressBitsPerResourceis 0, whileGPU_VIRTUAL_ADDRESS_SUPPORTsays 40.FORMAT_SUPPORTfails forR32G32B32_FLOAT/UINT/SINT. Every 11_0+ device takes them as vertex formats, and so do this runtime's input layouts.MULTISAMPLE_QUALITY_LEVELShas no 8x forR8G8B8A8_UNORM(Apple GPUs stop at 4x). This was the game's last read on its real device before it gave up.ARCHITECTURE.TileBasedRendereris TRUE. Desktop GPUs and vkd3d-proton say FALSE.Change
madeira-d3d12/src/pe/madeira_d3d12.c, three madeira.cfg keys, all off by default. Without them every answer and every method is unchanged.d3d12-tiled-resources = 1:OPTIONSreportsTiledResourcesTier2 and 40 address bits per resource.FORMAT_SUPPORTgives the three R32G32B32 formatsIA_VERTEX_BUFFER, and nothing else: Metal has no 96-bit texture format.CreateReservedResource/1/2create the resource fully backed, exactly like a committed resource in a DEFAULT heap.d3d12-reserved-max-mb(default 1024) refuses larger ones withE_OUTOFMEMORYbefore anything is allocated. A NULLoutreturnsS_FALSE, the documented capability test.GetResourceTilinganswers D3D12's standard tiling: 64 KB tiles, the standard 2D/3D/BC/MSAA shapes, Tier 2 mip packing, and packed mips per array slice.UpdateTileMappings/CopyTileMappingsare no-ops, because every tile is backed.d3d12-msaa8 = 1: 8x reports one quality level. Resources and pipelines still go throughmad_clamp_sample_count, so 8x renders at 4x and the answer never reaches Metal.d3d12-tile-based = 0:ARCHITECTURE/ARCHITECTURE1reportTileBasedRendererFALSE.Also in this PR:
[d3d12-caps]line when a key is on, and bounded[d3d12-tiled]lines for refused reserved resources, in the style of the existing ml1970 line.tests/host/check-d3d12-tiled.py. It checks the static wiring: each key defaults off, each method falls back to its stub, and everything is in the vtables. It also compiles the tiling code on the host and checks it against D3D12's tables: tile shapes, Tier 2 packing, array slices, buffers, and the formats with no tiling.Evidence
From the fork, GTA V Enhanced on an iPhone 17 Pro Max (iOS 27):
[d3d12-caps]survey trace showedOPTIONSbyte 12 = 02 and byte 36 = 0x28, the R32G32B32 formats leaving the failure list, 8x answering 1, andTileBasedRenderer0.IDXGIFactory7, the Agility SDK layout (d3d12-core-dll), the D3DKMT adapter and NVAPI driver 581.57, the game created a third device, kept it, and played its intro video.Notes / risks
Reserved resources are not real Tier 2. A tile the application never mapped reads what the backing holds, not zeros, and costs its full memory. Real residency could later come from Metal sparse textures or Metal 4 placement sparse heaps.
No per-game config file upstream. The fork set these keys in GTA's own config file. In willfaust/Madeira madeira.cfg is global, so while testing GTA the keys apply to every game. A library-entry option may be wanted later.
Not ported:
d3d12-raytracing-tierexperiment, which reported DXR with nothing behind it;d3d12-caps-logsurvey trace.The DXR switch was on in the passing run but did not help on its own (the box stayed with it on), and a DXR claim without DXR is not something to offer upstream.
Needs a rebuild of
arm64ec-windows/madeira_d3d12.dll/d3d12.dll(build/madeira-d3d12/build-pe.sh). Checked: arm64ec-c -O2 -Wallwith llvm-mingw 20260421, no new warnings;check-d3d12-tiled.pyPASS.🤖 Generated with Claude Code
Claude-Session: https://claude.ai/code/session_0189oLHghpaYKLk4f786a6bc