Skip to content

Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy: copies, presentation (M0), compute path - #119

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
Ryx69:runtime/vulkan-device
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
Ryx69:runtime/vulkan-device

Conversation

@Ryx69

@Ryx69 Ryx69 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Follow-up to #79. The Vulkan command objects (list, queue, allocator, fence) existed, but nothing handed them to
the game, nothing could get data onto the GPU, show a frame or run a shader. This branch adds a Vulkan-backed
device behind the existing Xbox-ABI proxy, then copies, presentation and the compute path on top of it. Five
commits:

1. Vulkan-backed ID3D12Device (40f6399, runtime/shims/d3d12_vulkan_device.cpp)

  • An ID3D12Device11 (PC ABI, 80 slots) that the Xbox-ABI proxy forwards to, so the measured overrides keep working:
    slot 14 heap handles returned in RAX, slot 76 texture creation, slot 62.
  • It creates:
    • queues, allocators, command lists (including CreateCommandList1) and fences;
    • descriptor heaps, plus render-target and depth-stencil views;
    • committed buffers and 2D textures in the common colour, depth, typeless and BC1–7 formats.
  • It answers feature-level and architecture queries; every other query is logged.
  • New textures are zero-filled on first use, as D3D12 committed resources start zeroed, so creation needs no GPU
    work. BC textures are the exception: Vulkan can't clear them.
  • Children hold the proxy, so GetDevice returns the Xbox-ABI object.
  • Opt-in: with LEONIDA_D3D12=vulkan, D3D12XboxCreateDevice uses it; the host PC device stays the default.

2. Copies (9933638)

  • CopyBufferRegion, CopyTextureRegion (subresource ↔ subresource, placed footprint ↔ texture, optional box) and
    CopyResource, replayed with the Vulkan copy commands. Every range is checked before anything is written.
  • A texture in COMMON is copied in place (implicit promotion).
  • GetCopyableFootprints covers buffers and 2D textures. Comparing it with the PC runtime over 13 descriptions
    showed that planar depth-stencil rows are padded to 512 bytes, not 256.
  • Each submission ends with a host barrier, so readback buffers are valid after the fence wait.

3. Presentation, milestone M0 (c876a44, runtime/src/vulkan_present.h)

  • VulkanPresenter blits a back buffer (an ordinary texture in PRESENT state) to a swapchain image and presents
    it, on the same queue after the app's work.
  • Vsync on or off, resize with a scaled blit, and minimised windows are handled.
  • This is the back end a DXGI shim or PresentX would call. The game's own present path is still open
    (question 6), so neither front end is invented here.

4. Test-harness fix and compute groundwork (e9cb850)

  • Review feedback: GPU tests now count only validation-type errors, so a broken third-party implicit layer
    (ReShade's, seen on an RTX 5090) no longer fails every run. Real validation errors still fail.
  • runtime/src/shader_library.h: extracts the FSSM program from the game's shader container (DXIL → XDAT 0x0D →
    XBCH → zlib) and looks up its SHA-256 in the translator's spirv/index.json. It has its own inflate, SHA-256
    and JSON reader, so there are no new dependencies.
  • runtime/src/root_signature.h: parses serialized root signatures and lays out the 32 user-data dwords
    (section 3.5 mapping).
  • Dispatch in the IR, with its root arguments captured at record time.

5. Compute path end to end (0afefcb)

  • GPU address arena (section 3.3): one buffer-device-address buffer standing in for the console's GPU memory
    (LEONIDA_ARENA_MB, default 256, max 4095 so addresses fit 32-bit table pointers).
    • Default-heap buffers, shader-visible descriptor heaps and shader programs live in it; console VA = offset.
    • Upload and readback buffers get VA = their device address − heap base.
  • CreateRootSignature; CreateComputePipelineState through slot 62, finding the shader by its FSSM hash.
  • Command list: root signatures, pipeline state, constant / root view / descriptor-table setters, Dispatch.
    Misuse makes Close return E_INVALIDARG.

Also updated: docs/d3d12_vulkan.md (sections 3.2 and 4.5, the M0 row), runtime/README.md, and the README
status row ("Not started" → "In progress").

Still missing: the bindless descriptor set 0 (images, samplers, the descriptor hash table, which most translated
shaders need, M2), graphics PSOs and draws, wave64 subgroup size control, placed/reserved resources, MSAA, 3D
textures, and the game's own present call. Shaders that declare set-0 bindings are refused with a log for now.

Tested

