Commit Graph

1118 Commits

Author SHA1 Message Date
c68a35bcb4 Merge pull request #2109 from TheHoracio 2026-11-22 13:13:02 -05:00
4d64f9a68f Merge pull request #2069 from AlxcBTW 2026-11-22 13:12:59 -05:00
db317bd3ee Merge pull request #1947 from Jolymmiles 2026-11-22 13:12:44 -05:00
60cc47cb79 Merge pull request #306 from IAmNotSiob 2026-11-22 13:12:26 -05:00
e8602fdfae runtime: address shader-cache session review feedback (D3D-34 follow-up)
Follow-up on merged 2d848a33 (#2167) addressing @Flyander's 7 review items:
1. Enforce version mismatch on live sessions (DXGI_ERROR_ALREADY_EXISTS) and clear+recreate on reopen after all sessions close.
2. Discard MODE_MEMORY stores on final release (in-memory sessions do not persist across full teardown).
3. Return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE on FindValue/StoreValue while ShaderCacheControl DISABLE is active.
4. Make ShaderCacheControl CLEAR remove inactive default-directory disk cache files left by prior runs.
5. Bound disk-file deserialization against actual file_size and max_file_bytes before allocating or reading.
6. Apply documented zero-limit defaults (1 KiB value, 128 entries, 128 MiB file) and return DXGI_ERROR_CACHE_FULL when limits are exceeded.
7. Use unique per-writer temp filenames (<pid>.<tid>.<seq>.tmp) for atomic disk flushes.

Verified on Windows 11 + NVIDIA GeForce RTX 3060 (621.24, Vulkan 1.4.357, LEONIDA_VK_VALIDATION=1): d3d12_shader_cache_test passed (0 validation errors).
2026-11-22 19:11:35 +01:00
c43bc3df9d d3d12: CheckFeatureSupport refuses undefined root signature versions
The layer clamped every HighestVersion above 1.1 to 1.1 and returned S_OK.
The host only does that for versions it defines: on an RTX 4070 Laptop
(621.24) and WARP, anything above 1.2 is E_INVALIDARG with the value left
unchanged. Keep the clamp for 1.2 and refuse the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:10:23 -03:00
21f2585a48 Merge remote-tracking branch 'origin/main' into bindless-per-queue-retire
# Conflicts:
#	runtime/test/d3d12_descriptor_test.cpp
2026-11-22 19:08:58 +01:00
e8a23c1afc Retire bindless table generations by timeline instead of waiting for the device (D3D-314)
A flush that grows the table or changes live keys now makes a new generation (table buffers, descriptor set, descriptors rewritten from a CPU shadow) that replay binds, and frees the old one once every submission up to its ticket has completed. No vkDeviceWaitIdle. Adds d3d12_bindless_churn_test and the LEONIDA_BINDLESS_IDLE_WAIT=1 comparison knob.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:05:06 +01:00
c226964ea0 d3d12: WriteToSubresource/ReadFromSubresource answer as the host runtime does
d3d12_subresource_copy_test runs the same 117 steps on the Vulkan-backed device
and on the host runtime: textures in write-back and write-combine custom heaps,
a volume, an array, BC1 blocks, a buffer, an upload-heap buffer, a default-heap
texture and a multisampled one; whole and boxed copies, boxes outside, empty,
inverted or cutting a block, subresources past the last, pitches too small or
0, and copies before Map. It records every HRESULT and a hash of the whole
destination of every read, once per copy path (host image copy and staging).
On main 17 steps differed (RTX 3060, driver 610.88); now none do. The host's
rules:

- a box is refused only when its right, bottom or back edge lies past the
  mip's, or it cuts a compressed block; an empty or inverted box that passes
  those checks is S_OK and copies nothing (the layer refused it);
- the row and depth pitches are not checked: rows or slices that overlap are
  copied in order (the layer refused a pitch smaller than a row or slice).

Not compared, and reported as such: null data (the host faults; the layer
still answers E_INVALIDARG), which bytes win when a read's rows overlap (the
driver's copy order, tiled on NVIDIA), and a default-heap texture, which the
host refuses and the layer copies on purpose, as docs/d3d12_vulkan.md says.

d3d12_vulkan_device_test's cpu_copies expected the old refusals for an empty
box and overlapping slices, and now expects S_OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:04:31 +01:00
ccc7cf8f3c Merge remote-tracking branch 'upstream/main' into d3d-msaa-quality-levels-host 2026-11-22 17:52:50 +00:00
90555270cb Reject R1_UNORM and keep output for unknown formats in MULTISAMPLE_QUALITY_LEVELS; fix flag type name
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:50:24 +00:00
a78c36ae51 d3d12: acceleration-structure state only on a device that has them
@aguedou-34 measured on #2462 that an integrated Radeon without DXR (OPTIONS5
reports no ray tracing) refuses a UAV buffer created in
RAYTRACING_ACCELERATION_STRUCTURE state, which an RTX accepts. The layer now
accepts that state only where it has acceleration structures (KHR builds, or
the XDXR records with the GPU address arena), for committed, placed and
reserved resources alike, and refuses it elsewhere.

