Commit Graph

4696 Commits

Author SHA1 Message Date
4a4acf3e63 Register the compute, draw and present tests with ctest
main's tests/test_ctest_registration.py (#1258) fails on this branch after
the merge: d3d12_compute_test, d3d12_draw_test and d3d12_present_test are
built but no add_test runs them.

They are registered like their neighbours, with SKIP_RETURN_CODE 77, and
return 77 when vktest::Device::initialize() finds no Vulkan device, as the
other registered D3D12 tests do. Without that, the CPU runtime job, whose
runner has no Vulkan driver, would fail on them the way it did on
d3d12_predicated_copy before #1314.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 05:46:39 -05:00
4cfde416f8 Merge main (f85582e) into runtime/compute-path
On top of the merge candidate 70178d3 (Ryx69/Leonida#6, which merged main at
426023a): the 219 commits main gained since. Three hunks conflicted, in two
files; both follow the notes on #291 (ItsNotRexed 08:27 UTC, Vonsek 09:58 UTC
on 2026-11-22).

runtime/shims/d3d12_vulkan_device.cpp, device setup after the VulkanContext:
- the branch's GPU address arena is created first, as before;
- main's block that configures predication and the predicated byte copy
  (#1277) follows it;
- one load_host_image_copy call and main's lazy D24 converter (enabled only
  where D24_UNORM_S8_UINT is not usable) replace the branch's unconditional
  enable_depth24, which was the same code before main changed it.

runtime/src/vulkan_replay.h:
- CopyBuffer: main's version. It already adds ResourceBinding::buffer_offset
  to both offsets, as the branch did, and adds the overflow and overlap
  checks and the predicated copy. With the arena, source and destination are
  often the same VkBuffer; the overlap check compares the adjusted ranges.
- Predication: main's version. prepare() passes buffer_offset + the command's
  offset to prepare_predicate, so a default-heap buffer inside the arena is
  read at its own range; emit() captures the word and tests the capture's
  scratch slot, not the application's buffer.

Everything else merged without conflicts. Nothing in main's 219 commits adds
a caller that takes a buffer's Vulkan device address for its GPU VA.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 05:45:58 -05:00
217fbf5133 fix(d3d12): honor native RGB9E5 render-target support
Radeon advertises a color attachment for shared-exponent textures. Allow the native path to create the resource and RTV while keeping the mutable R32 UAV backing unavailable for render targets.
2026-11-22 11:45:17 +01:00
b8bd9f20a0 Runtime: apply backing-buffer offsets to CopyResource and CopyTexture 2026-11-22 13:44:57 +03:00
b9864d274a vk_compute_test: the heap of the bvh mode holds its BVH
The "bvh" mode writes its nodes at heap offsets 0x100 to 0x264, but with one
group the heap buffer is 64 words, 256 bytes. The host wrote past the mapped
range and the shader read the nodes through the buffer device address outside
the buffer. It worked because the memory allocation is larger than the buffer.