AI-assisted change. MSVC 2022, Vulkan SDK 1.4.363, NVIDIA GeForce RTX 5060 Ti (driver 621.24):

  • ctest: all 8 tests pass (loader, pe_loader, device_proxy, command_list, shader_library,
    root_signature, bink_decode, d3d12_state_map). No compiler warnings.
    • shader_library: FIPS 180-4 vectors; stored, fixed and dynamic deflate blocks; corrupt and truncated streams;
      FSSM extraction from a synthetic container.
    • root_signature: every field against the PC serializer (v1.0 and v1.1), a signature over 32 dwords, the Xbox
      flag byte.
  • GPU tests, all clean with LEONIDA_VK_VALIDATION=1 (Khronos validation layer, zero messages):
    • d3d12_vulkan_device_test: everything through the proxy (heaps via slot 14 with RAX handles, a render target
      via slot 76). Readback goes through D3D12 itself. Uploads and texture, buffer and BC copies are checked, and
      GetCopyableFootprints matches the host D3D12 runtime exactly.
    • d3d12_present_test (M0): 60 cleared frames in a window, then a resize, then unsynchronised presents. The
      on-screen pixel reads 51,153,229 for a 51,153,230 clear.
    • d3d12_compute_test: a root signature from the PC serializer, a PSO via slot 62 from a game-shaped container,
      and root constants, a root UAV and a descriptor table pointing at an upload buffer. Two dispatches with
      different arguments each give 64/64 correct values. The shader is GLSL written to the translator's
      push-constant and address contract (llvm-mc isn't available here to build RDNA2 test shaders).
    • vk_command_replay_test and d3d12_com_test still pass.
  • Negative checks: a wrong barrier before state, and replay without the layout tracker, both produce validation
    errors and fail the test.
  • Independently tested by a reviewer at c876a44 on an RTX 5090 (driver 621.24): all GPU tests pass.

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. (n/a: no translator change)

@Ryx69 Ryx69 changed the title Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy, with copies. Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy, copies and presentation (M0) Nov 21, 2026
@Vyral1978

Copy link
Copy Markdown
Contributor

Tested 9933638 on a second NVIDIA setup (AI-assisted, run on my machine, no game files):
RTX 3070, driver 610.88, VS 2026 Community (MSVC via vcvars64), Vulkan SDK 1.4.363.1, scripts/build_runtime.ps1.

  • Build: no errors.

  • ctest: 6 of 6 pass.

  • With validation off, d3d12_vulkan_device_test, vk_command_replay_test and d3d12_com_test all pass.

  • With LEONIDA_VK_VALIDATION=1, all three fail with "1 validation errors", but no VUID is reported. The only messages are from the loader:

    validation: loader_get_json: Failed to open JSON file C:\Program Files\Rockstar Games\Social Club\SocialClubVulkanLayer.json
    validation: Removing layer VK_LAYER_EOS_Overlay (...Win64.json) because it is a duplicate of VK_LAYER_EOS_Overlay (...Win32.json)
    

    The first one comes from a stale ExplicitLayers registry entry that an old Rockstar Social Club install left behind. That's probably common on GTA players' PCs. on_validation in runtime/test/vk_test_device.h counts every ERROR-severity message, whatever its type, so loader messages count too. main has the same counter.

Counting only validation-type messages fixes it here. All three tests then pass under validation, with 0 VUIDs:

-                                                    VkDebugUtilsMessageTypeFlagsEXT,
+                                                    VkDebugUtilsMessageTypeFlagsEXT type,
                                                     const VkDebugUtilsMessengerCallbackDataEXT* data, void*) {
-    if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) ++validation_error_count();
+    if ((severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) && (type & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT))
+        ++validation_error_count();

I haven't checked that this still catches a deliberately injected VUID. A narrower alternative is to skip only messages whose pMessageIdName is "Loader Message".

One question, @Ryx69: the PR lists the swapchain as still missing. Are you planning the DXGI side of M0 next (factory/adapter, CreateSwapChainForHwnd, GetBuffer, Present, the 60-frame clear test)? If not, I'd like to try it on top of this PR. I'd rather not duplicate your work.

ItsNotRexed added a commit that referenced this pull request Nov 21, 2026
# Conflicts:
#	README.md
#	runtime/README.md
@Ryx69

Ryx69 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@Vyral1978 Go for it I'm not doing the DXGI side. What's already there: the presentation back end is in this branch (runtime/src/vulkan_present.h, rt::d3d12::create_window_presenter / WindowPresenter::present in runtime/shims/d3d12_com.h), and d3d12_present_test already does the 60-frame clear through the Xbox-ABI proxy on Vulkan, validation-clean. So the DXGI shim mostly needs to be a front end that ends in WindowPresenter::present():

