Skip to content

dxgi: the title's output answers in the console's slot order (slot 21 is GetDisplayModeList1) - #7937

Open
ASTROWwwW wants to merge 1 commit into
ItsNotRexed:mainfrom
ASTROWwwW:fix/xs-output-slot21
Open

ASTROWwwW wants to merge 1 commit into
ItsNotRexed:mainfrom
ASTROWwwW:fix/xs-output-slot21

Conversation

@ASTROWwwW

Copy link
Copy Markdown

Claimed in the coordination issue as: #7694 (comment) (new D3D item, the console IDXGIOutput slot order)

Depends on: none. Touches the slot #7619 serves (see below).

What and why

A GDKX title finds its output through IDXGIDevice1::GetAdapter and EnumOutputs(0). It then calls output slot 21 twice, the count and then the fill, with DXGI_FORMAT_UNKNOWN, flags 0 and a DXGI_MODE_DESC1 array, and scans the refresh rates. Two independent reads of the retail executable put GetDisplayModeList1 at slot 21 on the console, two slots after the PC order (YaBulochka: #7154 (comment), FJKiXfaR: #7154 (comment)). The layer's Output answers slot 21 as GetDisplaySurfaceData1, which returns DXGI_ERROR_INVALID_CALL. The boot breaks right after that on Wine (lunarminus) and Proton (samarslan). On Proton, serving slot 21 as a display-mode query carried the boot on to device slot 133 (samarslan, #7154 (comment)).

The change:

  • dxgi_com.cpp: a ConsoleOutput in the console order. Slots 0-18 forward to the layer's Output (the public IDXGIOutput order). Slot 21 is GetDisplayModeList1. Slots 19, 20 and 22-39 are not measured: each says so once on stderr and returns E_NOTIMPL. Its QueryInterface stops at IDXGIOutput, since the PC's IDXGIOutput1+ chain is another order; per the executable the title never asks for it.
  • DXGI_FORMAT_UNKNOWN lists the desktop's B8G8R8A8_UNORM modes. ASSUMPTION: the console lists its modes for any format there. The PC answers 0 modes, which the title would also accept: it then keeps 60 Hz.
  • Only the adapter the Vulkan device hands out through IDXGIDevice1::GetAdapter gives console outputs (rt::dxgi::hand_out_console_outputs, found through a private QI tag). The factory's adapters, which PC code such as the swap chain uses, are unchanged. On the host D3D12 backend the title gets the host's adapter and outputs, which this does not touch (FJKiXfaR's comment explains why Windows runs don't see this stop).

@bitzin-dev: #7619 serves GetDisplaySurfaceData1 on the PC Output. That is fine for PC callers, but it is not what the title reaches at slot 21.

Tested

Windows 11 Pro 26300, MSVC 2022 BuildTools, RelWithDebInfo, Vulkan headers 1.4 (LEONIDA_VULKAN_HEADERS_FETCH), RTX 5080, NVIDIA driver from the RTX 50 series. No game files.

  • dxgi_device_test: the Vulkan backend walks the title's path (QueryInterface(IDXGIDevice1), GetAdapter, EnumOutputs(0)) and calls slot 21 raw, the count then the fill: 103 modes. It also checks that slots 19, 20 and 22 return E_NOTIMPL, that GetDesc is still the PC slot, and that QueryInterface(IDXGIOutput1) is refused. On main it fails at the slot 21 count call. 3 backends pass (WARP, the host hardware adapter, Vulkan).
  • Full ctest: 235/237. The two failures, d3d12_vulkan_device and d3d12_depth_resolve, fail the same way on main on this machine.
  • python -I scripts/check_no_game_data.py on the four files: clean.

Not measured: a retail run (no package here). @lunarminus @samarslan, one Wine or Proton run on the ladder would settle it.

AI-assisted: yes (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. (no translator change)

🤖 Generated with Claude Code

… is GetDisplayModeList1)

A GDKX title finds its output through IDXGIDevice1::GetAdapter and
EnumOutputs(0), then calls output slot 21 twice (count, then fill) with
DXGI_FORMAT_UNKNOWN and a DXGI_MODE_DESC1 array, and scans the refresh
rates. Two independent reads of the retail executable (ItsNotRexed#7154) put
GetDisplayModeList1 at slot 21 on the console, two slots after the PC
order. The layer's Output answered it as GetDisplaySurfaceData1
(DXGI_ERROR_INVALID_CALL), and the boot breaks right after on Wine and
Proton.

The adapter the Vulkan device hands out through IDXGIDevice1::GetAdapter
now gives ConsoleOutputs: slots 0-18 forward to the layer's Output, 21 is
GetDisplayModeList1 (DXGI_FORMAT_UNKNOWN listed as the desktop format), and
19, 20 and 22-39 are unmeasured, say so once and return E_NOTIMPL. The
factory's own adapters, which PC code uses, are unchanged.

dxgi_device_test: the Vulkan backend calls slot 21 raw as the title does
(103 modes on an RTX 5080); it fails on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASTROWwwW

Copy link
Copy Markdown
Author

Correction to the description: output slot 21 is not the boot stop on Wine. lunarminus answered slot 21 as GetDisplayModeList1 and the boot broke at the same place (#7154 (comment)). When the call fails, the title just releases the output and goes on. The stop was the physical-page view protection, which #7492 / #7550 clear (DCHoaxer, #7154 (comment)). I missed lunarminus's correction when I wrote this.

What this PR still does: it gives the title the console's slot order, so its count-and-fill mode query succeeds and its 120 Hz check sees the real modes. Without it, the query fails and the title keeps 60 Hz. That's a correctness fix with no stop behind it, so the priority is the maintainers' call.

@nullmarsh

Copy link
Copy Markdown

Tested bbc96d0f natively on Windows 11 26200, MSVC 14.44, RX 9060 XT (AMD 26.11.2), with a real monitor on the AMD output: pass. dxgi_device, dxgi_swapchain and dxgi_swapchain_count: 3/3. dxgi_device prints the title's output answers console slot 21 (GetDisplayModeList1): 202 modes, and slots 19, 20 and 22 log their not measured; returning E_NOTIMPL once each.

AI-assisted (Claude Code), no game files.

@Envyre

Envyre commented Nov 23, 2026

Copy link
Copy Markdown

Code read of bbc96d0: the console-order output holds up.

  • Slot 21 (runtime/shims/dxgi_com.cpp:1130) has GetDisplayModeList1's shape under the x64 ABI (this, fmt, flags, count, modes on the stack) and maps DXGI_FORMAT_UNKNOWN to B8G8R8A8_UNORM, which fill_mode_list (:814) accepts.
  • Slots 19, 20 and 22-39 (:1127-1146) log once and return E_NOTIMPL; none falls through to a PC method.
  • The wrapper owns the one reference to the inner Output and releases it in the destructor (:1150); GetParent returns the same console-order adapter; QueryInterface answers only IUnknown / IDXGIObject / IDXGIOutput (:1078), whose slots 0-18 match in both orders, so refusing IDXGIOutput1 is right.
  • EnumAdapters builds a fresh Adapter per call (:1506), so the factory's own adapters stay in PC order.

Requests:

  1. docs/d3d12_vulkan.md:2890 and :3859 still say vtable slots aren't measured; worth recording the console IDXGIOutput order (19-20 console-only, 21 GetDisplayModeList1) with the Boot log for coding agents: where the executable stops and which PRs get past it #7154 citation and the DXGI_FORMAT_UNKNOWN assumption.
  2. The new block in runtime/test/dxgi_device_test.cpp:144 is skipped without an output (headless CI) and doesn't check that factory->EnumAdapters(0)->EnumOutputs(0) stays PC order, that AddRef/Release balance, or that GetParent -> EnumOutputs round-trips to a console-order output.
  3. On the host backend the title still gets the host adapter, where slot 21 is GetDisplaySurfaceData1; worth noting as a known gap.

AI-assisted (Claude Code).

@hah346

hah346 commented Nov 23, 2026

Copy link
Copy Markdown

Independently tested bbc96d0 on Windows build 26300, MSVC 19.51, RTX 2060 (NVIDIA 616.64), with Khronos Vulkan validation. dxgi_device, dxgi_swapchain and dxgi_swapchain_count passed. Vulkan console output slot 21 returned 126 modes on the count/fill probe, and all three backends passed.

I also locally combined this head with #6672 at 895579f. The merge was clean. All five focused tests passed: the same three DXGI tests, vk_queue_present_order and vk_sync_validation. The swapchain test confirmed that an independent Vulkan queue can submit while Present waits on its blit fence, with zero validation errors. Synthetic fixtures only. AI-assisted.

@VibeClauding

Copy link
Copy Markdown

Tested bbc96d0fd merged into main dde82f27e on Windows 11 26200, MSVC 14.44 RelWithDebInfo, RTX 3070 (NVIDIA 610.88), Vulkan SDK 1.4.363, no game files: pass.

  • dxgi_device, dxgi_swapchain, dxgi_swapchain_count: 3/3. dxgi_device prints the title's output answers console slot 21 (GetDisplayModeList1): 140 modes; slots 19, 20 and 22 log once each.
  • Full ctest: 268/272, the same as main on this machine. The same 4 fail on both (d3d12_vulkan_device, d3d12_depth_resolve, d3d12_indirect_dispatch_count, d3d12_indirect_rt), and they fail again when rerun serially.
  • Negative control: this PR's dxgi_device_test.cpp built against main's dxgi_com.cpp/.h and d3d12_vulkan_device.cpp fails at line 149 (the slot 21 count call), so the test catches the bug.
  • Nit: MSVC C4456 at dxgi_device_test.cpp:160. The new DXGI_OUTPUT_DESC desc shadows an earlier local.

AI-assisted (Claude Code).

VibeClauding added a commit to VibeClauding/Leonida that referenced this pull request Nov 23, 2026
…und-trips

Covers the gaps from the ItsNotRexed#7937 code read:
- factory->EnumAdapters(0)->EnumOutputs(0) still answers IDXGIOutput1, and
  GetDisplayModeList1 gives the same mode count as console slot 21.
- ConsoleOutput's AddRef/Release balance.
- output->GetParent -> EnumOutputs(0) is console-order again (IDXGIOutput1
  refused, slot 21 gives the same count).
Also renames the block's `desc` (MSVC C4456: it shadowed an earlier local).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VibeClauding

Copy link
Copy Markdown

@ASTROWwwW, for point 2 of Envyre's code read: test-only commit on top of bbc96d0fd, ready to cherry-pick: 9dd94e9fa (branch VibeClauding:pr7937-tests, +41/-3 in dxgi_device_test.cpp only).

It adds three checks to the Vulkan block:

  • The factory's own adapters stay PC-order. adapter->GetParent(IDXGIFactory1)->EnumAdapters(0)->EnumOutputs(0) answers IDXGIOutput1, and its GetDisplayModeList1(B8G8R8A8_UNORM) gives the same count as console slot 21.
  • AddRef/Release balance on the console output (2, then 1).
  • The round trip: output->GetParent(IDXGIAdapter) has the device's LUID, and its EnumOutputs(0) is console-order again (IDXGIOutput1 refused, slot 21 gives the same count).

It also renames the block's desc to output_desc, which fixes the C4456 from my test above.

RTX 3070 / 610.88, MSVC 14.44: dxgi_device passes (3 backends), and the build has no new warnings. Mutation check: setting console_outputs_ = true for every adapter fails the new check at the factory output's IDXGIOutput1 line, so it catches a change that leaks into PC callers.

Envyre's other point still stands: like the rest of the block, these checks are skipped when there's no output (headless CI).

AI-assisted (Claude Code).

@NolanCotter

Copy link
Copy Markdown
Contributor

Reviewed on its head (clang-cl 20 + xwin cross-build):

Correctness reads clean:

  • ConsoleOutput's vtable lays out 0-18 exactly as IDXGIOutput's (QI/AddRef/Release, 3-6 IDXGIObject, 7-18 output methods) with 21 = GetDisplayModeList1 — matches the two independent reads you cite.
  • Refcount chain balances: EnumOutputs hands the Output's sole ref to ConsoleOutput, whose destructor releases it; the kLayerAdapterTag QI AddRef/Release pair is balanced in hand_out_console_outputs.
  • Only the GetAdapter-derived adapter gets flagged — a title reaching an adapter through EnumAdapters directly still gets PC order. Right boundary.
  • QI stopping at IDXGIOutput is correct since the console chain diverges; DXGI_FORMAT_UNKNOWN→B8G8R8A8_UNORM is a fair documented assumption (title keeps 60 Hz either way).

Test limits here: dxgi_device_test compiles clean but SKIPped under headless Wine (no Vulkan device), so I couldn't exercise the slot-21 path — a native/Vulkan run still needed for the new assertions. xs_proxy_mock_test PASS.

AI-assisted (Devin); no game files used.

@LooperSalty

Copy link
Copy Markdown

Tested bbc96d0f on Windows 11 26300, RTX 4070 SUPER (driver 610.88), MSVC RelWithDebInfo, with a real monitor on the NVIDIA output: pass (the previous independent check was on AMD).

  • dxgi_device_test: Vulkan: the title's output answers console slot 21 (GetDisplayModeList1): 119 modes. Slots 19, 20 and 22 log "not measured" and return E_NOTIMPL. 3 backend(s) passed. The same test with LEONIDA_VK_VALIDATION=1 gives exit 0 with 0 validation errors.
  • Full ctest: 268/272. The 4 failures (d3d12_vulkan_device, d3d12_indirect_dispatch_count, d3d12_depth_resolve, d3d12_indirect_rt) are the same 4 as on main dde82f27 on this machine.
  • Merges cleanly with d3d12: enable OPTIONS13 AlphaBlendFactorSupported and validate blend/logic-op state #8043 and d3d12: fix no-ReBAR arena placement, WRITE_BACK caching, and sparse tile spillover #8055 (same d3d12_vulkan_device.cpp).
  • No retail verdict from this branch alone: a 90 s LEONIDA_D3D12=vulkan gta6rt --run on my own 1.0.2.1 copy stops long before DXGI, at GetProcAddress(xgameruntime.dll, XErrorReport): not served. The Wine/Proton ladder is still the place to confirm slot 21.

AI-assisted (Claude Code).

@Kerwinss

Copy link
Copy Markdown

Tested bbc96d0 on Windows 11 Pro 10.0.26300, MSVC 14.51 (VS Build Tools 2026), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4060 / 621.24, Khronos Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON: pass, no regression.

Merged onto main 867d922 (clean), full runtime build, ctest -C RelWithDebInfo -j4: 237/239, same as main alone on this GPU; the two failures are main's own d3d12_depth_resolve (#7985) and d3d12_vulkan_device:6574. dxgi_device, dxgi_swapchain and dxgi_swapchain_count pass on the RTX 4060.

Picked from the "No game copy" list in #7154. AI-assisted (Claude Code). No game files.

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