Device slots 25, 26, 56 and 108 tell the C form (buffer, device) from the
PC form (device, buffer) by which argument starts with the proxy vtable
pointer. A title's return buffer is uninitialised stack memory and can still
hold that pointer from an earlier call; both arguments then look like the
proxy and the struct is written over it (xcl found this on a retail title).
A device proxy is a heap object, so an argument inside the calling thread's
stack is taken for the buffer.
xs_proxy_mock_test: check_struct_return_stale_vtable puts a stale copy of
the vtable pointer in a stack buffer and calls slots 25 and 108 in the C
form and slot 26 in both forms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xmem commits physical pages on first touch (#7556), so a range the title has
mapped but not written yet is still MEM_RESERVE when it places a buffer on it
through device slot 133, and the Vulkan layer's import (#7218) refuses reserved
pages and answers with its fallback buffer, which the title's writes never reach.
Slot 133 now calls a registered pages hook (set_placed_at_va_pages_hook, next to
set_placed_at_va_handler) with the buffer's range before the handler; gta6rt
registers rt::xmem::commit_physical_range. A failed commit is logged once and the
handler still runs. Textures don't call it. The Vulkan layer doesn't link xmem.
Tests: xs_proxy_mock_test checks the hook order, arguments, failure and texture
cases; the new d3d12_xmem_placed_test places a buffer on untouched xmem physical
pages and checks the fallback without the hook, and with it the import and a GPU
copy reading the CPU's writes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
regen_fixtures finds its sources by marker on main, so the two ds_append
sources carry the marker instead of a SHADERS entry. ds_append and
ds_consume join wave64_emulate_opt's always-barrier ops (autogenes-sudo's
fix on #3976): under --wave64-emulate they exchange through a barrier
round, and a guarded one in a multi-wave group hit the translator's assert.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A question that keeps coming back on the boot path is "what is actually on screen", and the window is not a reliable
answer: under Wine it is not mapped at all, and even on Windows a compositor or a capture-blocked surface can hide
the content. The presenter already copies every presented frame into a staging buffer when capture is enabled, so
this adds the disk side: `LEONIDA_CAPTURE=<dir>` writes each captured frame as a binary PPM and appends the extent
and the mean RGB to `<dir>/index.txt`, with `LEONIDA_CAPTURE_EVERY` and `LEONIDA_CAPTURE_LIMIT` bounding the run.
Off unless set, and created with the folder if it is missing. The write happens on the fence that already covers the
copy, so the present path is untouched.
d3d12_present_test turns it on and checks the files against the colour the test clears to: at least half the captured
frames (it resizes and injects failures on purpose, so a frame caught mid-transition is a near miss), and no frame
black. A capture that reads the wrong or a stale buffer fails there instead of in a report months later.
Measured against the host runtime's DXGI on an RTX 5070 Ti and on WARP (Windows 11), both agreeing:
- The adapter answers IDXGIAdapter4. GetDesc3 gives what GetDesc1 gives, plus the
preemption granularities; a null description is E_INVALIDARG.
- GetRestrictToOutput on a swap chain created without an output is S_OK with a null
output, not DXGI_ERROR_NOT_FOUND.
- ResizeBuffers refuses NONPREROTATED, FULLSCREEN_VIDEO and every bit from 0x4000 up
with DXGI_ERROR_INVALID_CALL, and FOREGROUND_LAYER, YUV_VIDEO and 0x2000 on a chain
created without them with E_INVALIDARG (a sweep of all 32 bits on the host).
- A null out-pointer on GetBuffer, GetHwnd, GetLastPresentCount and GetRestrictToOutput
is DXGI_ERROR_INVALID_CALL, not E_POINTER or E_INVALIDARG.
dxgi_host_parity_test compares the layer with the host for each of these (PROBE_WARP=1
for WARP): 18 of 26 rows differ before, 0 after, on both. dxgi_device_test and
dxgi_swapchain_test now expect the host's answers.
AI-assisted: yes
Own's mock keeps the SetPrivateDataInterface object in Mock::held (ladder's
port of #7052); #7235's mock calls it private_data.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review notes on #9549: fopen warns C4996 on MSVC and narrows the temp path to
the ANSI code page, so a TEMP outside it left stderr unredirected and the test
failed with counts of 0. The capture now opens the wide path and reports
whether it redirected, which the test expects.
The comment said nothing is written with the trace off; a refused PresentX
under a capture with the trace off now checks it.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Releasing N placed buffers scanned N(N+1)/2 entries under the lock slot 70 takes (shdann's review on #8304).
The entries now live in a std::map keyed by their id. Ids only grow, so map order is placement order and
slot 70 still walks it backwards for the newest placement; a tag whose entry already went with its device
erases nothing. Teardown of 32,768 buffers released newest first: 151.63 ms before (shdann), 3.47 ms after
(same loop, MSVC /O2, Windows 11).
(cherry picked from commit 335d0a1870a2fd49106289ecb0980b71cd2410c8)
Device slot 70 makes a shader-resource view from a description and a console
address, with no resource object. It asked only the device behind the proxy
for a buffer at that address, and that device knows the buffer by the title's
address only when it could put the buffer on the title's own pages. When it
could not (the import is refused, or the device is a PC one), the slot 133
buffer has an address of its own, nothing was found, and the title's
descriptor got the null view.
The proxy now remembers every buffer a slot 133 call made by the range the
title placed it at, whichever way it was made (the placed-at-VA handler, PC
CreateCommittedResource3 or CreateCommittedResource), and slot 70 asks there
first, then the device's provider. An entry holds no reference. An object
attached to the resource as private data removes the entry when the resource
dies, and a device proxy's entries go with it. The newest buffer over an
address answers, so a range the title places again is the new buffer's.
xs_proxy_mock_test: check_slot70_placed_buffer covers both creation paths
and the handler path, the element range, the cut at the buffer's end, the
addresses around two buffers, a texture, the provider fallback and its
order, a range placed twice, a released buffer and a released device. The
check of the placed-at-VA handler in check_levels hands out a mock resource
instead of a made-up pointer, since the proxy now asks the object for
ID3D12Resource.
Depends on: #7066 (slot 70), #7218 or #7075 (slot 133), #6953 (the table
reaches slot 133), and #7235 for the mock's SetPrivateDataInterface.
(cherry picked from commit 7387445983daa6d52367cd7a78ef0a6069b7035e)
Resolved as #8304's integration merge b7a68aa39 does: a buffer goes to the registered placed-at-VA handler
first; a texture, a device with no handler and a handler refusal keep #7075's committed stand-in. #7218's own
proxy_create_placed_resource_x is folded into #7075's; slot_name keeps one case 133.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both were hardcoded (FLIP_DISCARD, RENDER_TARGET_OUTPUT). The host and WARP report the creation values:
FLIP_SEQUENTIAL, RENDER_TARGET_OUTPUT | SHADER_INPUT, or 0. dxgi_host_answers: 6 of 7 rows differ on main against
the NVIDIA host and against WARP, 0 with both commits.
AI-assisted: yes
When the native swapchain matched the request (count, size and format), the app's back buffers were the Vulkan
images themselves, so GetCurrentBackBufferIndex followed vkAcquireNextImageKHR: 0 1 0 2 1 0 2 on an RTX 5070 Ti
with three FIFO images, where DXGI (NVIDIA and WARP) hands a flip-model chain's buffers out 0, 1, 2, 0, ... An app
that keeps its own (i+1)%N counter rendered into a buffer that wasn't presented next. The offscreen ring the
mismatched cases already use (one blit per present) is now always used.
dxgi_host_answers_test creates the same chains on the Vulkan-backed factory and on the host's (PROBE_WARP=1: WARP)
and compares the index sequence over 12 presents and a resize, and GetDesc/GetDesc1.
AI-assisted: yes
The HDR10 swapchain check compared only red, so errors confined to green or blue could pass. Compare all three
channels within one 10-bit code for either packed format and report the first mismatching sampled pixel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both tools ranked the devices themselves and ignored LEONIDA_VK_DEVICE,
so on a PC with two GPUs they ran on the best-ranked one whatever the
filter said. vk_sandbox now uses vk_device_pick.h's pick_device, and
vk_descriptor_bench skips devices the filter leaves out. When the filter
matches no usable device, both report it and fail the run, as the other
harnesses do.
check_device_filter_tools.py (ctest vk_device_filter_tools) runs both
tools with a filter that matches nothing and skips on a machine with no
Vulkan device.
The VKH_BINARY_OUT/VKH_BINARY_IN path needs VK_KHR_pipeline_binary, which is newer than
some Vulkan header sets: Ubuntu 24.04 ships 1.3.275 and CMake's find_package(Vulkan)
picks those up when VULKAN_SDK is not set, so the whole target failed to compile with
"VkPhysicalDevicePipelineBinaryFeaturesKHR was not declared in this scope" and seven
follow-on errors.
Guard the feature on the two extension macros the code already needs. With old headers a
VKH_BINARY_OUT/VKH_BINARY_IN run now prints "unsupported: these Vulkan headers have no
VK_KHR_pipeline_binary" and exits 77, the skip code the harness uses elsewhere, and
everything else in the harness is unchanged.
The test registered SKIP_RETURN_CODE 77 and check_sparse_queue_family.py already reads 77 as
"Vulkan device / sparse features unavailable", but main() pushed the standalone device creation
through ok(), so on a host without a Vulkan device it printed "FAIL Leonida
create_vulkan_device_standalone hr=0x80004005" and exited 2. The Windows CI runner has no GPU
driver, so the windows ctest job fails on this one test out of 166 while every sibling d3d12 test
skips through vktest::Device.
Return 77 on a failed creation instead, matching d3d12_dxr_validation_test, and keep the hard
failures for everything after it.
XUserDeviceImpl slots 4/5 (XUserRegisterForDeviceAssociationChanged and its
unregister) and 7/8 (XUserRegisterForDefaultAudioEndpointUtf16Changed and its
unregister) handed out a token and dropped the registration; unregister
returned true for anything.
Each registration is now kept (kind, a duplicate of its queue, context,
callback) under a token unique across both kinds and never 0, and the
matching unregister removes it at once, with or without wait. Unregister
returns true for every token, as XUserUnregisterForChangeEvent does; a token
already removed, never issued or of the other kind changes nothing. Offline
the association and the default audio endpoint never change, so no event is
raised and no callback is queued or called. The state is namespace-scope
with a constinit SRW lock, no function-local statics.
xgameruntime_offline_test checks null arguments, token uniqueness, that
registrations are kept and removed per kind, harmless repeat and foreign
unregisters, and that no callback runs. docs/runtime_imports.md says so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 20-thread group is one wave32 with lanes 20-31 never launched. A launched
lane whose source lane is missing gets 0, and a send to a missing lane is
lost. cs_w32_permute and cs_w64x_permute run full waves only. The expected
words are measured with a raw 20-thread hw_oracle kernel on gfx1036.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Handle the console-extended CreateDescriptorHeap layout observed in #313 by reading address/size only on the Xbox slot 14 proxy path after a readable-range check, and report that console VA as the heap CPU/GPU start via an explicit Leonida helper. Normal 16-byte PC CreateDescriptorHeap calls remain unchanged. Title-memory aliasing / section 3.3 backing is still unresolved.
`CommandList::clear_depth_stencil` (`runtime/src/command_list.h`) refused a `ClearDepthStencilView` whose depth was
outside [0, 1] or NaN, and one whose `D3D12_CLEAR_FLAGS` were 0, so `Close` answered `E_INVALIDARG` and the whole
`ExecuteCommandLists` submission was dropped. Windows' D3D12 closes those lists: on WARP a `D32_FLOAT` target keeps
1.5, -0.5 and NaN exactly as given, and a clear that names no plane clears nothing. `d3d12_clear_test` now reads those
back on WARP and on the layer, and `d3d12_close_parity_test` measures the four `Close` verdicts.
A title that clears depth with a computed value (or wraps the clear in a flag mask that can be 0) lost that frame's
depth clear and, with it, the whole submission's work. The call is now recorded with the depth as given (a D16 target
still quantizes at replay) or, with no plane named, recorded as nothing.
d3d12_clear_test adds three read-back comparisons (1.5/-0.5, NaN, flags 0), command_list_test asserts the accepted
calls and the stored values, and the four close-parity rows move from the known-difference table to `match`.
From review (@FRaccie):
- The texture fallback called create_committed, which takes the state without checking it (textures start
undefined and take their first command's layout), so the barrier-layout state and its COMMON retry did
nothing. It now goes through create_committed_validated, as CreateCommittedResource does: RENDER_TARGET on a
texture without ALLOW_RENDER_TARGET is refused and the COMMON retry answers; a description the checks refuse
outright is refused.
- An imported buffer's VA is its host address, in the same BufferVaIndex as default-heap buffers, whose VAs are
offsets in [0, arena size). A host address inside that window (low addresses, as under Wine) would shadow arena
buffers in the nearest-start lookup, so such a range is not imported and the fallback answers.
d3d12_existing_heap_test checks the two texture cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
own/main shares this mock between the slot 127 and slot 133 tests. The ported refusal also turned away
a buffer with unordered access, which the PC runtime accepts, and failed slot 133's UAV buffer case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The queue proxy's PresentX slot is past the PC chain, so nothing recorded
a present: a --trace-d3d12 run of a frame loop could not say how many
frames were presented, or whether one was refused. XboxPresentation::PresentX
now writes one line per call through d3d12_trace::result (ok or failed).
xbox_present_test captures the trace around a blank present and a refused
three-plane call and checks for exactly those two lines.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
The host runtime sizes and creates R8G8B8A8_UNORM_SRGB and B8G8R8A8_UNORM_SRGB textures with
ALLOW_UNORDERED_ACCESS (RTX 4090 617.42 and WARP). The layer created their image in the sRGB format with
STORAGE usage, which most GPUs lack, so it refused them: a retail title sizes a 2048x2048, 12-mip
R8G8B8A8_UNORM_SRGB render target with unordered access through device slot 25, got UINT64_MAX and
stopped on its 32-bit size check.
Such a texture is now a mutable image of the UNORM format of the same order (Format::uint_backed, from
#7604), where the GPU can make that image with both formats listed. Its storage view is UNORM, as every
D3D12 typed UAV of these textures is; RTVs and SRVs are sRGB, so clears and draws encode and sampling
decodes. Multisampled ones are still refused.
d3d12_srgb_uav_test compares with WARP: the retail shape's size alignment and creation, a clear
through the sRGB RTV and one through a UNORM UAV, byte for byte, for RGBA8 and BGRA8. Without the
change it fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synthetic PE32+ images built in the test (relocations, imports and delay
imports, exports with forwarders, TLS directory, .pdata/UNWIND_INFO),
field- and byte-level mutations, seeded and reproducible per case, with
--minimize in child processes. LEONIDA_LOADER_FUZZ_ASAN builds it with
/fsanitize=address under MSVC or clang-cl.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>