CreateSwapChainForHwnd → create_window_presenter(device, hwnd) + N back buffers;
GetBuffer(i) → ordinary committed textures from the Vulkan device (they don't need to be swapchain images, since the presenter blits; see docs/d3d12_vulkan.md §4.5);
Present → present(buffer[current], sync_interval), then advance GetCurrentBackBufferIndex;
ResizeBuffers → recreate the back buffers (the presenter already handles window resizes).

Caveat: the Xbox build likely presents through PresentX, not DXGI (open question 6), so please keep it a thin layer over the presenter. I'm working on the compute path next (shader library, root signatures, GPU address arena, compute PSOs, Dispatch), which shouldn't touch presentation.

@TricksterG

Copy link
Copy Markdown
Contributor

Tested c876a44 on an RTX 5090 (Blackwell, driver 621.24, subgroup 32..32), Windows 11, MSVC 2022 (14.44), Vulkan SDK 1.4.363.0, Release build.

AI-assisted (Claude Code): it built the branch, ran the tests and wrote this comment.

Build: clean, 0 compiler warnings.

Run directly (they aren't registered in ctest):

test result
d3d12_com_test pass: 16 colour, depth and stencil texels matched
vk_command_replay_test pass
d3d12_vulkan_device_test pass: clears, zero fill, uploads, texture/buffer/BC copies, GetCopyableFootprints all matched
d3d12_present_test pass: 70 frames, swapchain recreated on resize, screen pixel 51,153,229 for a 51,153,230 clear

With LEONIDA_VK_VALIDATION=1: all four pass with no VUID messages. One caveat: on the first try all four exited with 1 validation errors. The message wasn't from the code but from the loader: Failed to open dynamic library "...\ReShade64.dll" with error 1114. ReShade installs an implicit Vulkan layer that fails to load in these tests. With VK_LOADER_LAYERS_DISABLE=*reshade* they pass. The messenger in runtime/test/vk_test_device.h also counts GENERAL messages of warning/error severity, so a broken implicit layer on a contributor's machine fails the run. That's on main too, not something this PR adds, but it may be worth counting only VALIDATION-type messages, or naming the layer in the README.

ctest: 5/5 (device_proxy isn't built here because d3d12.lib isn't found outside a Developer Prompt; #106 is about that).

@Ryx69
Ryx69 marked this pull request as draft November 21, 2026 19:53
@Ryx69

Ryx69 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@TricksterG Thanks for testing on the 5090, that's a useful second data point (Blackwell, same driver). Good catch on the messenger, you're right: it counted every error-severity message, so a broken implicit layer failed every run. Fixed in the next push. runtime/test/vk_test_device.h now only counts VALIDATION-type errors, and general loader/layer messages are still printed but marked "not counted". I checked a real validation error still fails the test (part B of vk_command_replay_test without the layout tracker still exits 1). runtime/README.md now mentions VK_LOADER_LAYERS_DISABLE for silencing a layer like ReShade's.

On ctest: the GPU tests are deliberately not registered, since they need a GPU and a desktop (the present test opens a window), and ctest should stay green on machines and CI without one. The README lists them with how to run them. If people would rather have them under a ctest label (ctest -L gpu), I can add that.

the next push also starts the compute path: shader lookup from the FSSM hash, a root-signature parser checked field by field against the PC serializer, and Dispatch in the IR. Pipelines aren't wired up yet; that's next.

@Ryx69 Ryx69 changed the title Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy, copies and presentation (M0) Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy: copies, presentation (M0), compute path Nov 21, 2026
@Ryx69
Ryx69 marked this pull request as ready for review November 21, 2026 20:12
@aslan2142

Copy link
Copy Markdown
Contributor

@Ryx69 I've claimed D3D-5 (M2) in #156 and am building it on your head 0afefcb: the GFX10 descriptor codec, the descriptor hash table, bindless set 0, the view/sampler/CopyDescriptors device methods, and set 0 in your compute pipeline layout and Dispatch replay (the place that currently refuses shaders with set-0 bindings). I'm leaving graphics pipelines and draws (D3D-4) to you. If you've already started any of the set-0 work, tell me which part and I'll drop it. I also have ResolveSubresource and volume copies ported onto your copy code. AI-assisted.

@Ryx69

Ryx69 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Hello, @aslan2142 You can work on that. I’m not at home right now, so I’m not working so go right ahead.

@ItsNotRexed

Copy link
Copy Markdown
Owner

Thanks! This now conflicts in runtime/shims/d3d12_com.cpp with #164 (ID3D12GraphicsCommandList8, merged) and #159 (3D texture transfer, merged). Since it's the core of the D3D12 layer, I'd rather not splice it by hand: could you rebase onto main? It also conflicts with #138's root-signature model (root_signature.h and its test) if that lands first; #138 isn't on main yet.

@Ryx69

Ryx69 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@ItsNotRexed Check! I will fix it when im get home!

@Vyral1978

Copy link
Copy Markdown
Contributor

@Ryx69 Here's a proposal for after your rebase. It touches your queue, so I'm asking before writing any code.

#148's day-one plan says the first PresentX call and the queue vtable tail are the only way to recover the present surface; its slot, signature and plane struct are all still open. Today the queue the game gets is the CommandQueue object itself (the device proxy doesn't wrap it), with the SDK's 19 public slots (0–18).

What follows slot 18 is worse than garbage. I checked with MSVC's /d1reportSingleClassLayoutCommandQueue on d3d12_com.cpp: slot 19 of CommandQueue's vtable is its C++ destructor ({dtor}, from virtual ~Object() in d3d12_com_object.h). If the first Xbox queue extension (PresentX, SuspendX, ResumeX…) sits at slot 19, the game would call the deleting destructor with whatever is in RDX as flags, and could free the queue. Past slot 19 it reads whatever follows the vtable. The same base is used by the 9 classes on Object/Child (lists, allocators, fences, resources, heaps, PSOs, root signatures and the device), so their first slot past the public chain is also the destructor. The device is the exception in practice, because the game only sees it through the proxy, which already traps.

What I'd add, following the rule the device proxy already applies past the PC vtable:

  • trap slots after the queue's public chain, up to some limit (64?);
  • each trap logs once: the slot number, RDX/R8/R9 (RCX is this) and the first few stack words, as raw hex. No interpretation and no guessed struct. Then it returns E_NOTIMPL;
  • per-slot hit counters, like the device's, for the trace build;
  • a test that calls trap slots through the raw vtable and checks the log and the return value.

For the destructor slot, one option is to make ~Object non-virtual. Release already deletes through static_cast<Derived*>, and that's the only delete in the shims. The overrides on ~Child and on the classes would go too. That's your call.

A limit: this only catches calls past the public chain. If the Xbox queue reorders or inserts methods inside it (the device keeps the public order but changes 62/76), the per-slot counters on the public slots would at most show unexpected argument shapes.

Nothing beyond logging would be implemented, and no slot or layout guessed. Would you rather I put it in d3d12_com.cpp on your branch after the rebase, or as a small separate PR on main once #119 lands? Or were you planning to do it yourself?

Also a heads-up for the rebase: Ryx69#2 (the DXGI shim) sits on 0afefcb. Once you've rebased, I'll rebase it onto your new head.

AI-assisted.

@ItsNotRexed

Copy link
Copy Markdown
Owner

Thanks! This conflicts with what landed on main today (runtime/shims/d3d12_com.* from #164/#159/#167, and pe_loader.cpp from #122/#140), and it's core runtime code, so I'd rather not resolve it by hand. Could you rebase onto main? Please check #156 for overlapping claims first.

S1m0ne1997 added a commit to S1m0ne1997/Leonida that referenced this pull request Nov 21, 2026
…ulkan-backed device (ItsNotRexed#119)

AI-assisted (Claude Code).

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

Copy link
Copy Markdown
Contributor

@Ryx69 Two things for your rebase. 1) main's 28cf235 changed proxy slot 62 to (desc, w2, w3, riid, out). d3d12_compute_test still calls it as (desc, riid, out): it compiles, but the proxy then reads the IID from the wrong argument. Adding the two zero words to XboxComputePipelineFn and to the call fixes it. 2) #138 put runtime/src/root_signature.h and root_signature_test.cpp on main, the same paths as yours. I rebased your three commits onto aae4d99 locally (before #138) to keep building D3D-5 on them; I can push that branch if it saves you time. Small one: after #164, ClearState resets the root state but not the GCL8 stencil references. AI-assisted (Claude Code, Claude Fable 5.2).

@Ryx69

Ryx69 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@ItsNotRexed Done 🙏🏻

Vyral1978 added a commit to Vyral1978/Leonida that referenced this pull request Nov 21, 2026
A thin DXGI layer over rt::d3d12::WindowPresenter, as agreed in ItsNotRexed#119 (D3D-2 in ItsNotRexed#156).

- shims/dxgi.cpp: CreateDXGIFactory/1/2 in the shim table, so the loader binds
  the game's dxgi.dll imports to it. The factory forwards everything to the
  host's DXGI except swapchain creation for a queue of the Vulkan-backed
  device (directly or behind the Xbox-ABI proxy); host D3D12 queues still get
  host swapchains.
- The swapchain owns committed back buffers created through the device the
  game sees (not swapchain images: the presenter blits). Present advances
  GetCurrentBackBufferIndex; ResizeBuffers refuses while a buffer is still
  referenced and waits for the queue before freeing the old ones. Flip model
  only; exclusive fullscreen and HDR are refused with a log.
- tools/gen_d3d12_stubs.py: several --header (chains across dxgi.h ..
  dxgi1_6.h) and --forward, which writes <Interface>Forward classes. The
  D3D12 output is byte-identical.
- d3d12_com.h: is_vulkan_device(), to tell the Vulkan device from a host one.
- Tests: dxgi_swapchain_test (70 frames, ResizeBuffers, on-screen colour,
  host forwarding through WARP) and tests/test_gen_d3d12_stubs.py.

Whether the executable imports dxgi.dll at all (vs PresentX or d3d12_xs's
DXGIX* exports) is still open; docs/d3d12_vulkan.md section 4.5 says so.

AI-assisted. No game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ryx69
Ryx69 force-pushed the runtime/vulkan-device branch from 5796549 to 6f6165f Compare November 21, 2026 22:28
S1m0ne1997 added a commit to S1m0ne1997/Leonida that referenced this pull request Nov 21, 2026
…ulkan-backed device (ItsNotRexed#119)

AI-assisted (Claude Code).

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

Copy link
Copy Markdown
Contributor

Tested b18aedf on AMD Radeon RX 9070, driver 26.11.1 (LLPC), Windows 11: pass

Tested via #291's branch, which includes #119's commits.
GPU: AMD Radeon RX 9070 (subgroup 32..64)
Driver: 26.11.1 (LLPC), Vulkan 1.4.359
OS: Windows 11
Commit: b18aedf
Tools: LLVM 21.1.8 (llvm-mc, AMDGPU target), SPIRV-Tools v2026.4, Vulkan SDK 1.4.363.0, MSVC 19.44, CMake 4.4.4, Python 3.12.10
Run: LEONIDA_VK_VALIDATION=1, python -I scripts/run_gpu_tests.py --build runtime\build
53 shaders: 53 translated, 53 pass spirv-val
GPU tests: 50/51 passed, 1 skipped (ps_vcc_x2 — needs the seeded V# memory of tests/semantic; checked there)
No validation errors

@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@Ryx69 This PR conflicts with main, so I've made a merge you can take as is. It is conflict resolution only, with no feature changes: AlxcBTW:pr119-main, at b2e7d3c. It descends from your head 3732227, so taking it is a fast-forward of your branch:

git pull https://github.com/AlxcBTW/Leonida.git pr119-main

How the conflicts were resolved:

  • README.md (D3D12 row): main's wording plus your "frames are presented to a window". The old "no swapchain" claim is dropped.
  • docs/d3d12_vulkan.md:
  • d3d12_vulkan_device.cpp and vk_test_device.h: there is one device-extension list (swapchain + conditional rendering + host image copy). Your instance-level variables are renamed to instance_extension_count / instance_extensions to avoid a shadowing clash.
  • A separate small commit, b2e7d3c: main changed detail::image_barrier to take a ResourceBinding, so the four swapchain-blit calls in vulkan_present.h now pass a binding with only .image set.

Tested b2e7d3c on an AMD Radeon 880M (26.11.2) and an NVIDIA RTX 5070 Laptop (617.42), Windows 11, MSVC 17.14:

  • ctest: 29/29 on each GPU.
  • d3d12_present_test: pass on both. The window opens, and the pixel reads 51,153,229 against the expected 51,153,230. It runs 70 frames, although the docs say 60.
  • LEONIDA_VK_VALIDATION=1: 0 VUID lines in every D3D12 test. Your "count only validation-type messages" change also makes this machine's stale Nsight layer manifest stop failing them.
  • Failures: d3d12_descriptor_test on AMD (depth_image.format) and d3d12_clear_test on NVIDIA (the 0.5 tie, fixed by Runtime: clears match WARP on every format class: tie rounding, and the SNORM/SINT/R8/R16 formats (D3D-45) #521). Both fail identically on plain main 67204bf.

One small doc nit: the docs call the presenter leonida::VulkanPresenter, but the code has rt::d3d12::create_window_presenter.

AI-assisted (Claude Code).

@quackottu

Copy link
Copy Markdown
Contributor

Tested 3732227 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0: pass

  • ctest -C RelWithDebInfo: 14/14 passed
  • With LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan, 0 validation errors in each of:
    • d3d12_vulkan_device_test: clears, zero-filled first use, uploads, texture/buffer/BC copies, a resolve and GetCopyableFootprints matched
    • d3d12_com_test: 16 colour/depth/stencil texels matched; queue wait held the GPU
    • d3d12_descriptor_test: CopyDescriptorsSimple and CopyDescriptors matched
    • d3d12_present_test: 70 frames presented, swapchain recreated on resize, colour confirmed on screen

Overlay layers (Social Club, Overwolf) were disabled with VK_LOADER_LAYERS_DISABLE so they couldn't interfere.

@Ayinaki

Ayinaki commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

TEST-56 result at 3732227 (head tested, not merged with current main; the PR is CONFLICTING).

Environment: Windows 11, NVIDIA RTX 5070 (driver 616.86), Vulkan 1.4.363, MSVC 19.52 (VS 2026), Windows SDK 10.0.26100, Release, LEONIDA_VK_VALIDATION=1.

  • Build: clean, no warnings.
  • ctest: 14/14 passed.
  • d3d12_vulkan_device_test: exit 0; clears, zero-fill, uploads, texture/buffer/BC copies, resolve and GetCopyableFootprints matched.
  • d3d12_present_test: reached the 70-frame and resize path with no validation errors, but the final on-screen pixel read returned 255,255,255 instead of 51,153,230. The test saw the window as foreground; this session's desktop is white/non-composited, so I am reporting the screen readback as environment-limited rather than a device failure.
  • d3d12_compute_test is not built on this branch; it is added by Runtime: compute path and graphics draws on Vulkan (D3D-3, D3D-4, milestone M1) #291.

No game files.

@whattheflop

Copy link
Copy Markdown
Contributor

TEST-56 on RTX 3080 (NVIDIA 616.64, Vulkan 1.4.351), Windows 11 Pro 25H2 (26200.9974), MSVC 19.38, Windows SDK 10.0.26100, Vulkan SDK/validation layer 1.4.363.0, Ninja RelWithDebInfo. Set LEONIDA_D3D12=vulkan and LEONIDA_VK_VALIDATION=1; loader tracing confirmed Khronos validation and the selected GPU. An empty VK_IMPLICIT_LAYER_PATH isolated a stale overlay registration.

  • Exact head 3732227: build passed, CTest 14/14 (game-dependent tests self-skipped), six direct runtime tests passed with zero Vulkan validation errors. Copy footprints matched the Windows host and the present test rendered 70 frames and recreated the swapchain on resize. This adds RTX 3080 coverage to the earlier Windows run.
  • The exact head conflicts with main 67204bf. The published reviewer integration b2e7d3c built and passed CTest 29/29. Of the seven direct tests, only d3d12_clear_test failed. It reports the same format 28 clear-byte difference (Vulkan 7f, WARP 80) on plain 67204bf, with zero VUIDs in both cases.

AI-assisted verification using repository tests and synthetic inputs.

- vulkan_present.h: VulkanPresenter blits a back buffer (an ordinary texture
  in D3D12's PRESENT state, layout tracked like any other) to an acquired
  swapchain image and presents it on the same VkQueue, after the
  application's work. Two frames in flight, a present semaphore per image,
  FIFO for vsync else MAILBOX/IMMEDIATE, swapchain recreated on resize or
  out-of-date/suboptimal, minimised windows skip presents.
- rt::d3d12::create_window_presenter / WindowPresenter: Win32 surface for a
  Vulkan device created with presentation; holds the device. This is the back
  end a DXGI shim or PresentX would call; the game's own front end is still
  open (docs question 6), so neither is invented here.
- Standalone device enables VK_KHR_surface/win32_surface and VK_KHR_swapchain
  when present; the test helper can too.

Test: d3d12_present_test opens a window and presents 60 frames through the
Xbox-ABI proxy (reset, PRESENT->RENDER_TARGET, clear, ->PRESENT, execute,
present, fence), resizes the window (swapchain recreated, scaled blit),
switches to unsynchronised presents, and reads the screen with GDI:
51,153,229 for a 51,153,230 clear. Clean under the Khronos validation layer,
as are the other GPU tests; 6/6 ctest.
The debug messenger in test/vk_test_device.h counted every error-severity
message, so a broken third-party implicit layer (ReShade's, reported on an
RTX 5090) failed every GPU test. Only VALIDATION-type errors are counted now;
general loader and layer messages are still printed, marked "not counted".
A real validation error still fails the test (checked by replaying part B of
vk_command_replay_test without the layout tracker). runtime/README.md says
so and mentions VK_LOADER_LAYERS_DISABLE.
@bobcatchris

Copy link
Copy Markdown
Contributor

TEST-56 on an AMD GPU on Windows, validation on.

#119 is already on main, so what I ran is main at 4a36bb1; the two newer commits this PR still carries were not tested — say the word and I will run them the same way.

GPU AMD Radeon RX 7900 XTX (RDNA3, gfx1100), AMD proprietary 26.10.1 (LLPC), Vulkan 1.4.359
OS Windows 11 x64 build 26200, MSVC 19.39, Windows SDK 10.0.26100, Vulkan SDK 1.4.341.1
Build scripts/build_runtime.ps1: clean, 165 targets.

LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build: 31/32 passed, 1 failed:

OPTIONS19.SupportedSampleCountsWithNoOutputs: ours 0xf not subset of host 0x1d

Filed as #854. It fails identically on main without #291, so it is independent of the compute/draw path: the layer reports Vulkan's framebufferNoAttachmentsSampleCounts (d3d12_vulkan_device.cpp:1246) while AMD's own D3D12 driver on this card reports {1,4,8,16} — we under-report 16× no-outputs MSAA and over-report 2×.

Everything else passed with validation on: the device, copy, resource-desc, descriptor, clear, typeless-RTV, pipeline-cache, state-map and replay tests, plus the vk_* tools. The GPU shader suite on the same commit is 98/98 on this card (posted in #166).

AI-assisted.

…s only shown frames (review)

From VictorJulianiR's review of the presenter, with Vonsek's measurements:
- A failed blit submission left the frame's fence reset with nothing to signal it, so the next present waited
  forever (Vonsek: the retry reached vkWaitForFences with UINT64_MAX). An empty batch now takes the acquire
  semaphore and signals the fence, and the swapchain is recreated next time to give back the image that was
  never presented. If that batch fails too, or a fence wait or reset fails, the presenter stops (ok() is
  false). A back buffer the device does not know is refused before an image is acquired for it.
- A swapchain recreation published the new swapchain before its per-image semaphores existed, so a failed
  semaphore left a presenter that could submit with a null one. The images and semaphores are now built in
  local storage and published only when all exist; on a failure the partial objects are released and the next
  present tries again.
- An out-of-date present was counted as presented (Vonsek: 69 VK_SUCCESS and one VK_ERROR_OUT_OF_DATE_KHR
  reached 70). presented() now counts VK_SUCCESS and VK_SUBOPTIMAL_KHR only; the caller still gets VK_SUCCESS.

d3d12_present_test gives the device and presenter their functions through a driver double that forwards to the
real driver. It counts real out-of-date presents (the frame counts allow for them) and live binary semaphores.
It reports one present as out of date and one as suboptimal, fails the second semaphore of a recreation, and
fails one blit submission. Against the old presenter the test fails at the frame count after the resize, where
this RTX 5060 Ti reported a real out-of-date present.

Docs: the presenter is named as leonida::VulkanPresenter, made by rt::d3d12::create_window_presenter, and the
test is described as 60 frames then 10 after a resize (AlxcBTW).
@Ryx69
Ryx69 force-pushed the runtime/vulkan-device branch from 3732227 to 147f930 Compare November 22, 2026 03:56
@Ryx69

Ryx69 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

hanks for the runs and the review. Rebased onto main 4a36bb1 (merges cleanly), plus 147f930 for @VictorJulianiR's review, with @Vonsek's measurements confirming items 1 and 3:

A failed blit submission no longer leaves a fence nothing will signal. An empty batch waits on the acquire semaphore and signals the frame's fence, and the swapchain is recreated next time to get the unpresented image back. If that batch fails, or a fence wait or reset fails, the presenter stops (ok() is false). A back buffer the device doesn't know is refused before an image is acquired.
A recreation builds the swapchain's images and semaphores in local storage and publishes them only when all exist. On a failure the partial objects are released and the next present retries.
presented() counts VK_SUCCESS and VK_SUBOPTIMAL_KHR only.

d3d12_present_test now runs through a driver double around the real driver. It injects an out-of-date and a suboptimal present, a failed semaphore during a recreation (only the two acquire semaphores may remain afterwards), and a failed blit submission (the next four presents must go through). Against the old presenter it fails at the frame count after the resize, where my RTX 5060 Ti reported a real out-of-date present.

Docs: the presenter is leonida::VulkanPresenter, made by rt::d3d12::create_window_presenter, and the test is 60 + 10 frames (@AlxcBTW). The Windows 10 footprint failure (@Jess-Doit, @Derpbeat, @rasptum) and the 128-byte assertion (@ezwinxdlmao) were fixed on main and come in with the rebase.

Tested on an RTX 5060 Ti (driver 621.24) with validation: ctest 32/32 and the GPU tests with 0 VUIDs, except d3d12_clear_test, which fails on plain main as well. AI-assisted.

@JavierBlanco23

Copy link
Copy Markdown
Contributor

Tested #119 at 147f930 on Windows 11, RTX 5080 (Blackwell), driver 616.56, Vulkan 1.4.x, MSVC 19.44, Ninja.

  • ctest --test-dir runtime/build: 32/32 pass with LEONIDA_VK_VALIDATION=1
  • d3d12_vulkan_device_test: 0/69 copy cases differ from host; FORMAT_INFO 195 queries 0 mismatches; CheckFeatureSupport 15 queries 0 mismatches; allocation info all match; resolves 60/60 matched; WriteToSubresource/ReadFromSubresource both paths matched
  • d3d12_clear_test: 3 pre-existing mismatches (R8G8B8A8_UNORM/SNORM and D16_UNORM at exact 0.5 — NVIDIA rounds down, WARP rounds up; documented as known)
  • vk_descriptor_bench: full sweep 1K/10K/100K entries across device_local, host_visible, host_device_local (Resizable BAR). Critical: host_visible divergent_miss collapses to 0.01 Glk/s at 100K (600× slower than device_local); host_device_local (ReBAR) matches device_local. Supports Runtime: put the descriptor table in device-local memory (D3D-76) #696 bindless-in-VRAM approach.
  • No validation errors reported.
  • AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor

Windows + RDNA3 GPU test (TEST-56)

Tested together with #291: this PR's head (147f930) is an ancestor of #291's head (2aed144), so one build contains both and the run below covers both. Full report is on #291.

Environment: AMD Radeon RX 7900 XTX (RDNA3, gfx1100), AMD proprietary 32.0.32015.7029 (26.10.1, LLPC), Vulkan 1.4.359; Windows 11 x64 build 26200; MSVC 19.39; Windows SDK 10.0.26100; Vulkan SDK 1.4.341.1. Built with scripts/build_runtime.ps1 (RelWithDebInfo). LEONIDA_VK_VALIDATION=1 on every run, no validation messages.

No game files used. AI-assisted (Freebuff/Buffy).

@hadagalberto

Copy link
Copy Markdown
Contributor

TEST-56: tested head 147f930 on Windows 11 Pro 26300 with an AMD Radeon RX 7900 XTX (RDNA3), AMD driver 26.11.2 (Vulkan 1.4.359, LLPC). Built RelWithDebInfo with MSVC 14.51 (VS 18 Build Tools) and Ninja, Vulkan SDK 1.4.363.0. Ran with LEONIDA_VK_VALIDATION=1 and without VK_VALIDATION_VALIDATE_SYNC. Every D3D12 test printed device: AMD Radeon RX 7900 XTX (validation on). No game files.

  • Build: OK, with one warning: C4456 at runtime/src/vulkan_replay.h:1372 (i shadows the declaration at line 1225).
  • CTest: 31/32 pass, and gameinput was not run (no SDL3). d3d12_vulkan_device fails with OPTIONS19.SupportedSampleCountsWithNoOutputs: ours 0xf not subset of host 0x1d. That is d3d12_vulkan_device: OPTIONS19.SupportedSampleCountsWithNoOutputs 0xf vs host 0x1d on AMD (RX 7900 XTX, Windows) #854, which main d1211d0 also hits, so this PR didn't cause it. Runtime: OPTIONS19 no-output sample counts are 1/4/8/16 (no 2x) — fixes the red d3d12_vulkan_device_test on AMD #855 has a fix. The test returns at that check, so the checks after it (the D3D-14 push-constant ones) did not run here.
  • Explicit GPU tests: all exit 0 with 0 VUIDs.
    • d3d12_clear (189 readbacks matched WARP), d3d12_com, d3d12_descriptor, d3d12_method_variants
    • d3d12_present (M0: 70 frames, resize, colour on screen; its injected out-of-date, recreation and blit failures recovered)
    • d3d12_resource_desc, d3d12_sampler2, d3d12_typeless_rtv (799 readbacks), d3d12_uav_clear, vk_command_replay
  • Not run: scripts/run_gpu_tests.py and the vk_compute, vk_store, vk_texture and vk_bindless tests it drives. They need llvm-mc with the AMDGPU target, which isn't installed here.

AI-assisted (Claude Code).

@DiazE117

Copy link
Copy Markdown
Contributor

TEST-56 on Windows 11 + RTX 4070 SUPER (Ada), driver 610.88: 147f930 tested as part of #291's head 2aed144, which contains it. ctest passes 33/33 with LEONIDA_VK_VALIDATION=1, with zero validation messages; d3d12_vulkan_device_test copies 0/69 differ and resolves 60/60 match. Full report: #291 (latest comment).

AI-assisted (Claude Code).

@hadagalberto

Copy link
Copy Markdown
Contributor

TEST-56 follow-up: ran scripts/run_gpu_tests.py, which my first comment had skipped. Same heads and machine as before (147f930 / 2aed144, RX 7900 XTX, AMD 26.11.2), with llvm-mc 21.1.8 (AMDGPU only) built by scripts/build_llvm_mc.ps1.

AI-assisted (Claude Code).

@hadagalberto

Copy link
Copy Markdown
Contributor

@Ryx69: Ryx69#4 merges main (d1211d0) into runtime/vulkan-device and resolves this PR's conflicts in runtime/CMakeLists.txt and runtime/shims/d3d12_com.h by keeping both sides. It builds and passes the same tests as above (RX 7900 XTX, validation on). Merging it into your branch should clear the conflict here. AI-assisted (Claude Code).

@LucasDonin

Copy link
Copy Markdown

Tested 147f930 on an NVIDIA GeForce GTX 1660 (Turing TU116), driver 610.88, Windows 11, MSVC 19.44, LEONIDA_VK_VALIDATION=1: pass, as part of #291's head 2aed144 (which contains 147f930). Details in #291 (comment): ctest 33/33, no validation messages, d3d12_vulkan_device_test 0 mismatches, run_gpu_tests.py 73/100 (27 wave64 skips) and 100/100 with LEONIDA_W64_EMULATE=1; the only failure is the known d3d12_clear_test tie rounding (#917, #521).

AI-assisted run (Claude). No game files involved.

@ItsNotRexed
ItsNotRexed merged commit 147f930 into ItsNotRexed:main Nov 22, 2026
10 checks passed
aslan2142 added a commit to aslan2142/Leonida that referenced this pull request Nov 22, 2026
main gained 117 commits since f85582e, among them ItsNotRexed#119 itself (through ItsNotRexed#908,
which is built on its head and adds PresentX on top), so both sides now
carry the presentation path: this branch as ItsNotRexed#119's own commits merged with
main at 426023a, main as ItsNotRexed#908's integration of them. Eleven hunks in six
files conflicted.

runtime/src/vulkan_present.h (2 hunks):
- present's blit: main's structure (a blank present, the source rectangle)
  with both locks of the branch. record() reads and updates the context's
  layout tracker, which ExecuteCommandLists guards with tracker_mutex_ (it
  copies the tracker, emits, and commits the copy after the submit); under
  the resource lock alone a present between that copy and that commit would
  lose its update. Order as in the context: resource -> tracker -> submit.
- presentable(): identical code, main's comment.

runtime/shims/d3d12_vulkan_device.cpp (3 hunks):
- includes: shader_library.h stays (pipelines read the translator's index);
- Resource's fields: the branch's arena fields and main's rgb96_ (D3D-62);
- standalone device: info.presentation is set once, where the swapchain
  extension is pushed (the branch's order); main set the same value later.

runtime/shims/d3d12_com.h (2 hunks): the union of the includes; the
branch's VulkanDeviceInfo::features and shader_dir stay.

runtime/CMakeLists.txt: main now builds and registers d3d12_present_test
next to xbox_present_test, so the branch's copy of that block goes; the
compute and draw tests keep theirs. d3d12_present_test keeps returning 77
without a Vulkan device, which main's registration (c2967a5) relies on but
main's test does not do yet.

README.md, docs/d3d12_vulkan.md (3 hunks): the branch's text. main's side
is what the branch had already merged at f85582e, unchanged since.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AlxcBTW added a commit to AlxcBTW/Leonida that referenced this pull request Nov 22, 2026
ItsNotRexed#119 is in main now, so the presenter files come from main (vulkan_present.h, the present tests and their ctest
registration). Conflicts (both sides kept): runtime/CMakeLists.txt, d3d12_com.h, d3d12_vulkan_device.cpp (rgb96_
next to the PR's graphics code), docs and README.

This PR's own tests d3d12_compute_test, d3d12_draw_test and d3d12_subgroup_test were built but never run by ctest
(tests/test_ctest_registration.py). They are registered now, and exit 77 (skipped) when there is no Vulkan 1.3
device, like d3d12_present_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlxcBTW added a commit to AlxcBTW/Leonida that referenced this pull request Nov 22, 2026
ItsNotRexed#119 is in main now, so the presenter files come from main (vulkan_present.h, the present tests and their ctest
registration). Conflicts (both sides kept): runtime/CMakeLists.txt, d3d12_com.h, d3d12_vulkan_device.cpp (rgb96_
next to the PR's graphics code), docs and README.

This PR's tests d3d12_compute_test, d3d12_draw_test and d3d12_translated_draw_test were built but never run by ctest
(tests/test_ctest_registration.py). They are registered now, and exit 77 (skipped) when there is no Vulkan 1.3
device, like d3d12_present_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.