GPU-assisted validation reports it for cs_bvh on current main:
VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819, "trying to read 4 bytes at
[..220, ..223) but this range does not belong to any buffer", the buffer being
256 bytes. The heap is now at least 0x280 bytes in this mode. The eight result
words are unchanged, and both BVH fixtures are clean under core and
GPU-assisted validation on RADV (RDNA2 integrated GPU) and llvmpipe.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 05:43:32 -05:00
db7538e8f0 test(vulkan): encode the sampled view format in the synthetic T#
The arbitrary texture key named an unsigned format for an RGBA8_UNORM view, sending explicit gathers down the wrong branch. Derive the T# format from the same Vulkan format used to create the view.
2026-11-22 11:40:48 +01:00
478c4a18e4 d3d12_r9g9b9e5_uav_test: skip the WARP comparison where WARP has no typed R9G9B9E5 UAVs
The UAV clear comparison builds its reference on WARP, which needs a
typed R9G9B9E5_SHAREDEXP UAV. Windows 10's WARP has none
(FORMAT_SUPPORT Support1 0x008013f0, no TYPED_UNORDERED_ACCESS_VIEW), so
its CreateCommittedResource with ALLOW_UNORDERED_ACCESS returned
E_INVALIDARG and the test failed at line 604 on every Windows 10 host
(the only ctest failure on main there). Ask WARP for the format first
and, without it, take the existing 'WARP unavailable' path: the layer's
six clear sequences must still succeed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 04:38:35 -06:00
dc0cd5debc Merge main into the constant lane-mask fix
Conflicts with main's DPP and TEST-175 entries in check.py,
run_gpu_tests.py and regen_fixtures.py: main's lists with
cs_w32_mask_imm / cs_w64_mask_imm added back.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:38:22 +01:00
de5c12ba53 Merge pull request #1361 from 73N1X 2026-11-22 05:37:55 -05:00
bfa0565b11 Tests: the 14 v_cmpx forms no test ran, GPU and CPU
v_cmpx_{eq,gt,le,lt,ngt,nle}_f32, v_cmpx_f_i32, v_cmpx_t_u32,
v_cmpx_{eq,gt,le}_i64 and v_cmpx_{ge,lt,ne}_u64 are translated but
appeared in no test, fixture or fuzzer table.

ps_vcmpx_forms runs each in the e32 encoding, and the f32 ones,
f_i32, t_u32, gt_i64 and ge_u64 in e64 too, on operands read from
memory: NaN on either side, signed zeros, -infinity, and 64-bit pairs
that only the low word, only the high word or the sign tells apart. It
also checks that an empty EXEC stays empty and that VCC is kept. The
four words are derived from the ISA in the .asm header.

test_vcmpx_forms.py re-derives those words, runs every form in both
encodings on a table of operands, and runs each on a 16-lane wave with
one lane switched off beforehand.

No translator change: all of them pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:37:54 +01:00
59ef8a8941 Merge pull request #1357 from totonii 2026-11-22 05:37:54 -05:00
bbf2ff118b Merge pull request #1355 from whattheflop 2026-11-22 05:37:54 -05:00
280122eca0 Merge pull request #1350 from Emre Demir 2026-11-22 05:37:53 -05:00
ac8d66e0bd Merge pull request #1346 from ezwinxdlmao
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 05:37:52 -05:00
8a84d14d58 Merge pull request #1343 from lloyd 2026-11-22 05:37:50 -05:00
41dccfb3e4 Merge pull request #1339 from mrb-eel 2026-11-22 05:37:48 -05:00
67c3e40ad7 Merge pull request #1337 from Emirhan Karaca 2026-11-22 05:37:47 -05:00
c4db02a1c8 Merge pull request #1334 from ezwinxdlmao
# Conflicts:
#	docs/design.md
2026-11-22 05:37:46 -05:00
4c70aca8b1 Merge pull request #1332 from mrb-eel 2026-11-22 05:37:44 -05:00
67468767cf Merge pull request #1326 from zneel 2026-11-22 05:37:42 -05:00
90c8688124 Merge pull request #1323 from Flyander 2026-11-22 05:37:41 -05:00
8fa286d3a1 Merge pull request #1322 from Vonsek 2026-11-22 05:37:41 -05:00
4324a7f88f Merge pull request #1321 from Emirhan Karaca 2026-11-22 05:37:41 -05:00
d01d1df494 Merge pull request #1306 from zneel 2026-11-22 05:37:40 -05:00
53300de17f Merge pull request #1270 from AimLogin 2026-11-22 05:37:39 -05:00
2f6881a065 Merge pull request #908 from AlxcBTW 2026-11-22 05:37:39 -05:00
d630dd7db8 fma: test_fma_khr runs on its own; no startup line when the device lacks VK_KHR_shader_fma
test_fma_khr put tools/ on the path only through support, so it failed when
run alone; it now inserts TOOLS_DIR itself like test_f16_fma_rounding. The
standalone device no longer prints on every start when the feature is
missing (the tools refuse an FMAKHR module where it matters).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:34:52 +01:00
8f5ee29f85 Merge remote-tracking branch 'origin/main' into w-m15 2026-11-22 11:33:54 +01:00
8f89893212 Merge current main into depth-stencil copy fix 2026-11-22 06:33:39 -04:00
43d578f3cf Translator: a constant lane mask gives lane L its bit L
Gen.mask_src turned an immediate lane-mask operand into bit 0 of the
constant for every lane, so s_and_saveexec_b32 s7, 0xff00 with all lanes
on left none on and an inline 5 left all 32 on. Lane L now takes bit L:
of the 64-bit value for the 64-bit forms (inline constants sign-extended,
literals with a zero high word, as src64_data) and of the 32-bit value at
L mod 32 for s_*_saveexec_b32 and s_andn2_wrexec_b32. 0 and -1 stay
constants. s_bcnt0/1_i32_b64 of a constant now counts the constant's bits
(scalar data, like s_ff1_i32_b64) instead of this lane's mask copy.
SGPR operands are unchanged.