d3d12_vulkan_device_test compares the existing committed case on the device
main builds (no acceleration structures) only with a host without ray
tracing, and two new cases on the standalone device (committed and placed)
only with a host that has it; otherwise they are reported as not comparable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:43:48 +01:00
98b0335c6c d3d12: log when an allocation spills from DEVICE_LOCAL to host memory (D3D-299) 2026-11-22 18:33:06 +01:00
7a9bebd226 Runtime: CheckFeatureSupport(FORMAT_SUPPORT) answers UNKNOWN and unlisted formats as the host does
Measured against the host D3D12 runtime (RTX 5070, driver 621.14):
UNKNOWN is a buffer format (S_OK, Support1 = BUFFER), and a value the
runtime's format table has no entry for is E_FAIL: 116-188, which
includes the planar video formats P208/V208/V408 at 130-132, and 192 and
up. The layer answered DXGI_ERROR_UNSUPPORTED for both.

compare_invalid_arguments gets 11 "format support:" cases, comparing the
HRESULT and Support1. Support2 is not compared, because the host's
TILED is a GPU capability the layer doesn't offer. The local check that
expected UNKNOWN to fail now expects the host's answer. 115, 189 and 191,
the table's edges, must not be E_FAIL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:29:43 +01:00
eac6e0cee8 Match host multisample quality level query validation
Follow RTX 5070 / 621.14 measurements from upstream #1991; preserve tiled-resource rules and cover host answers synthetically.

AI-assisted.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:26:17 +00:00
1ace3ac642 Merge remote-tracking branch 'origin/main' into d3d12-queues-v2
# Conflicts:
#	runtime/src/vulkan_backend.h
2026-11-22 18:21:38 +01:00
9b50f17532 Runtime: one required-subgroup-size struct per graphics stage (VS, GS, PS)
The recipe kept two VkPipelineShaderStageRequiredSubgroupSizeCreateInfo, one
per stage of the old VS+PS table; with a GS the PS's subgroup request wrote a
third one past the array, into the recipe's attribute vector (found by
@0xTehuti on #2109). The array now has three entries and a static_assert ties
it to the stage table.

