Commit Graph

456 Commits

Author SHA1 Message Date
78688eab40 Merge pull request #2389 from Julio Facal
# Conflicts:
#	docs/design.md
2026-11-22 13:14:35 -05:00
45a5aec292 Merge pull request #2100 from Koro4e 2026-11-22 13:13:01 -05:00
4d64f9a68f Merge pull request #2069 from AlxcBTW 2026-11-22 13:12:59 -05:00
0a46434246 Merge pull request #1985 from Dominik 2026-11-22 13:12:46 -05:00
db317bd3ee Merge pull request #1947 from Jolymmiles 2026-11-22 13:12:44 -05:00
6cfe5862ed Merge pull request #860 from adonizm 2026-11-22 13:12:29 -05:00
60cc47cb79 Merge pull request #306 from IAmNotSiob 2026-11-22 13:12:26 -05:00
cde85e21e1 Runtime: stage block-compressed copies one vkCmdCopyImage cannot express
CopyTextureRegion between two block-compressed textures copies whole blocks
on the PC runtime. When a mip edge falls inside a block on one side only (a
4x4 box into a 3x3 mip, a 6x6 mip into a 12x12 one), no single Vulkan extent
is a block multiple or reaches the edge of both images, so the layer refused
the copy with invalid_copy (docs/d3d12_vulkan.md, section 3.2 known gaps).

Such a copy now goes through the transfer scratch that depth <-> colour
copies already use (vulkan_scratch.h): vkCmdCopyImageToBuffer with the
source's own cut extent into whole blocks, then vkCmdCopyBufferToImage with
the destination's. The box fits the source's padded mip, so the scratch
holds every block the destination reads. The staged emit path calls the
destination's copy_layout after the scratch write, so every earlier transfer
write is ordered before the destination's (the write-after-write @Vonsek
found under synchronization validation in the first version of #860).

- d3d12_copy_compare: the 8 BC mixed-mip cases that were printed as known
  differences must now match the host; two more shapes (a source edge inside
  the block, a destination offset to the edge).
- d3d12_state_map_test checks the staged regions on the CPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:32:05 +01: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
9b17404e15 Runtime: replay overlapping statistics and binary occlusion queries (D3D-252)
D3D12 only forbids beginning the same query element twice while it runs, so a
command list may overlap two pipeline-statistics queries, or an ordinary
occlusion query and a binary one, on different slots of one heap. The replay
refused all of those with ReplayResult::unsupported. The overlapping-ordinary
occlusion machinery already virtualizes concurrent queries as non-overlapping
physical segments whose results are summed; this extends it to the remaining
cases:

- Binary occlusion joins the ordinary kind in the same physical pool (both are
  VK_QUERY_TYPE_OCCLUSION, so one physical query is open at a time and the
  shared intersection interval is counted by both logical queries). A binary
  resolve of a multi-segment query sums its segments and normalizes the total
  to 0/1 (OcclusionResolve::sum_binary; run flag needs_sum_binary).
- Overlapping pipeline-statistics queries split into the statistics pool with
  the same one-slot-per-event layout (plan_overlapping_statistics_segments);
  every non-timestamp resolve while a query runs closes and reopens the open
  segment for D3D-162's helper-dispatch exclusion. The single-list replay()
  helper still has no segment pool and refuses such lists outright instead of
  running two Vulkan queries of one type whole.

The device test's old pin of the occlusion+binary refusal now expects a
replay; vk_overlapping_occlusion adds crossing statistics queries checked
word-by-word against three unsplit references and an ordinary query around a
binary one; replay_query_predication pins the segment layouts, the composite
binary resolve and the helper's refusal without a GPU. docs/d3d12_vulkan.md
4.6 moves the case out of "Not implemented yet".

AI-assisted: yes
2026-11-22 18:10:42 +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
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
df8de6a1fc Merge pull request #2296 from João Ramos 2026-11-22 11:43:55 -05:00
07a6d1c5ae Merge pull request #2286 from Matheus Gomes 2026-11-22 11:43:48 -05:00
4c28f269ec Merge pull request #2264 from SirAmong 2026-11-22 11:43:34 -05:00
83d973a424 pe_loader: read the TLS directory through directory(), honouring NumberOfRvaAndSizes
Every data directory the loader reads goes through directory(), which
returns an empty entry past OptionalHeader.NumberOfRvaAndSizes (PE/COFF: those
slots are not directories, whatever bytes they hold) - except the TLS one,
which read DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS] directly. An image
declaring fewer than 10 directories with leftover bytes in slot 9 then failed
to load ("the TLS directory runs past the image") or, with plausible bytes,
had a TLS directory the Windows loader would ignore.