GPU tests cs_w32_mask_imm.asm and cs_w64_mask_imm.asm, words derived in
their headers, failed on main on an RTX 5080 and an RDNA2 iGPU and pass
now; LaneMaskConstants runs both across every lane in the semantic suite.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:33:18 +01:00
bf42427ed3 feat(dxgi): add IDXGIFactory5 tearing query, present-mode selection, and waitable swapchains 2026-11-22 07:32:02 -03:00
d5c0e16319 Tests: GPU test for the xy/xyz typed buffer loads and stores (TEST-185)
buffer_load_format_xy/xyz, tbuffer_load_format_xy/xyz and
buffer_store_format_xy/xyz were checked only on the CPU. The new
cs_fmt_xy_xyz.asm runs 12 loads and 9 stores on one thread, and
check.py and run_gpu_tests.py compare 128 dumped words.

Every expected word was measured by running the same body natively on a
Radeon 680M (gfx1035, RDNA2), through tools/hw_oracle's kernel wrapper
with s[0:3] set to the V# vk_compute_test passes. Wave32 and wave64 gave
the same words. What the hardware does:
- Loads write only their 2 or 3 VGPRs. A missing channel repeats one the
  format has (SHADER-86), and tbuffer loads take the instruction's format.
- Bounds: the whole element must end inside num_records, even when the
  loaded components do. Such a load reads 0, and such a store writes
  nothing.
- A store with fewer components than its format writes the whole
  element, with 0 for the rest. Into a one-channel format only x is
  written.

The translation already does all of this. The test catches a store that
fills the missing components with anything but 0, a bounds check on the
first dword only, and an xy/xyz load that writes four VGPRs: each of
these, made in a scratch copy of the translator, failed 6, 16 and 18
words.

check.py's dump comparison becomes dump_test, shared with
fmt_1010102_test, whose messages are unchanged. docs/design.md records
the measured rules in the typed-load, format-store and bounds rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:31:42 +02:00
8d40bbf5c3 Tests: fail predicated copy on Vulkan initialization errors 2026-11-22 20:31:13 +10:00
a03e155134 Fix stencil corruption in depth-stencil CopyResource 2026-11-22 06:28:58 -04:00
fa4d54f22d process shim: keep the game's command line wide so a non-ASCII argument can't crash --run (RT-84)
main.cpp turned each game argument into std::filesystem::path::string(),
which throws std::system_error under MSVC when the ANSI code page has no
mapping for a character. Nothing caught it, so gta6rt --run ended in
0xc0000409 before the game started.

set_command_line now takes wide strings: __wargv and GetCommandLineW hold
the arguments exactly, and the narrow argv and GetCommandLineA are their
CP_ACP text from WideCharToMultiByte, which replaces a character the code
page lacks instead of failing, as the CRT does.