d3d12_geometry_test's PS asks for a 32-wide subgroup, so a VS+GS+PS pipeline
fills the third struct: without the fix the test crashes (3 of 3 runs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:05:49 +01:00
2a015677b3 Runtime: geometry shaders in graphics PSOs (VS + GS + PS)
CreateGraphicsPipelineState refused any desc.GS, although all 195 geometry
shaders translate (triangles in, a triangle strip out; docs/design.md
"Geometry shaders"). The stage table now holds VS, GS and PS; a GS needs the
geometryShader feature (enabled on the standalone and test devices where
the GPU has it, E_NOTIMPL otherwise), and the PSO's topology type must be
TRIANGLE, the GS's input (E_INVALIDARG otherwise). The push-constant range
names the geometry stage only where the device has it. Hull, domain and
stream output stay refused.

d3d12_geometry_test (in ctest): a GS that emits each triangle twice, against
a pipeline without one, and a line topology refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:05:49 +01:00
1240e41494 Fix Windows SDK 10.0.26100 D3D12 compatibility 2026-11-22 18:05:26 +01:00
076149b744 d3d12: placed and reserved resources answer their arguments as the host does
compare_placed_reserved (d3d12_vulkan_device_test) runs 76 CreatePlacedResource
and CreateReservedResource cases against the host runtime on the standalone
device. On main 31 of them differed (RTX 3060, driver 610.88):

- CreatePlacedResource checked none of the description, initial-state and
  clear-value rules CreateCommittedResource has, and checked a plain texture's
  size against nothing: a texture larger than its heap, or past its end, was
  accepted. A small texture (4 KiB alignment) at a 4 KiB offset was refused.
- CreateReservedResource checked those rules only for textures (through the
  committed backing) and never the initial state or clear value.
- Both answered a null output with S_FALSE; the host checks the arguments,
  then answers E_UNEXPECTED.

The initial state was not checked for committed resources either. The host
takes exactly GENERIC_READ, one write state alone (RENDER_TARGET,
UNORDERED_ACCESS and DEPTH_WRITE with their flag), or a mix of read states on a
texture; any bits on a buffer except the acceleration-structure state without
UAV access. initial_state_refusal holds that rule, in committed_resource_refusal,
so committed, placed and reserved resources share it; 23 "committed: ... state"
cases pin it in compare_invalid_arguments.

A placed buffer in an upload or readback heap takes any initial state on the
host (a committed one must start in GENERIC_READ or COPY_DEST); UAV access is
refused there as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:02:11 +01:00
6670b2bca0 d3d12: order timestamp resolves after their writes on MoltenVK
On Apple GPUs MoltenVK samples a vkCmdWriteTimestamp in a blit pass of its own at the end of the current Metal
encoder. Nothing orders the vkCmdCopyQueryPoolResults resolve after that pass. The copy read the old value, or 0 for
a timestamp never written, so d3d12_vulkan_device failed under Wine on a Mac (t1 == 0). A minimal Vulkan program
reproduces it natively on MoltenVK 1.4.3 and 1.4.2: the copy was right 0 to 43 times in 200, in the same command
buffer, the next one or the next submit. KosmicKrisp and llvmpipe were right in every case.

Where driverID is MoltenVK, the queue sets and waits for a fresh VkEvent before each timestamp resolve that copies.
A submission with such a resolve also waits on the queue's timeline for the submission before it. Both measured
200/200 and 500/500. The timestamps are still the GPU's own. The events go back to a pool after a host reset once
their submission completes. d3d12_vulkan_device also checks a resolve in the execution after the write. Documented
in docs/d3d12_vulkan.md section 4.6.
2026-11-22 21:00:39 +04:00
78e83dec6f Runtime: GetCustomHeapProperties names node 0 where it has no answer, as the host does
For CUSTOM, an unknown heap type and a node mask other than node 0, the
layer answered an all-zero D3D12_HEAP_PROPERTIES. The host runtime
(RTX 5070, driver 621.14) answers the same zeros, but with node 0 in
CreationNodeMask and VisibleNodeMask. The masks are now set first, for
every answer.

d3d12_fence_timing_test compares those four cases with the host too:
CUSTOM on node masks 0 and 1, type 99 and UPLOAD on node mask 2. Before,
only DEFAULT, UPLOAD and READBACK were compared. Its local check of the
CUSTOM answer now includes the memory pool and the masks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:58:40 +01:00
64b24f69fd SHADER-378: dynamic --f16-interp-fallback packing and per-pipeline SPIR-V half linking 2026-11-22 13:57:55 -03:00
97daa1aec0 Merge origin/main into presentx-planes
Keeps the swapchain_colorspace enable and main's custom border colour extension in
create_vulkan_device_standalone; the present compose path follows main's LayoutPieces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:51:53 +01:00
f2d7501f1d Merge pull request #2308 from AREA52 Agent 2026-11-22 11:44:03 -05:00
3fd09d4ecd Merge pull request #2232 from Jolymmiles 2026-11-22 11:43:11 -05:00
b3a5411ce0 Merge pull request #2186 from fearkov
# Conflicts:
#	docs/design.md
2026-11-22 11:42:36 -05:00
2d848a33ee Merge pull request #2167 from Alex Arenas 2026-11-22 11:42:25 -05:00
e3c972d0d5 Merge pull request #2145 from KanameS 2026-11-22 11:42:13 -05:00
6f77e39793 Merge pull request #2112 from SirKingg 2026-11-22 11:41:54 -05:00
388a4723c2 Merge pull request #2103 from requiemsnkrp 2026-11-22 11:41:49 -05:00
95ac207b7b Merge pull request #2099 from Luis Baker 2026-11-22 11:41:47 -05:00
2fe08d7e18 Merge pull request #2084 from Luis Baker 2026-11-22 11:41:37 -05:00
e0b03b2721 Runtime: CheckFeatureSupport refuses the undefined shader models between 5.1 and 6.0
D3D12_FEATURE_SHADER_MODEL echoed a request of 0x52-0x5f back with S_OK.
No runtime defines a model there, and the host runtime refuses them
with E_INVALIDARG (RTX 5070, driver 621.14). Refuse them the same way.
Requests above 6.9 stay clamped to the layer's model, as newer runtimes
accept newer ones. Checked in d3d12_vulkan_device_test's main, not
against the host: the test notes the host crashed on 0x5f elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:41:18 +01:00
817de3de95 Merge pull request #2041 from fearkov 2026-11-22 11:41:08 -05:00
1e24a98cce Merge pull request #2032 from Alex Arenas 2026-11-22 11:41:04 -05:00
1241d87e4f Merge pull request #1991 from TheHoracio 2026-11-22 11:40:59 -05:00
56000c7c7f Runtime: CreateRootSignature and CreateQueryHeap answer invalid arguments as the host does
Measured against the host D3D12 runtime (RTX 5070, driver 621.14) with
d3d12_vulkan_device_test's compare_invalid_arguments, five answers
differed:

- CreateRootSignature took a node mask other than node 0 (host:
  E_INVALIDARG), took a DXBC blob passed with more bytes than its own
  size (host: E_INVALIDARG), and answered a null output with E_POINTER.
  The host answers a null output with S_FALSE before it looks at the
  blob or the node mask.
- CreateQueryHeap answered an unknown type (past PIPELINE_STATISTICS1)
  with E_NOTIMPL (host: E_INVALIDARG), and a null output with S_FALSE
  (host: E_UNEXPECTED, after the description checks).

compare_invalid_arguments gets 30 "query heap:" and "root signature:"
cases. The root signature blobs come from the host's serializer.
d3d12_vulkan_device_test's own null-output check now expects
E_UNEXPECTED. Known query types this layer has no path for stay
E_NOTIMPL, and more than 32 root dwords stay refused (pack()).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:40:55 +01:00
067e0240bd Merge pull request #1935 from Tao Battarel 2026-11-22 11:40:49 -05:00
72b6218983 Merge pull request #1916 from cobalt-pebble-804 2026-11-22 11:40:47 -05:00
24796f5284 Merge pull request #1886 from Claude 2026-11-22 11:40:44 -05:00
fc2ee62c98 Merge pull request #1683 from requiemsnkrp 2026-11-22 11:40:37 -05:00
f8e89767f6 Runtime: map sparse reserved RGBA8 texture tiles (D3D-285) 2026-11-22 13:39:08 -03:00
7812487acc d3d12_vulkan_device: answer Intel integrated OPTIONS1 lanes per generation (D3D-280)
Meteor Lake (Xe-LPG) hosts answer 8..32 while the D3D-121 rule pins 16..16 for every
Intel integrated GPU; keep the measured 16..16 pin on pre-Xe-LPG lines (Tiger Lake
regression-checked locally) and keep the Vulkan range on Xe-LPG+ device-ID ranges
(Meteor/Arrow Lake 0x7d40-0x7dc5, Lunar Lake 0x64a0-0x64b6).

Fixes D3D-280.
2026-11-22 17:38:00 +01:00
0a3bf1ed91 PresentX planes: enable swapchain_colorspace on the real instance, premultiply before filtering
- create_vulkan_device_standalone now enables VK_EXT_swapchain_colorspace when the loader has it (only the
  test device did), so the HDR10 surface formats can be listed in the real runtime; xbox_present_test checks
  the standalone path (device_has_swapchain_colorspace).
- Straight-alpha planes are bilinearly filtered on premultiplied colour and un-premultiplied after, so a
  transparent texel adds no colour; the CPU model does it independently, plus a transparent-edge case.

Both found in review by Flyander.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:34:38 +01:00
fac5a5af7d Runtime: MULTISAMPLE_QUALITY_LEVELS answers TILED_RESOURCE
CheckFeatureSupport(MULTISAMPLE_QUALITY_LEVELS) refused the TILED_RESOURCE
flag with E_INVALIDARG. Native D3D12 (RX 7800 XT, a Radeon iGPU and WARP)
answers S_OK: 1x and 4x keep the plain answer, every other count has none,
and a format without a tile shape (96-bit) has none at any count, which is
GetResourceAllocationInfo's tiled rule here (tiled MSAA is 4x only).
128-bit formats tiled at 4x are a driver difference: the AMD drivers answer
0, WARP and NVIDIA allocate them; the layer follows the latter.

d3d12_vulkan_device_test compares the TILED_RESOURCE quality levels of six
formats at five counts with the host's (allowing that one difference). The
allocation side of the AMD failure is c97ae261's host-quality gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:32:12 +01:00
9b99a5f030 Merge remote-tracking branch 'origin/main' into d3d12-queues-v2
# Conflicts:
#	runtime/test/vk_test_device.h
2026-11-22 17:31:21 +01:00
7e7275915c MoltenVK: size the bindless set by its update-after-bind limits, not its layout-support answer
MoltenVK's vkGetDescriptorSetLayoutSupport compares every layout with maxPerSetDescriptors (1212, the limit without
argument buffers) and rejects even 1212 itself, although it creates and samples a 65536-image, 4096-sampler
update-after-bind set correctly (native repro; d3d12_descriptor_test under Wine with the set grown). On MoltenVK the
D3D12 device no longer asks it: size_bindings' per-type update-after-bind limits, which MoltenVK takes from Metal's
argument-buffer limits, decide, and the set grows to 65536 2D images and 4096 samplers on an M3 Max.
2026-11-22 20:29:38 +04:00
cfcc6c54a3 runtime: implement ID3D12Device9::CreateShaderCacheSession and ShaderCacheControl (D3D-34)
Add in-memory ID3D12ShaderCacheSession support (FindValue, StoreValue, SetDeleteOnDestroy, GetDesc) and ID3D12Device9::ShaderCacheControl on the Vulkan-backed D3D12 device, matching the Windows D3D12 host runtime's validation, size queries, duplicate rejection, cross-session sharing, and delete-on-destroy lifecycle.

Verified with synthetic test d3d12_shader_cache_test comparing the Vulkan layer against the host Windows D3D12 runtime under LEONIDA_VK_VALIDATION=1.
2026-11-22 17:24:30 +01:00
f6ae4e58ab runtime: report COMMAND_QUEUE_PRIORITY_HIGH unsupported (D3D-258) 2026-11-22 17:15:59 +01:00