Commit Graph

1118 Commits

Author SHA1 Message Date
9c8522d224 d3d12_xs: slot 70 writes a raw buffer view when its words are the measured raw-buffer shape and the VA is a buffer the layer knows (retail boot chain stop 14)
AI-assisted.
2026-11-23 17:43:57 +01:00
67950a8d51 d3d12: A8_UNORM render targets through VK_FORMAT_A8_UNORM_KHR (VK_KHR_maintenance5)
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>
2026-11-23 17:42:36 +01:00
d3a1c290b5 d3d12: persist the pipeline cache across launches (D3D-704)
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.
2026-11-23 17:39:38 +01:00
588ef0b5eb d3d12: slot 133 falls back to an ordinary buffer when the driver will not import the title's pages
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>
2026-11-23 17:33:52 +01:00
efc347830b d3d12: CreateCommandSignature creates a DISPATCH_MESH signature on a device with mesh shaders
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>
2026-11-23 17:31:00 +01:00
626beeb8f7 Merge remote-tracking branch 'origin/main' into slot133-host-va
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
2026-11-23 17:23:22 +01:00
a32330f561 d3d12_xs: slot 133 review fixes: integer flag mask for clang-cl, handler registered by every Vulkan device
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>
2026-11-23 17:23:12 +01:00
9545ba80f8 d3d12_xs: device slot 133 (CreatePlacedResourceX) makes a buffer on the title's own pages
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>
2026-11-23 17:08:20 +01:00
059f79129b presenter: recover a lost surface instead of a sticky E_FAIL (#6832)
Squash-merged after diff review of PR #6832 - presenter: recover a lost surface instead of a sticky E_FAIL
2026-11-23 09:55:22 -06:00
2c72b0d281 d3d12: validate DXR acceleration-structure prebuild and recording inputs (#6825)
Squash-merged after diff review of PR #6825 - d3d12: validate DXR acceleration-structure prebuild and recording inputs
2026-11-23 09:49:28 -06:00
4d3d1e4448 d3d12: a write-combined range opens as a WRITE_COMBINE existing heap, an uncached one is refused
Measured on the RTX 4090 and WARP: PAGE_READWRITE | PAGE_WRITECOMBINE is accepted with
CPUPageProperty WRITE_COMBINE, PAGE_READWRITE | PAGE_NOCACHE is E_INVALIDARG. Two new cases in
d3d12_existing_heap_test; 8 of 8 match both host devices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:36:33 +01:00
56e607ac85 Runtime: pipeline-statistics queries around mesh draws (D3D-291) (#2359)
Squash-merged after diff review of PR #2359
2026-11-23 09:34:02 -06:00
4eeb61b301 d3d12: OpenExistingHeapFromAddress backs a heap with the caller's memory (VK_EXT_external_memory_host)
The retail executable opens the 64 KiB graphics region it has just committed with XMemVirtualAlloc
through device slot 48 right after its first queue and fence; the layer answered E_NOTIMPL and the
title asserted.

The call now answers as the host runtime does on an RTX 4090 and WARP (six cases measured in
d3d12_existing_heap_test): the base of a VirtualAlloc allocation committed read-write over its whole
size opens a heap of that size, 64 KiB aligned, CUSTOM / WRITE_BACK / L0, SHARED |
SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS; an inner address, a partial or reserve-only commit
and a read-only range are E_INVALIDARG. The backing is the range itself, imported with
VK_EXT_external_memory_host, which the device and the test device enable when present.
CheckFeatureSupport(EXISTING_HEAPS) follows the extension. Placed resources in such a heap are
refused (E_NOTIMPL, logged) until the placed path addresses memory outside the arena.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:33:40 +01:00
e76cb47fb5 Runtime: D3D12 queues share a VkQueue when the GPU has no free one (Intel UHD 770 queueCount 1), plus a CPU-signal hang fix (#5110)
Squash-merged after review of PR #5110 - Runtime: D3D12 queues share a VkQueue when the GPU has no free one (Intel UHD 770 queueCount 1), plus a CPU-signal hang fix
2026-11-23 08:11:02 -06:00
0a08dbb02b d3d12 Vulkan: align copyable footprints from BaseOffset, not from 0
GetCopyableFootprints started the layout at BaseOffset and aligned every
subresource to D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT as an absolute
address. The PC runtime lays the subresources out from 0 and adds the base
afterwards: with base 513 the host returns offset 513 for subresource 0,
ours returned 1024, and the totals differed by the gap.
GetCopyableFootprints1 wraps the same function.

compare_footprints now also runs bases 513 and 2^32 + 1 (both unaligned)
next to 0 and 1024. Against the hardware host device on an AMD Radeon
RX 7600, on main 561b65a8, the old code gives 652 mismatching fields
(offsets and totals), all at the two new bases: with only 0 and 1024 it
gives none, which is why this went unnoticed. With the fix there are none
at any base. No caller in the runtime passes an unaligned base (the only
internal caller is GetCopyableFootprints1).

AI-assisted. Tested on AMD Radeon RX 7600, driver 26.11.2 (LLPC),
Windows 10 22H2 (in-box d3d12core 10.0.19041), MSVC 14.44.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 09:31:05 -03:00
a4d7182243 Restore #4098: xdxr_build_check failed on #2753's BLAS index check, not on the builder
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:50:22 -05:00
18151aedfb Revert #4098: a second rewrite of the XDXR builder on top of #3315's, and xdxr_build_check fails with both
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:43:12 -05:00
9b232eda65 Merge pull request #4538 from kapitche
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:42 -05:00
7cf7fa7c4d Merge pull request #4508 from SHAURYASANYAL3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:23 -05:00
5426b0eacc Merge pull request #4489 from Nicolas Abosch
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:11 -05:00
38dadef55a Merge pull request #4460 from shdann
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:54 -05:00
59cba88743 Merge pull request #4454 from gabsilvs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/README.md
2026-11-22 23:14:52 -05:00
a33cf4cf3f Merge pull request #4333 from ligmaSec
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:13:40 -05:00
f54c6395ed Merge pull request #4312 from Victor Garcia
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:13:27 -05:00
b0ea417152 Merge pull request #4290 from 73N1X
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:13:10 -05:00
43f41a1d8d Merge pull request #4101 from Exopus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:17 -05:00
c42b2cbd05 Merge pull request #4098 from NiiRoZz
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:15 -05:00
433f4e12e1 Merge pull request #4088 from Exopus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:09 -05:00
b102d827d2 Merge pull request #4065 from mohamedsaad.lahlou
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:10:58 -05:00
cd5267b47a Merge pull request #4060 from sds-228
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:10:55 -05:00
2e3fd36d79 Merge pull request #3951 from Jan Trencansky
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:09:52 -05:00
c50a702d2b Merge pull request #3925 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:36 -05:00
714b80329c Merge pull request #3865 from shelbykb2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:02 -05:00
aa770dd19f Merge pull request #3835 from Emma
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:45 -05:00
65ab2bcccf Merge pull request #3833 from gertify
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:44 -05:00
7fefdb1e12 Merge pull request #3781 from Douglas Sposito
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:25 -05:00
0177e62dab Merge pull request #3780 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:25 -05:00
6af4ba333d Merge pull request #3451 from Jonathan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:07:31 -05:00
6df9cc0d18 Merge pull request #3315 from zneel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	README.md
2026-11-22 23:07:14 -05:00
6b7360453a Merge pull request #3089 from mrp1no
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:45 -05:00
769d0e5a3c Merge pull request #2887 from Rafael
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:17 -05:00
560c5676ed Merge pull request #2740 from AlxcBTW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:04 -05:00
333e3b2926 Merge pull request #2706 from 0xTehuti
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:05:59 -05:00
6a726e708d d3d12: register_literal_samplers above pick_entry's comment; its log names what it counts
pick_entry's comment had ended up above the new helper, and the log line
ended in "words" while printing the number of literal S#s. Reported by
@zzEmmazz on #2906.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:50:58 -03:00
04d020822d Merge main for reserved texture tile mapping 2026-11-23 00:47:18 -03:00
4abd83a06b d3d12: pipeline libraries answer their arguments as the host runtime does
d3d12_pipeline_library_host_test runs 46 CreatePipelineLibrary /
ID3D12PipelineLibrary1 calls that need no pipeline state object on the
Vulkan-backed device and on the host runtime, and compares each HRESULT and
what happened to the output pointer (74 values). On the host every call runs
in a child process with a fresh device: a call that faults there leaves the
runtime broken, and in-process the next call failed fast (0xC0000409). On main 25 values differed (RTX
3060, driver 610.88); now none do:

- A foreign, truncated or corrupt blob, the other device's serialized
  library, or a null pointer with a size is E_INVALIDARG, and the output
  pointer is left as it was (the layer answered DRIVER_VERSION_MISMATCH and
  nulled it). One of the layer's own blobs from another format version stays
  D3D12_ERROR_DRIVER_VERSION_MISMATCH.
- A pipeline library is a device child, not a pageable object:
  QueryInterface(ID3D12Pageable) is E_NOINTERFACE.
- Load*Pipeline with a null output is E_INVALIDARG, not E_POINTER.

Not compared, and printed as such: the serialized size and bytes (each
device's own), and the calls the host faults on (Serialize(nullptr, n),
StorePipeline with a null PSO, Load* with a null name or description), which
the layer answers E_INVALIDARG.

d3d12_pipeline_library_test expected DRIVER_VERSION_MISMATCH for a foreign or
tiny blob; it now expects E_INVALIDARG, and DRIVER_VERSION_MISMATCH for one of
ours from another version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:41:50 +01:00
f173fc0df3 d3d12: cap the GPU address arena at the device's maxBufferSize and maxMemoryAllocationSize
create_arena clamped LEONIDA_ARENA_MB to 16..4095 MiB and never read the device's buffer limits. The RX 6800
(AMD 26.11.2) reports 2 GiB for both, so LEONIDA_ARENA_MB=3000 made d3d12_compute_test fail under
LEONIDA_VK_VALIDATION=1: one vkAllocateMemory over maxMemoryAllocationSize per device. The size is now decided by
src/arena_size.h (min of the request, maxBufferSize and, for the buffer's memory requirement, maxMemoryAllocationSize,
rounded down to MiB), read with the device's other Vulkan 1.3 properties into VulkanDeviceInfo (0: query; a test sets
a smaller one), and logged once when a limit cuts the request. arena_size_test checks the decision on the CPU;
d3d12_compute_test checks the arena against the real limits and a simulated 32 MiB maxMemoryAllocationSize. Tested
on an RX 6800, Windows 11, AMD 26.11.2: ctest 133/133, and the 3000 MiB validation run now passes with no errors.

Co-Authored-By: Claude Opus <noreply@anthropic.com>
2026-11-22 20:40:03 -07:00
6b690ec3a1 d3d12: OpenExistingHeapFromAddress, OpenExistingHeapFromFileMapping and CreateLifetimeTracker answer the host's argument errors 2026-11-22 21:12:10 -05:00
b1fffe8357 d3d12: GetResourceAllocationInfo resource flag and sample quality parity (D3D-467) 2026-11-23 07:24:34 +05:30
0f0c85ccbc d3d12: committed resources accept ALLOW_SHADER_ATOMICS with a UAV
CreateCommittedResource refused D3D12_HEAP_FLAG_ALLOW_SHADER_ATOMICS on
every resource. On an RTX 4070 Laptop (621.24) and WARP the host accepts it
on buffers and textures with ALLOW_UNORDERED_ACCESS, refuses it without,
and keeps it in GetHeapProperties. Match that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:45:39 -03:00