process_cmdline_test passes wide arguments and checks a Latin-1 one and a
Greek, Cyrillic and CJK one that no single-byte code page holds, so the
crash is covered on every system locale, not only 1253.
2026-11-22 13:28:05 +03:00
e6f8478e9b D3D-62: create the converter on every GPU; merge with the concurrent-queue test
The converter was made only where the GPU lacks D24_UNORM_S8_UINT (1c5463b4). 96-bit textures need it on every
GPU, so it is always created; it costs nothing until a copy uses it (lazy pipeline, lazy tracker lock).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:26:48 +01:00
0723014a83 D3D-62: converter split test, COPY queue, footprint refusal, ctest skip
- depth24_convert_test: 96-bit texels split into rows (1 KiB range) and slices (1 MiB range).
- d3d12_rgb96_test: an upload and a readback on a COPY queue; GetCopyableFootprints refuses what creation
  refuses (as WARP); returns 77 without a Vulkan GPU or WARP so ctest skips; large timings behind LEONIDA_RGB96_LARGE.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:26:48 +01:00
983862e2a8 Runtime: 96-bit R32G32B32 textures on the Vulkan layer (D3D-62)
R32G32B32_FLOAT/UINT/SINT/TYPELESS textures were refused ("texture format not
supported yet"). They are now R32G32B32A32 images on every GPU: most have no
optimal-tiling RGB32 image, and one that has would not avoid the repack, since
D3D12 places subresources at multiples of 512 bytes and Vulkan wants a copy's
buffer offset to be a multiple of the texel size
(VUID-vkCmdCopyBufferToImage-dstImage-07975).

- Footprints keep D3D12's 12-byte texels (compared with WARP).
- CopyTextureRegion between a texture and a buffer is repacked by the D24
  compute pass (depth24_convert.comp modes 2 and 3, Depth24Job::rgb96): the
  same scratch, parts and lifetime, texels of three words in the footprint and
  four in the scratch, copied uninterpreted. depth24_convert.inc is
  regenerated with the documented glslc command; the same glslc reproduces the
  previous blob byte for byte from the previous source.
- WriteToSubresource/ReadFromSubresource take the staged copy, as D24-as-D32.
- A view's T# names GFX10_FORMAT_32_32_32_*, so alpha reads as one.
- Refused: unordered access and depth (as WARP), render targets (WARP has
  them; not done, and FORMAT_SUPPORT and GetResourceAllocationInfo agree),
  copies between a 96-bit and a four-channel texture, views of another
  format family.

Tested on an RX 9070 XT (AMD 26.11.2), Windows 11: d3d12_rgb96_test matches
WARP and the expected texels bit for bit for 4 formats as 2D arrays with mips
and as volumes; d3d12_descriptor_test samples FLOAT, UINT and TYPELESS views.
Clean under the validation layer with sync validation; depth24_convert_test
and ctest (62) pass.

AI-assisted (Claude Code).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:26:48 +01:00
e256a2547c Translator: --fma khr emits OpFmaKHR for fused multiply-adds
GLSL.std.450 Fma may be split into two roundings by a driver (Vulkan
environment: inherited from OpFMul followed by OpFAdd); RDNA2 v_fma_* round
once. --fma khr (default stays glsl) emits OpFmaKHR with capability FMAKHR and
SPV_KHR_fma and lists shaderFmaFloat32 in the index. Runtime device creation
and the vk_* test programs enable VK_KHR_shader_fma when present; cs_fma_fused
tests single rounding; the mini interpreter learns OpFmaKHR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:25:37 +01:00
806ee523c4 tests: D3D12 host comparisons skip under Wine (TEST-105 follow-up)
The host-comparison tests added since #869 create their host devices with
D3D12CreateDevice themselves, so copycmp::try_create_host's Wine check never
reached them. Under Wine the reference is vkd3d, not Microsoft's runtime,
and they failed on a real GPU for that reason alone.

runtime/test/host_wine.h has the same check (ntdll's wine_get_version) for
them. Under Wine:
- d3d12_fence_events, d3d12_query_rules: the layer's own expectations
  still run; only the host references are skipped.
- d3d12_depth_resolve: the layer is still checked against the clears; a
  host reference is no longer required.
- d3d12_resource_desc, d3d12_node_mask, d3d12_copy_xfmt,
  d3d12_typeless_rtv, d3d12_predicated_copy: every case compares with the
  host (or WARP), so they exit 77, which ctest already reads as a skip.
Windows runs them all as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:25:32 +02:00
c491cf097c Tests: d3d12_sampler2 compares non-normalized cases only with a host that has them (TEST-191)
The test compared all 22 CreateSampler2 edge cases with the host's PC
runtime. A host that reports no NonNormalizedCoordinateSamplersSupported
leaves every non-normalized description unwritten, so the test failed
at the first one ("UINT border and non-normalized: ours written 1, host
runtime 0"). It printed that the host lacks the feature, then compared
anyway. Since 817a5e9 registered it with ctest, ctest fails on such
hosts.

Each edge case now records whether its description has
D3D12_SAMPLER_FLAG_NON_NORMALIZED_COORDINATES, read from the description
itself. Without the feature on the host, only the 3 cases without the
flag are compared live. The layer's answers to all 22 are still checked
against the recorded RTX 4090 / WARP answers first, as before. The
host's normalized-vs-not descriptor check runs only when the host has
the feature.

Measured on the host's default adapter here, a Radeon 680M (D3D12
driver 31.0.14084.6002): it reports no non-normalized samplers and
leaves all 19 non-normalized descriptions unwritten, which
docs/d3d12_vulkan.md now records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:25:13 +02:00
f5c427716f fix(translator): saturate packed integer image reads
Native gfx1036 clamps out-of-range channels from signed and unsigned RGBA32 views before packing D16 results. Exercise both limits in the existing GPU readback fixture so wrapping at either boundary is observable.
2026-11-22 11:23:18 +01:00
3b7cbf46c7 Resolve indirect arguments relative to Vulkan backing buffers 2026-11-22 11:22:14 +01:00
1b88414e61 Tests: s_andn2_saveexec_b64 and s_andn2_wrexec_b64 on wave64, GPU and CPU
Neither instruction had a test (the _b32 forms are in #1299). The translator
needs no change: both pass.

- runtime/test/shaders/cs_w64x_andn2_exec.asm: one 64-lane wave. Each result
  has lanes in one half of the wave only, so an EXEC or an SCC taken from the
  other half alone shows; D is checked to be the old EXEC for saveexec and the
  new one for wrexec. In check.py and run_gpu_tests.py as a wave64 dump.
- tests/semantic/test_andn2_exec_b64.py: 12 pairs of S0 and EXEC for each
  instruction on all 64 lanes, against the ISA's definition written as
  integers; also runs the GPU test's fixture.

Run on an RX 9070 XT (AMD 26.11.2, Windows 11): passes natively 64-wide and
with LEONIDA_W64_EMULATE=1; the whole GPU suite is 127/127 both ways and the
semantic suite 1175 tests OK. Breaking either instruction in the translator
(D of wrexec = the old EXEC, D of saveexec = the new one, andn2 as and) fails
the GPU test and 13 CPU subtests.

AI-assisted (Claude Code).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:22:13 +01:00
d5ad74af45 presenter: lock the resource table through resource_mutex_ (main split it from mutex_)
main moved the resource table behind VulkanContext::resource_mutex_ (a
shared_mutex for lookups), so present(), present_blank() and the capture
path take a shared lock on it instead of the old mutex_.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:21:19 +01:00
36c11f8879 Merge remote-tracking branch 'upstream/main' into codex/constant-buffer-storage-read 2026-11-22 11:20:42 +01:00
8e50a770f8 Runtime: suspend conditional rendering around WriteBufferImmediate 2026-11-22 13:19:27 +03:00
e432faea31 Retry briefly blocked pipeline cache replacement on Windows 2026-11-22 11:16:59 +01:00
1ea8ac875d Merge remote-tracking branch 'origin/main' into presentx-core-v2-local
# Conflicts:
#	README.md
#	docs/d3d12_vulkan.md
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/vk_test_device.h
2026-11-22 11:15:14 +01:00
d0ae89d817 Merge origin/main into m15-translated-draw-v2 (again)
main moved (c0ac5fd): vulkan_replay.h takes main's checked buffer copies (predicated copies, overlap and overflow
refusals). README's Xbox row is rebuilt from both sides (the previous merge commit had committed a zero-filled
README.md; this restores it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:11:09 +01:00