Repository navigation
Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy: copies, presentation (M0), compute path - #119
Conversation
|
Tested
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 One question, @Ryx69: the PR lists the swapchain as still missing. Are you planning the DXGI side of M0 next (factory/adapter, |
# Conflicts: # README.md # runtime/README.md
|
@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; 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. |
|
Tested 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
With
|
|
@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 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. |
|
Hello, @aslan2142 You can work on that. I’m not at home right now, so I’m not working so go right ahead. |
|
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. |
|
@ItsNotRexed Check! I will fix it when im get home! |
|
@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 What follows slot 18 is worse than garbage. I checked with MSVC's What I'd add, following the rule the device proxy already applies past the PC vtable:
For the destructor slot, one option is to make 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 Also a heads-up for the rebase: Ryx69#2 (the DXGI shim) sits on AI-assisted. |
…ulkan-backed device (ItsNotRexed#119) AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@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). |
0afefcb to
5796549
Compare
|
@ItsNotRexed Done 🙏🏻 |
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>
5796549 to
6f6165f
Compare
…ulkan-backed device (ItsNotRexed#119) AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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. |
|
@Ryx69 This PR conflicts with How the conflicts were resolved:
Tested
One small doc nit: the docs call the presenter AI-assisted (Claude Code). |
|
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
Overlay layers (Social Club, Overwolf) were disabled with |
|
TEST-56 result at Environment: Windows 11, NVIDIA RTX 5070 (driver 616.86), Vulkan 1.4.363, MSVC 19.52 (VS 2026), Windows SDK 10.0.26100, Release,
No game files. |
|
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
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.
|
TEST-56 on an AMD GPU on Windows, validation on. #119 is already on GPU AMD Radeon RX 7900 XTX (RDNA3, gfx1100), AMD proprietary 26.10.1 (LLPC), Vulkan 1.4.359
Filed as #854. It fails identically on Everything else passed with validation on: the device, copy, resource-desc, descriptor, clear, typeless-RTV, pipeline-cache, state-map and replay tests, plus the 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).
3732227 to
147f930
Compare
|
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. 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. |
|
Tested #119 at
|
Windows + RDNA3 GPU test (TEST-56)Tested together with #291: this PR's head ( 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
No game files used. AI-assisted (Freebuff/Buffy). |
|
TEST-56: tested head
AI-assisted (Claude Code). |
|
TEST-56 on Windows 11 + RTX 4070 SUPER (Ada), driver 610.88: AI-assisted (Claude Code). |
|
TEST-56 follow-up: ran
AI-assisted (Claude Code). |
|
@Ryx69: Ryx69#4 merges |
|
Tested AI-assisted run (Claude). No game files involved. |
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>
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>
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>
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)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.
CreateCommandList1) and fences;work. BC textures are the exception: Vulkan can't clear them.
GetDevicereturns the Xbox-ABI object.LEONIDA_D3D12=vulkan,D3D12XboxCreateDeviceuses it; the host PC device stays the default.2. Copies (
9933638)CopyBufferRegion,CopyTextureRegion(subresource ↔ subresource, placed footprint ↔ texture, optional box) andCopyResource, replayed with the Vulkan copy commands. Every range is checked before anything is written.COMMONis copied in place (implicit promotion).GetCopyableFootprintscovers buffers and 2D textures. Comparing it with the PC runtime over 13 descriptionsshowed that planar depth-stencil rows are padded to 512 bytes, not 256.
3. Presentation, milestone M0 (
c876a44,runtime/src/vulkan_present.h)VulkanPresenterblits a back buffer (an ordinary texture inPRESENTstate) to a swapchain image and presentsit, on the same queue after the app's work.
PresentXwould 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)(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-256and 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).
Dispatchin the IR, with its root arguments captured at record time.5. Compute path end to end (
0afefcb)(
LEONIDA_ARENA_MB, default 256, max 4095 so addresses fit 32-bit table pointers).CreateRootSignature;CreateComputePipelineStatethrough slot 62, finding the shader by its FSSM hash.Dispatch.Misuse makes
ClosereturnE_INVALIDARG.Also updated:
docs/d3d12_vulkan.md(sections 3.2 and 4.5, the M0 row),runtime/README.md, and the READMEstatus 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 Xboxflag byte.
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 targetvia slot 76). Readback goes through D3D12 itself. Uploads and texture, buffer and BC copies are checked, and
GetCopyableFootprintsmatches the host D3D12 runtime exactly.d3d12_present_test(M0): 60 cleared frames in a window, then a resize, then unsynchronised presents. Theon-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-mcisn't available here to build RDNA2 test shaders).vk_command_replay_testandd3d12_com_teststill pass.beforestate, and replay without the layout tracker, both produce validationerrors and fail the test.
c876a44on an RTX 5090 (driver 621.24): all GPU tests pass.Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)