Commit Graph

1118 Commits

Author SHA1 Message Date
c53024be39 Merge pull request #1858 from AlxcBTW
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 09:48:50 -05:00
667dbc76c9 Merge pull request #1851 from Alex Arenas 2026-11-22 09:48:45 -05:00
7886972a6b Merge upstream main
# Conflicts:
#	docs/d3d12_command_objects.md
2026-11-22 09:48:41 -05:00
2daadb7968 Merge pull request #1820 from Tomgamer 2026-11-22 09:48:26 -05:00
fb3e409fe0 Merge pull request #1817 from Alex Arenas 2026-11-22 09:48:25 -05:00
3b7cd5e4bf Merge pull request #1791 from AlxcBTW 2026-11-22 09:48:16 -05:00
cd6d8ac35a Merge pull request #1787 from CowDeV 2026-11-22 09:48:15 -05:00
c56532da45 Merge pull request #1772 from Alex Arenas 2026-11-22 09:48:13 -05:00
26a0ca32da Merge pull request #1753 from Serrambi 2026-11-22 09:48:10 -05:00
bf0ce0d062 Merge pull request #1706 from Ash Hopkins 2026-11-22 09:48:06 -05:00
54e2fee2a9 Runtime: CreateCommandSignature refuses what the host refuses
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ2Pr9JZJaj81r4m2MtQZk
2026-11-22 14:47:23 +00:00
e608a1b992 d3d12: support typeless and castable RGBA8 RTVs on MSAA textures 2026-11-22 15:44:41 +01:00
3db0860727 runtime: graphics pipelines on a Vulkan 1.2 device through VK_EXT_extended_dynamic_state(2)
The graphics pipelines use the Vulkan 1.3 core dynamic states (primitive topology, primitive restart, vertex
binding stride) and their commands (vkCmdBindVertexBuffers2, vkCmdSetPrimitiveTopology,
vkCmdSetPrimitiveRestartEnable). On a Vulkan 1.2 device these come from VK_EXT_extended_dynamic_state and
VK_EXT_extended_dynamic_state2, with the same values and signatures. Vulkan13Features now enables both where
the device has them, and device_proc_or_khr also tries the EXT name. Without them a 1.2 device still works for
compute, and graphics pipelines are refused as before.

AI-assisted. No game files.
2026-11-22 14:42:14 +00:00
c7801ac6fb Merge upstream main
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/README.md
2026-11-22 09:35:55 -05:00
537486c875 Merge remote-tracking branch 'fork/m4-synthetic-gate' into buffer-uav-typed-counter
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 15:34:07 +01:00
f209d86b8f D3D12 layer: typed buffer UAVs and UAV counters (V# FORMAT, counter V# in the slot), d3d12_buffer_uav_test
CreateUnorderedAccessView on a buffer with a typed Format writes a typed V# (GFX10_FORMAT code, element size as
stride, element count, OOB_SELECT structured, the format's own DST_SEL), and a structured view with pCounterResource +
CounterOffsetInBytes writes a second raw 4-byte V# in the upper 16 bytes of the slot (a hypothesis for the console
contract, documented in section 3.4). The combinations D3D12 documents as invalid leave a null slot.

d3d12_buffer_uav_test runs two hand-written RDNA2 compute shaders through the translator (typed store/load/atomic on
five formats with NUM_RECORDS as the bound; append by 256 lanes and consume by 128 on a counter at offset 4096, read
back with CopyBufferRegion) against a CPU reference, then compares typed-buffer and counter clears with the host D3D12
runtime on the same adapter (LUID).