loader_test: with NumberOfRvaAndSizes = 9 and junk in the TLS slot the image
loads (it was rejected before); with all 16 the same slot is still checked
and refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:43:32 +00:00
3fd09d4ecd Merge pull request #2232 from Jolymmiles 2026-11-22 11:43:11 -05:00
e3c972d0d5 Merge pull request #2145 from KanameS 2026-11-22 11:42:13 -05:00
d3b2262635 Merge pull request #2114 from Vonsek 2026-11-22 11:41:55 -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
61d5397910 Merge pull request #2070 from jaybeebabageyus 2026-11-22 11:41:29 -05:00
68733d6606 Merge pull request #2021 from jaybeebabageyus 2026-11-22 11:41:02 -05:00
fc2ee62c98 Merge pull request #1683 from requiemsnkrp 2026-11-22 11:40:37 -05: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
a28493ba8f runtime: support multiple simultaneous manually mapped static-TLS modules 2026-11-22 17:34:35 +01:00
989877d1e0 fix(vulkan): fail capture readback when the fence wait fails
Only copy the mapped capture buffer after a successful fence wait. Inject a failure in the synchronization test and verify that the caller's pixel and metadata outputs are unmodified.
2026-11-22 13:33:33 -03: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
8ab01bbe3b XDXR: totalSizeIn64BNodes does not count the header, a structure is 64 * (field + 1) bytes (RT-151)
docs/bvh.md 3.1: u32@0x20 = 0x140 + 64 * totalSizeIn64BNodes, 271,627 of
271,627 streams. xdxr_build.comp wrote total_size / 64; the copy and
postbuild paths read the field as the whole size, and tools/xdxr_bvh.py
wrote and validated it the same way. Now the header writes total / 64 - 1,
MODE_COPY_AS and MODE_POSTBUILD use (field + 1) * 64, validate() and the
reference builder agree, xdxr_build.inc is regenerated (glslc 2026.4) and
d3d12_xdxr_rt_test reads the size the same way.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 11:30:53 -05:00
f4a3fe8d4a runtime: propagate LoadLibraryEx flags and reject DONT_RESOLVE_DLL_REFERENCES for bundled DLLs 2026-11-22 17:14:23 +01:00
9bf0794813 PresentX planes: review fixes (resize, struct order, overlay flag, ResourceCount)
- Re-prepare the compose target after the acquire/out-of-date retry and check the extent in
  record_planes; xbox_present_test resizes the window between composed presents.
- XboxPresentPlaneParameters follows the public field order exactly (adds ExtendedDescCount,
  pExtendedDescs); implausible placement / unknown filter / extended descs are ignored and
  logged once, not refused.
- Plane 1 is composed only with our overlay flag (SDR/SDR no longer blends by default).
- present_planes rejects a non-positive or NaN SDR white level.
- ResourceCount != 1 is refused with DXGI_ERROR_UNSUPPORTED before either path (found by Flyander).
- Docs: PQ-space filtering, HDR10 swapchain verified on RTX 5080 by JavierBlanco23.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:11:01 +01:00
9cc95bff0d Runtime: GetCachedBlob and CachedPSO checks like the host runtime
ID3D12PipelineState::GetCachedBlob returns a blob with the adapter, driver, pipelineCacheUUID and a SHA-256 of the description (without Flags; shaders keyed by their DXBC checksum), sealed by a checksum. Create{Compute,Graphics}PipelineState check a supplied CachedPSO before creating the PSO and answer as the PC runtime does, measured on an RTX 3060 and WARP. Rebased onto main (one commit). AI-assisted.
2026-11-22 17:09:44 +01:00
b76c78acdb Runtime: a bundle's draws run with the parent's state, and what the bundle set stays on the parent
A draw recorded in a bundle took the bundle's own viewport, targets, root
arguments and buffers. A bundle cannot set a viewport, so every bundle draw
was dropped without an error, and nothing of the parent's state reached it.
Only the stencil reference and the blend factor were handed back.

Inside a bundle, state calls, draws and Dispatch are now kept as deferred
calls, and ExecuteBundle plays them on the parent through the members a
direct call uses, between the bundle's state-free commands, in order. A
draw sees the parent's state plus what the bundle set, and what the bundle
set stays on the parent, as measured on the PC runtime. This replaces the
stencil-reference and blend-factor carry-back fields. Trace lines are
written once, when the bundle records the call.

ClearUnorderedAccessView is refused in a bundle, like the other clears.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 23:06:44 +07:00
e4e87a69e0 vulkan_replay: the postbuild branch's names no longer hide emit's (C4456)
The if-init `info` of the AccelerationStructurePostbuild branch stays in scope through the following
`else if`, so the BLAS/TLAS build branch's VkAccelerationStructureBuildGeometryInfoKHR `info` hid it,
and the branch's loop `i` hid emit's command index. Both are renamed (`postbuild`, `s`); no change in
behaviour.
2026-11-22 16:05:32 +00:00
4f574add4b d3d12_descriptor_test: the bindless capacity check follows the set's room
On MoltenVK (1.4.2, 1.4.3) the check sampled zeros: vkGetDescriptorSetLayoutSupport there accepts only layouts
of fewer than maxPerSetDescriptors (1212) descriptors, so size_bindings keeps the default 4096 2D images and
1024 samplers, and the test's 5001st view and 2100th sampler were refused as the arrays filled. MoltenVK does
create and sample a 65536-image, 4096-sampler set correctly (a native reproduction, and the whole test passes
under Wine with growth forced), so that is MoltenVK's to fix; the runtime keeps following the driver's answer.

