The title's first call on a wrapped list is QueryInterface with the
console command-list IID c3827890-...-51dc4874; is_list_iid knew only
PC IIDs and refused it. Port the measured console->PC IID table from
(closed, unmerged) #7124 into d3d12_xs_command_list_iid.h and run the
requested IID through it in list_query_interface and in the PC-mode
slot-73 path, so a console IID maps to ID3D12GraphicsCommandList6 and
the caller gets the console-shaped proxy back.
The retail title's first native pipelines name an A8_UNORM render target
(@KkelebekK's RT-5 measurements). The layer stored every A8_UNORM texture as
R8_UNORM with a swizzled SRV and refused render targets.
Where the GPU has VK_KHR_maintenance5 and can sample VK_FORMAT_A8_UNORM_KHR and
blend it as a colour attachment, gta6rt enables the extension and its feature
(VulkanDeviceInfo::a8_render_target), and an A8_UNORM texture created with
ALLOW_RENDER_TARGET is stored in that format:
- its RTVs and the PSO's RTVFormats use it, so draws, blends and clears write
the alpha channel (the clear quantizes alpha like the other UNORM formats);
- its SRVs view the image in the same format. Vulkan puts A8 in a compatibility
class of its own, so it cannot share an image with an R8 view: gfx10's format
table gains an 8_UNORM row for it whose one channel X is alpha (channels_a),
and the T#'s (0, 0, 0, X) becomes (ZERO, ZERO, ZERO, A) on that view;
- CheckFeatureSupport adds RENDER_TARGET and BLENDABLE for A8_UNORM;
- the copy paths know its one-byte texel.
Other A8_UNORM textures stay R8_UNORM, and devices without the format refuse
A8 render targets as before. Depth-stencil and UAV stay refused.
Tests (both on an RTX 3060 and an Intel UHD 750, with Vulkan validation):
- d3d12_clear_formats: A8_UNORM joins the WARP comparison (was "not exposed");
- d3d12_descriptor_test: format support and creation follow the device; an A8
render target's default and remapped SRVs sample like the R8-backed ones;
- d3d12_draw_test: a full-screen draw and two alpha blends into an A8 target;
- gfx10_descriptors_test: the A8 row and its view mapping.
vk_test_device.h enables maintenance5 like gta6rt, so the whole suite runs
with it: ctest gives the same failures as main on both GPUs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- INSERTQ xmm, xmm took the length and index from swapped fields. The APM (vol. 4) has the length in
xmm2[69:64] and the index in xmm2[77:72]; a Ryzen 9800X3D and a Ryzen 5700X agree (TheHoracio,
Mayzkl on #7111). The measured 0x0810 case is a unit check now.
- INSERTQ/EXTRQ zero xmm1[127:64], as the Zen 3 measured in the same review does in all four forms.
- Decode REX bytes among the legacy prefixes (a non-final REX is ignored) and accept F2/F3 on CLZERO,
as Zen 3 runs them (#7055's reviews); F2/F3 stay #UD on MONITORX/MWAITX.
- Check the CLZERO line's page and the instruction bytes' readability with VirtualQuery instead of
catching a fault in a local __try, which clang-cl without /EHa does not cover for inline stores
(venetanji on #7111).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PSOs a session built were compiled again by the next one. The layer already read the `pipelines` stage's
pipeline_cache.bin beside gta6rt.exe (#367), but never wrote anything back.
Now the runtime keeps its own cache in pipeline_cache.session.bin beside it: vkGetPipelineCacheData on device
teardown, then vkMergePipelineCaches into the cache at the next launch. Vulkan takes one blob per create, so the
offline seed and the session file are two caches merged together rather than one file. They are deliberately
separate files, so a run can never replace the multi-GB corpus cache with the handful of pipelines it compiled.
The write is capped at 256 MiB (LEONIDA_PIPELINE_CACHE_BYTES=<bytes>, 0 turns it off): a cache seeded from the
corpus comes back as the whole union, which is not worth rewriting at every exit; past the cap the previous
session file is left alone. A foreign or truncated session file is ignored with one line, and so is a failed
write (a read-only install directory).
The header check moves to runtime/src/pipeline_cache_store.h, shared with the offline seed and tested without
Vulkan (runtime/test/pipeline_cache_store_test.cpp: the limit parser and the 32-byte
VkPipelineCacheHeaderVersionOne comparison). write_pipeline_cache_file moves from runtime/test to runtime/src so
the runtime and vk_pipeline_check use the same staged write.
Not run: this machine has neither MSVC nor the Windows SDK, so the shim itself is compiled by the Windows job.
The portable test passes here (23/23 ctest on Linux). The end-to-end check needs a Vulkan GPU: run
d3d12_vulkan_device_test twice and look for "wrote N bytes to pipeline_cache.session.bin", then "merged N bytes"
on the second run.
The title's stop-17 range holds two 3840x2160 RGBA8 targets at 510 SW_64KB_D tiles each.
AMD's Windows driver answers 513 x 64 KiB for that target, so leasing max(PC, console)
overran the range and hit an int3 inside the title's hook (measured by controldebils on
an RX 6900 XT). A listed render-target shape now leases its whole tiles; anything else
leases the PC size. The mock gets a driver bias to reproduce the AMD answer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RADV under Wine refuses to import a view of a pagefile-backed section (E_OUTOFMEMORY on an RX 9070 XT,
found in review), which is the form xmem's physical pages take, so the retail boot stopped at the first
174 MiB placement. An import failure other than a misaligned VA now gives an ordinary DEFAULT buffer of
the same description, as #6915's stand-in did, logged once: the boot goes on, and the title's writes at
that VA don't reach it on such a driver.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Vulkan layer created signatures for draw, draw-indexed and dispatch only and answered E_NOTIMPL
for DISPATCH_MESH, which the PC runtime creates on any mesh-shader tier 1 device. A title that
creates such a signature at startup and asserts on the result stopped there.
The signature is created when the device has VK_EXT_mesh_shader (MeshShaderTier 1), as a new
IndirectKind::dispatch_mesh (the name and value #3777 uses, so the two merge). ExecuteIndirect with
it records nothing yet and says so once; #3777 replays it as vkCmdDrawMeshTasksIndirectEXT.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Loader::initialise(Module&) called every DllMain(DLL_PROCESS_ATTACH) with
lpvReserved NULL. Microsoft's DllMain reference: "If fdwReason is
DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads and non-NULL for
static loads." The executable gta6rt maps and the DLLs it imports are the
static case; a run-time LoadLibrary (load_runtime_module) and a
GetProcAddress forwarder (resolve_module_export) are dynamic.
Each Module now records whether it was mapped inside a run-time load, and a
static module's DllMain gets a pointer to a CONTEXT captured for the call.
TLS callbacks and the process detach in ~Loader (an unload: NULL) are
unchanged.
loader_test: a host load() + initialise() must give a non-NULL lpvReserved
(fails on main), the same image through load_runtime_module NULL. The
lifecycle observer checks lpvReserved on detach only.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The retail title calls slot 74 once; the PC slot 74 reads the first pointer as kinds and returns E_INVALIDARG, so the title hits an int3. The proxy handler does not call the PC device, writes nothing, logs the three words once, and yields to an env slot override that moves a route onto 74.
Upstream's device routes Xbox slot 73, but returned the real PC list
unwrapped: the title's next console-slot call read through the PC
vtable. With console_lists the device now builds the real list as
ID3D12GraphicsCommandList and wraps it like the slot-12 path; a
console IID is answered by the list proxy's QueryInterface.
The d3d12_xs shim's device now hands callers console-shaped command
lists (160-slot vtable, object body at +0x18 with the write cursor
pinned at the record limits, console slots 27-30 recorded not
forwarded, slot map measured to the PC table: 60->58, 61->59,
146->80). Queue layout detection is atomic and device-wide; SignalX
(slot 23/25 by layout) forwards as Signal, PresentX (30/32) reaches
the presentation core, and ambiguous slot 18 serves the timestamp-
frequency getter until the layout is proven.
AllocateUploadMemory (console slot 148) carves a bump arena out of
persistently-mapped UPLOAD-heap buffers; the six root-VA setters and
the IA/SO view setters translate arena pointers to buffer device
addresses in proxy-owned copies. Impossible sizes and non-power-of-
two alignments are refused before any arithmetic that could wrap.
PC-compiled callers opt into real PC-shaped lists with
console_lists=false on create_device_proxy, and PC-compiled guests
with LEONIDA_D3D12_LISTS=pc — the fixture path check_tiny_frame.py
sets, so a guest ClearRenderTargetView at PC slot 48 reaches the
real list. The GPU tests take the flag; unmeasured console slots
stay console-shaped for the title path.
docs/d3d12_xs_console_abi.md records the measured ABI.
Split from #2490 (third of three): fixes the run_tiny_frame failure
the revert reported. AI-assisted. Hardware verification on the
earlier identical code is in #2490's thread (RTX 3060 Ti-5080, RX
7600/9060/9070/7900 XT, Intel UHD, RADV; 177/177). Wine/clang-cl on
the build host: xs_proxy_mock PASS incl. the overflow regression,
queue_proxy child-runner section fails identically on unmodified
main (Wine env), loader_test 86/0 upstream count.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The retail executable calls fence slot 12, one past ID3D12Fence1, as
(value, descriptor, flags) and reads the return as a pointer to the
fence's 64-bit completed value: it compares it with ~0 and subtracts the
value it waits for. The proxy refused it with E_NOTIMPL, which the title
then dereferenced.
Each fence now gets a mirror on its first slot 12 call. A wait-thread
callback reads the real fence's completed value into it and re-arms
SetEventOnCompletion(value + 1), so it follows every completion without
another call; slot 12 and the CPU Signal refresh it at once, under a lock.
After device removal it holds ~0 and nothing is re-armed. The release of
the proxy unregisters the wait before the real fence goes. The
descriptor's code pointer is not called.
Tests: xs_proxy_mock_test (mock fences now keep a completed value and
arm one event) and queue_proxy_test (a real queue signal reaches the
mirror).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PC flag mask was a D3D12_RESOURCE_FLAGS constant past the SDK's last enumerator, which clang-cl with
SDK 10.0.26100 refuses as a constant expression; it is an integer now, cast after the AND. The slot-133
handler was registered in create_vulkan_device only, so the standalone device gta6rt --run creates never
served the slot; the Device constructor registers it now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DeviceState::share() (runtime/shims/d3d12_vulkan_device.cpp) only sets
VK_SHARING_MODE_CONCURRENT when the device has >= 2 queue families; Vulkan
VUID-VkBufferCreateInfo-sharingMode-00914 forbids CONCURRENT with <= 1
family. On GPUs that expose only one sparse-capable graphics/compute/transfer
queue family (such as Intel UHD Graphics 770 Xe-LP, whose second family is
VK_QUEUE_VIDEO_DECODE_BIT_KHR only), d3d12_sparse_queue_family_test passes
with valid EXCLUSIVE sparse buffers and zero Vulkan validation errors, but
check_sparse_queue_family.py failed expecting CONCURRENT with >= 2 families.
Inspect vkCreateDevice and the same physicalDevice's
vkGetPhysicalDeviceQueueFamilyProperties in the api_dump trace (mirroring
runtime/src/queue_families.h). When the physical device genuinely exposes
only one sparse-capable family and vkCreateDevice created one family, still
validate that every sparse VkBuffer uses EXCLUSIVE with count=0 and that the
Khronos validation pass reports zero errors, then exit 77 (CTest skip).
Multi-family physical devices remain strictly enforced even if vkCreateDevice
erroneously drops to one family.
Leonida reports OPTIONS5.RaytracingTier == NOT_SUPPORTED even when XDXR or KHR
acceleration structures are active, so run_suite() had a skip path (exit 77)
when GetRaytracingAccelerationStructurePrebuildInfo returned zero. However,
make_buffer() allocated RAYTRACING_ACCELERATION_STRUCTURE buffers earlier in
run_suite(), which CreateCommittedResource refuses when neither backend is
available (such as d3d12_dxr_validation_khr with LEONIDA_RT_AS=khr on a GPU
without VK_KHR_acceleration_structure). That made the skip path unreachable
and turned a non-RT GPU skip into exit 1.
Move the minimal BLAS PrebuildInfo probe ahead of synthetic buffer allocation
so non-RT GPUs cleanly exit 77 in d3d12_dxr_validation_khr while XDXR and
RT-capable KHR runs remain unchanged.
105 is outside D3D12_INDIRECT_ARGUMENT_TYPE's range [0, 15], so clang-cl
rejects a constant expression that casts it to the enum (reported by
umnitus on #7163). The handler now reads each argument's Type field as a
uint32_t through memcpy and compares it with 105; the test writes and reads
the raw value the same way, and the mock records it the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the console a committed resource's memory is allocated with XMemAlloc, so it goes
through the title's __XMemAllocationHooks__. The retail title budgets its first
full-screen render targets with a per-thread hook that bump-allocates out of a range it
reserved and asserts that less than 2 MiB is left; PC resources never allocated through
the hooks, so the assert always fired. Slots 76 and 127 now allocate the slot-25 size of
each resource through the hooks, held by the resource with SetPrivateDataInterface and
freed when it is destroyed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The retail executable imports GameInputCreate from GameInput.dll by ordinal 1. The loader looks ordinal imports up
as "#1", which the shim table did not have, so the import bound to the host's GameInput.dll. On Windows the
installed GameInput answers; under Wine it is the builtin stub, the call fails and the title stops on its result.
The alias maps #1 to the same GameInputCreate, and gameinput_test checks it.
Conflicts in vk_store_test.cpp and vk_texture_test.cpp: both new includes (vk_validation.h and spirv_capability.h) are kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Xbox device slot 133 is (va, desc, state, clear, riid, out): the title places a buffer at the VA of a
physical-page range it has just mapped (docs/retail_boot_chain.md 3.4, #6915). The proxy now hands it to
a handler the Vulkan layer registers (set_placed_at_va_handler), which imports [va, va + width) with
VK_EXT_external_memory_host and binds a VkBuffer to it: the CPU's writes there are the GPU's reads with no
copy, and the resource's console VA is the title's VA, so views and immediate writes the title names by
that VA resolve to it through the buffer VA index. The Xbox flag bits above the PC ones are dropped and
the layout made ROW_MAJOR, as slot 76 does; textures are E_NOTIMPL, a misaligned VA E_INVALIDARG, and
with no handler (a PC device) the slot refuses with E_NOTIMPL as #6953's table does.
Not decided here: a shader that adds heap_base to the title's VA (its own V#s) does not reach these
pages; that needs the single address space of docs/d3d12_vulkan.md 3.3.
d3d12_existing_heap_test: on a VirtualAlloc range and on a view of a pagefile-backed section (the form
xmem's physical pages take), the buffer's GPU VA is the address and a GPU copy to a READBACK buffer reads
a pattern the CPU wrote after creation; Vulkan validation clean on an RTX 4090.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A line CLZERO cannot write now reaches the next handlers as the access violation (or guard-page
violation) the instruction raises, with the write flag and the line address, instead of the #UD.
The 66 prefix and segment overrides are accepted on CLZERO/MONITORX/MWAITX; F2/F3 (other
instructions there, F3 0F 01 FA is MCOMMIT) and LOCK stay #UD. Points raised by SirKingg on #7055.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>