Depends on: #1791

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:33:50 +01:00
57f57a825f runtime: allow explicit Texture1D SRVs on 1D texture arrays to select slice 0 2026-11-22 15:33:25 +01:00
d38daa4e9b runtime: implement ID3D12Device1::CreatePipelineLibrary and ID3D12PipelineLibrary1 2026-11-22 15:26:27 +01:00
629bcb2d99 d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates
vulkan_format() had no entry for R16_UINT, R16_SINT, R16_SNORM, R8_UINT,
R8_SINT, R8_SNORM, R8_TYPELESS, R16G16_UNORM, R16G16_SNORM,
R16G16B16A16_SNORM or A4B4G4R4_UNORM, so CreateCommittedResource refused
them with E_INVALIDARG and FORMAT_SUPPORT answered DXGI_ERROR_UNSUPPORTED
where native D3D12 creates them (item 1 of the FORMAT_SUPPORT finding in
#1380).

A4B4G4R4_UNORM keeps alpha in bits 0-3 and red in 12-15 (cleared and
read back on native D3D12, RX 9070 XT and WARP), which is Vulkan's
R4G4B4A4_UNORM_PACK16; its T# row reads that as W, Z, Y, X.

Copies get the formats' texel sizes, D16 copies pair with R16 SNORM/UINT/
SINT like the other R16_TYPELESS members, and the colour-resolve check
refuses every integer format by numeric class instead of a list that
missed R8/R16 and the SINT forms of R8G8B8A8, R32 and R32G32B32A32.

Tests: d3d12_vulkan_device creates each format (as the host does), copies
a 4x4 upload in and back out bit for bit, and clears an A4B4G4R4 render
target to R, G, B and A; d3d12_descriptor_test samples A4B4G4R4 through
a T# alongside B4G4R4A4 and B5G5R5A1.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:26:19 +01:00
0a43f80940 Runtime: drop the Intel minimum-LOD rounding from D3D-219
Rounding the view's minLod to the nearest level fixed point-filtered
samples on drivers that use minLodInteger, but integer texel fetches
and gathers use floor(minLod) on every driver, as D3D11.3 5.8 also
requires for ld and gather4. With a 0.75 clamp the rounded view gave
1.0, so a Load of mip 0 would read zero. No single view value is right
for both, so the sampling fix belongs in the translator (a MinLod image
operand on sample ops only). This keeps the bindless capacity fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:25:47 +01:00
7baf4c21ac D3D-238: refuse the heap descriptions the host refuses in CreateHeap
CreateHeap checked only for a null description and a zero size. A shared
heap_desc_refusal now also refuses an alignment other than 0, 64 KiB and
4 MiB, a heap with all three DENY_* flags, and the heap properties that
heap_properties_refusal already refuses for committed resources (a type
outside the enum such as 0, a custom heap without a CPU page property or
memory pool, a non-custom heap with either). CreateHeap1, a stub until
now, wraps CreateHeap and refuses a protected session.

Tests: direct E_INVALIDARG/S_OK checks on the standalone device for both
methods, and host comparison cases in compare_invalid_arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:25:38 +01:00
d665490a68 runtime: check SeIncreaseBasePriorityPrivilege for global realtime queues (D3D-236) 2026-11-22 15:25:02 +01:00
088447e117 FSPX programs: translated by the shaders stage, found at run time by their kind-6 bytes (RT-99)
The FidelityFX DLL creates its compute pipelines from FSPX programs (docs/fspx.md): through slot 67 with the bare
kind-6 program, then through slot 62 with the DXBC container whose ACCC part holds the payload. Both ended in
E_INVALIDARG: the layer took only FSSM bytecode, the build never translated the DLL and the index had no key for it.

- make_game.py: the shaders stage unpacks the package's DLL with tools/fspx_unpack.py --disasm into
  <work>/shaders/fspx and translates it into <work>/shaders/spirv/fspx, with the same wave64 mode and fallback
  flags. The step is redone as a whole when the DLL, its tools, llvm-mc or the flags change (fspx_build.json,
  written last) and never makes the game's shaders run again.
- tools/shader_meta.py: an entry of a program without an FSSM blob gets fspx_code_sha256, the SHA-256 of
  fspx/<name>.code.
- runtime/src/shader_library.h: the library also loads <dir>/fspx/index.json and finds entries by
  fspx_code_sha256. compute_program() takes an FSSM program as before, the kind-6 bytes of an ACCC container or of a
  bare FSPX payload, and a bare kind-6 program recognized by its prologue; the directory is parsed with the DLL
  reader's rules and bounds-checked, so a malformed one is refused.
- create_compute: looks the program up by the key of its kind and uses those bytes as the code base.
- Tests: shader_library_test (parsing, malformed directories, lookup, the fspx folder), d3d12_fspx_compute_test
  (PSOs from both forms, a dispatch each, refused inputs) and tests/test_fspx_shaders_stage.py.
- Docs: the lookup in docs/fspx.md; slots 62 and 67 in d3d12_command_objects.md and d3d12_vulkan.md. The size the
  slot-67 description carries at +0x30 is kind 6's own size, read from the DLL's code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:22:54 -05:00
7f38b0755b Revert "Merge pull request #1779 from cobalt-pebble-804"
#1779 (the #895 rebase) writes placeholder ShaderView records (kind, resource id, offset) into CBV/SRV/UAV slots
and adds a second CreateConstantBufferView next to #1729's, so the runtime no longer compiled. main's descriptor
slots hold GFX10 V#/T# words that translated shaders read; #1729's CBV already writes the raw buffer V#.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:21:42 -05:00
eebf85b60f Merge remote-tracking branch 'origin/main' into runtime-vulkan12-khr
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/vk_test_device.h
2026-11-22 14:21:37 +00:00
2d2eec9a75 M4 review: storage-image init only on shader-running non-copy submissions, ordered for other queues
- The zero-fill/GENERAL init of images with a UAV view no longer drains on a copy
  queue or in a submission that runs no dispatch or draw; every other queue's next
  submission waits on the initializing one's progress semaphore.
- storage_pending_ is a set (UAV descriptors are rewritten every frame).
- write_buffer_uav: FirstElement and element count are checked against
  Width / unit, so the byte range cannot overflow.
- docs: M4 row names the remaining limitation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:21:28 +01:00
74205e9d78 d3d12: enforce DENY_* heap flags for all placed resources (D3D-222) 2026-11-22 15:16:07 +01:00
ef15a21ba0 Merge pull request #1789 from romainveurrier 2026-11-22 09:15:22 -05:00
959505bae1 Merge pull request #1787 from CowDeV 2026-11-22 09:15:21 -05:00
542586de8a Merge pull request #1779 from cobalt-pebble-804 2026-11-22 09:15:17 -05:00
b78819439f Merge pull request #1753 from Serrambi 2026-11-22 09:15:05 -05:00
24abd3dde4 Merge pull request #1749 from Alex Arenas 2026-11-22 09:15:03 -05:00
b6135472da Merge pull request #1739 from Alex Arenas 2026-11-22 09:14:59 -05:00
b28487c827 Merge pull request #1729 from Vonsek 2026-11-22 09:14:55 -05:00
da574cb90e Merge pull request #1714 from SWAYAM 2026-11-22 09:14:53 -05:00
22baad5ec7 Merge pull request #1702 from Sagah123 2026-11-22 09:14:51 -05:00
c2f39447b6 Merge origin/main into m4-synthetic-gate 2026-11-22 15:13:40 +01:00
967564a20c M4 (synthetic): d3d12_m4_compute_test, UAV table, indirect dispatch, copy queues; buffer UAV views and indirect dispatch state
d3d12_m4_compute_test, through the proxy with D3D12 API only and two
translator-output compute shaders (cs_m4_fill.asm, cs_m4_indirect.asm):
a COPY queue streams an input buffer in, a COMPUTE queue waits on it and runs a
compute PSO over a UAV table (structured buffer, raw buffers, an R32_UINT
RWTexture2D), then ExecuteIndirect of a second PSO from arguments the first
wrote (with a transition to INDIRECT_ARGUMENT and UAV barriers), and a COPY
queue behind a cross-queue fence reads the results back. 1,924 words match the
CPU reference with error 0.

Layer gaps the test found, fixed:
- CreateUnorderedAccessView of a buffer was a stub: structured and raw views are
  now a V# in the slot.
- ExecuteIndirect of a dispatch ran whatever pipeline and root arguments the
  command buffer had bound; the command now carries the list's, as Dispatch does.
- An image created in UNORDERED_ACCESS and first used by a shader was
  zero-filled by the first barrier or copy that named it, losing the shader's
  writes; images with a UAV view are now moved to GENERAL (zeroed) at the next
  submission.
- COMPUTE and COPY command lists no longer log "unimplemented".

Test infrastructure: vk_test_device.h can create more than one VkQueue;
build.py gives a compute shader's FSSM program extra words (fssm-at/fssm-data
from 0x148) so two compute shaders with the same group size get distinct hashes,
and honours LEONIDA_SPIRV_TOOLS (as #1679) so the target builds under the Visual
Studio generator. docs/d3d12_vulkan.md section 6: M4 synthetic part met; M3 row
credits @whattheflop's #1584 measurement of fences in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:09:58 +01:00
f6d6121c9c XDXR builds: PERFORM_UPDATE refits instead of rebuilding
An update (same topology, new positions or instance transforms) now keeps the
source's tree and recomputes its boxes: the source is copied to the
destination unless it is the destination (MODE_COPY), the elements are
rewritten at their slots, MODE_LEVEL with arg2 = 1 recomputes each node's
boxes from the children it already points to, and the header gets the new
bounds. No Morton pass, no sort, and the parent table is kept.

RTX 2050: 1,000 triangles 0.07 ms (build 0.19), 100,000 1.02 ms (2.24),
1,000,000 9.8 ms (22.0); Iris Xe 13.1 ms for 1M (47.9).

- XdxrBuilder::record_blas / record_tlas take `update_from`; the Vulkan
  backend passes the source (or the destination, for an in-place update)
  when the D3D12 build has PERFORM_UPDATE.
- vk_xdxr_build_test: a 3,000-triangle BLAS refitted in place (radix-sort
  tree), an R32-indexed grid refitted into another buffer (its untouched
  source is checked too), and the TLAS refitted after its instances move;
  the timing mode also times refits.
- d3d12_xdxr_rt_test: the BLAS is built with ALLOW_UPDATE, its soup moves,
  and a PERFORM_UPDATE in place is checked as d3d12_blas_update.
- tools/xdxr_bvh.py check-build: the case being checked answers reads at its
  address first (an in-place update leaves two dumps at one address).

A sabotaged refit (no box pass) fails every update case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:09:14 +01:00
e2ec3a8448 Runtime: exact minimum-LOD views and full bindless set on Intel Xe-LP (D3D-219)
d3d12_descriptor failed every run on an Intel UHD 770 (101.7092) for two
reasons, both from the driver taking an option the Vulkan spec allows:

- VK_EXT_image_view_min_lod: the driver selects levels with
  minLodInteger = floor(minLod), the spec's "alternative", so a 0.75 or
  1.75 ResourceMinLODClamp read one mip too detailed. On Intel integrated
  GPUs bind_image now passes the clamp rounded to the nearest level,
  which point mip filtering selects exactly.
  LEONIDA_MIN_LOD_INTEGER=1/0 forces it either way.
- The bindless set stayed at its default counts (4096 2D images, 1024
  samplers) because the driver reports maxPerSetDescriptors = 6159 with
  every other limit at 1048576. size_bindings now takes an optional
  layout_supported callback, and past maxPerSetDescriptors the device
  asks vkGetDescriptorSetLayoutSupport about the grown layout.
  bindless::SetLayout describes set 0 once for create_layout and that
  query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:08:32 +01:00
eda19ca1d2 feat(runtime): add D3D12 CBV/SRV/UAV buffer views 2026-11-22 11:05:55 -03:00
af236e196b d3d12_xs: route slot 67 compute pipeline from native code to CreateComputePipelineState (RT-99)
Xbox device slot 67 takes (desc, riid, out) with IID_ID3D12PipelineState and a console-only
descriptor with the root signature at +0x00 and code blob pointer/size at +0x28/+0x30.
Previously it logged and returned E_NOTIMPL.

Route it to CreateComputePipelineState on the PC device (slot 11) like slot 62, mapping the
console descriptor to D3D12_COMPUTE_PIPELINE_STATE_DESC. On the Vulkan device this resolves
through the translator via fssm_program and ShaderLibrary.

- Implement proxy_create_compute_pipeline_from_native_code in d3d12_xs_device.cpp
- Update device_proxy_test to verify slot 67 thunk, compute PSO creation over WARP, and argument checks
- Update d3d12_compute_test to verify slot 67 compute PSO creation on the Vulkan device
- Update documentation in d3d12_command_objects.md and d3d12_vulkan.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:34:10 +05:30
af0453281d d3d12: support multisampled placed textures (D3D-222) 2026-11-22 15:02:35 +01:00
41ceb016c2 runtime: remove duplicate bind_image call in write_image_descriptor 2026-11-22 14:50:41 +01:00
ea879b5ca4 d3d12_vulkan_device.cpp: fix swapchain maintenance1 header guard syntax and scope 2026-11-22 14:50:34 +01:00
e451cf248a d3d12_vulkan_device.cpp: guard swapchain maintenance1 features with macro check 2026-11-22 14:49:15 +01:00
e8ac3266e7 d3d12_vulkan_device.cpp: guard swapchain maintenance1 features with macro check 2026-11-22 14:48:21 +01:00
be6ebf0e91 runtime: set binding.va and host_readable on placed buffers 2026-11-22 14:45:46 +01:00
19b261bb99 Merge remote-tracking branch 'origin/main' into runtime-vulkan12-khr
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/vk_test_device.h
2026-11-22 13:45:11 +00:00
5c6ff05950 feat(runtime): implement ID3D12Device::CreateConstantBufferView (GFX10 V#)
Write a 16-byte GFX10 raw buffer V# descriptor (48-bit BufferLocation, stride 0,
num_records = SizeInBytes, GFX10_FORMAT_32_UINT, OobSelect::raw) into the
32-byte CBV_SRV_UAV descriptor slot, zeroing the trailing 16 bytes (or the full
slot for a null description, zero BufferLocation, or zero SizeInBytes).

Verified on Windows 11 with RTX 5080 and Radeon Graphics in d3d12_compute_test:
64/64 dwords matched for CBV A, 32 in-bounds + 32 OOB-zero matched at +128, and
negative controls flipped 64/64 dwords for CBV B and null CBV.

AI Assisted.
2026-11-22 14:41:17 +01:00