The test now asks the set how much room it has (rt::d3d12::bindless_room, from BindlessSet::free_images and
free_samplers). Where the set holds the full counts nothing changes. Where it holds fewer, the test fills each
short array to its last index, checks the last view through the last sampler gives the texture, and that one
more view and sampler are refused and read as the fallbacks. The device logs at startup when its set holds
fewer samplers than a full shader-visible sampler heap. bindless_sizing_test gets MoltenVK's limits;
vk_bindless_test checks the free counts.
2026-11-22 20:01:37 +04:00
725f99e428 fix(runtime): retain the PresentX deadline on issued frame tokens
Rescheduling an origin event can make an existing frame look late before its original vblank. Keep the original deadline for both the tear decision and its display statistic.
2026-11-22 17:00:01 +01:00
90927ab35b Runtime: reject non-depth colour SRV formats on depth textures
Creating an SRV of a depth texture (D16_UNORM/R16_TYPELESS or D32_FLOAT/R32_TYPELESS) with a colour format (e.g. R16_FLOAT, R16_SNORM, R16_UINT, R16_SINT, R32_UINT, R32_SINT) previously produced a colour-format VkImageView with VK_IMAGE_ASPECT_DEPTH_BIT, violating VUID-VkImageViewCreateInfo-image-01762. Tighten vulkan_view_format(), image_descriptor() and bind_image() so depth/stencil textures only accept their own family's depth/stencil SRV formats and colour textures reject depth/stencil view formats. Adds exhaustive unit tests and GPU + Vulkan validation tests.
2026-11-22 16:56:36 +01:00
8af232c5e5 Runtime: clear typed UAVs of typeless textures in the view's format
ClearUnorderedAccess previously decoded encoded bytes into p.binding.format and cleared whole views via vkCmdClearColorImage, which corrupted non-float values (such as R16G16_UNORM 1.0 = 0xffff or R32_UINT sNaN bits) on SFLOAT-backed typeless textures. When view_format differs from p.binding.format and supports COLOR_ATTACHMENT, decode in view_format and clear through an attachment view of view_format (preserving the R32_UINT path for emulated R9G9B9E5_SHAREDEXP). Adds replay and GPU readback tests.
2026-11-22 16:54:40 +01:00
76262214e8 PresentX planes (M7): compose 1-2 planes on Vulkan with placement, filter, alpha overlay and HDR10/SDR conversion
A plain single plane keeps the old blit. A plane with pDestPlacementBase, a point/linear
ScaleFilter, the HDR10 colour space, or a second overlay plane goes through
VulkanPresenter::present_planes: a compute pass (present_compose.comp, SPIR-V embedded)
into an RGBA16F image that is copied to the swapchain. HDR10 uses an ST.2084 swapchain
when the surface lists one, else is clipped to SDR. An SDR plane 1 next to an HDR10 plane 0
is the GameDVR copy (public HDR sample) unless flagged an overlay. The layouts, flag values
and alpha convention are ours; xbox_present_test checks every case against a CPU model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:51:05 +01:00
c48a39d2d0 D3D-275: typed RTVs of every typeless color family
- ColorViewFormat now holds the view's VkFormat number (the RGBA8 names keep their values), and
  CreateRenderTargetView accepts any typed format of a TYPELESS color texture's family (B8G8R8A8 and
  B8G8R8X8 kept apart), not only RGBA8.
- ResourceBinding::rgba8_typeless becomes typeless (any TYPELESS color resource); color_view_format accepts a
  format of the resource's family (typeless_view_family, R8 included for when it is mapped), so clears go
  through a view in the RTV's format. Attachment views of every typeless image ask for color-attachment usage
  only.
- d3d12_typeless_families_test: every typed RTV format of each family, two clear values, bytes compared with
  the host D3D12 on the same adapter (LUID) and reported against WARP.
- docs/d3d12_vulkan.md: the typeless RTV section.

AI-assisted.
2026-11-22 16:48:45 +01:00
81c6cfe4fd Merge pull request #2021 from jaybeebabageyus 2026-11-22 10:40:29 -05:00
7e49e1b2e4 Merge pull request #1980 from totonii 2026-11-22 10:40:05 -05:00
4bc2fd2870 Merge pull request #1973 from Dominik 2026-11-22 10:39:59 -05:00
58cc88f5dd Merge pull request #1971 from Jolymmiles 2026-11-22 10:39:58 -05:00
6a4eff5816 Merge pull request #1942 from Felix Croasdale 2026-11-22 10:39:37 -05:00
68cee18fe2 Merge pull request #1939 from totonii 2026-11-22 10:39:35 -05:00
8b61d266bb Merge pull request #1933 from Emirhan Karaca 2026-11-22 10:39:32 -05:00
9887cc773a Merge pull request #1924 from Ash Hopkins 2026-11-22 10:39:28 -05:00