Skip to content

Native D3D12: opt-in answers for a consistent feature level 12_0 survey - #165

Merged
willfaust merged 1 commit into
willfaust:mainfrom
bahacan16:pr/d3d12-fl12-caps
Oct 4, 2026
Merged

willfaust merged 1 commit into
willfaust:mainfrom
bahacan16:pr/d3d12-fl12-caps

Conversation

@bahacan16

Copy link
Copy Markdown
Contributor

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

Claude-Session: https://claude.ai/code/session_0189oLHghpaYKLk4f786a6bc

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>
willfaust pushed a commit that referenced this pull request Oct 4, 2026
…ey (#165)

Squashed from #165.

Signed-off-by: bahacan16 <190844990+bahacan16@users.noreply.github.com>
willfaust added a commit that referenced this pull request Oct 4, 2026
d3d12.dll and madeira_d3d12.dll rebuilt from #138, #139, #152-#159, #165,
#166 and the fixes on top; d3d12core.dll (#166) is new and is used only
with madeira.cfg d3d12-core-dll = 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willfaust willfaust closed this Oct 4, 2026
@willfaust willfaust reopened this Oct 4, 2026
@willfaust
willfaust merged commit a70caf9 into willfaust:main Oct 4, 2026
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.

3 participants