Commit Graph

4163 Commits

Author SHA1 Message Date
033192d050 vk_command_replay_test: cover a subresource copied twice in one list
copy_layout has to order a transfer write that finds its range already in
the transfer layout, because a texture can stay in COPY_DEST and be copied
into again; D3D12 orders copies on the queue and needs no barrier from the
application. That ordering landed in 5ec780c without a test, and the BC7
copy case in d3d12_vulkan_device_test reaches it: on a tree without it the
case reports ten WRITE_AFTER_WRITE hazards under synchronization
validation.

Part G records two buffer-to-image copies into the same subresource with no
transition between them and reads the texture back, so the missing
dependency shows up as a validation error and as the wrong texels.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 23:26:54 -06:00
5826a60187 fix: apply sampler LOD bounds to emulated gathers
Explicit-LOD gathers use four texel fetches that bypass the Vulkan sampler. Decode its 4.8 LOD bounds before selecting the mip so clamped gathers agree with a sampler-backed draw.
2026-11-22 06:25:26 +01:00
1293cc2656 Translator: hardware NaN rules for float min/max/med3, v_fract below 1.0
Measured on an AMD Radeon RX 6800 (gfx1030) with the hw-oracle tool from the
AnyPS5 project, all four IEEE/DX10_CLAMP combinations, wave32 and wave64:

- v_min/v_max f32/f16, each half of v_pk_min/max_f16, and v_min3/v_max3 now
  emit NMin/NMax (one NaN operand gives the other) instead of FMin/FMax.
- v_med3_f32/_f16: FClamp(z, NMin(x,y), NMax(x,y)), and with OpIsNan of each
  operand that can be a NaN, select NMin(NMin(x,y), z) (hardware: min3 when
  any operand is NaN). Non-NaN constants get no check; no select when none.
- v_fract_f32: Fract, then 1.0 -> 0x3f7fffff by compare and select (the NaN
  of fract(+-inf) is kept). v_fract_f16: the same, then a packed 0x3c00 ->
  0x3bff (not after an output multiplier).

Other FMin/FMax/FClamp uses (clamp bit, LOD and conversion clamps) are
unchanged. GPU fixtures ps_fnan_med3 and ps_fnan_fract read their inputs
from memory; on the RX 6800 the two med3 words differed before this change.
tests/semantic/test_float_nan_fract.py runs the measured rows; both
interpreters gain NMin/NMax, and spirv_mini_interp OpIsNan and exact Fract.

tests/semantic/test_alu_med3.py (merged after this branch was cut): its float
reference used Python min/max, which return the first argument for equal
zeros. Hardware orders -0 below +0 (RX 6800: med3(-0, +0, 1.0) = +0,
med3(+0, -0, -1.0) = -0 in every operand order), so the reference now sorts
with that order, and spirv_mini_interp's FMin/FMax/FClamp order zeros the same
way as its NMin/NMax.

Rebased onto 8df277f. Two upstream tests were written against the old
behaviour and are updated: tests/semantic/test_valu_f32_min3_max3_mad.py
(its min3/max3 reference used first-operand order for mixed zeros, and its
negative control replaced FMin/FMax; now -0 < +0, as measured on the RX 6800,
and the control swaps NMin/NMax) and tests/semantic/test_valu_f16_round.py
(it asserted that the interpreter rejects Fract; it now asserts the value).
Upstream had added an OpIsNan/OpIsInf branch to spirv_mini_interp, so this
commit's own OpIsNan branch is dropped (it shadowed upstream's). docs/design.md
notes that an output modifier on v_fract_f16 is applied before narrowing to
f16, an order not measured on hardware.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:25:05 -07:00
b61f68ed2b d3d12_vulkan_device_test: compare OPTIONS1 with the same GPU's host device, not the default adapter
compare_options1 created the host D3D12 device on the default adapter. On a PC with an AMD
iGPU and an NVIDIA card, a run on the AMD (VK_LOADER_DRIVERS_SELECT=*amd*) compared its 32..64
lanes with the NVIDIA's 32..32 and failed (WaveLaneCountMax: ours 64, host 32). It now uses
create_host_device_for_physical, like compare_feature_options: LUID, then PCI ids, then the
default adapter as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:09:59 -05:00
ca776a4f5a compute_fixture: say that a Debug build isn't searched 2026-11-22 10:39:23 +05:30
e875297227 d3d12_vulkan_device_test: the predication block's query heap desc no longer hides heap_desc (C4456)
The occlusion-query block from #858 declared a D3D12_QUERY_HEAP_DESC
named heap_desc inside the function that already has a
D3D12_DESCRIPTOR_HEAP_DESC heap_desc (line 2107), and MSVC /W4 warned
C4456. Rename it to query_heap_desc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:08:17 -06:00
9363490570 feat(dxgi): add Vulkan-backed IDXGIFactory4 and IDXGISwapChain3 COM shim with HWND GPU test 2026-11-22 02:06:28 -03:00
dfde5f58e9 fix: allow packed A16 coordinates on texel-offset samples
The address decoder already preserves the full offset VGPR before reading the packed coordinates. Let the existing offset path use those operands, and compare asymmetric packed UVs to the full-precision texel on the GPU.
2026-11-22 06:05:34 +01:00
f61720d877 Translator: s_cmp of a lane mask with -1 compares the real mask word
In a partial wave, lanes that were never launched don't vote but their
bits are 0 in the mask, so the vote called vcc_hi = 0xff "all ones".
Keep the vote for 0 only; -1 goes through wave_mask(). GPU tests for a
40-thread wave64 and a 20-thread wave32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:04:46 -03:00
69fe9d3752 Merge remote-tracking branch 'origin/main' into claude/d3d-24-debug-markers-457bab
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.cpp
#	runtime/shims/d3d12_com.h
2026-11-22 05:01:46 +00:00
747d1c34c0 Support overlapping ordinary occlusion in Vulkan replay 2026-11-22 01:59:55 -03:00
9806be2999 Tests: prefer the native Vulkan ICD over Mesa's Dozen on Windows
With the Compatibility Pack installed, Windows enumerates Mesa's D3D12
translation layer next to the real GPU, and Dozen reports DISCRETE_GPU. Every
harness used "the last discrete device wins", so it selected the wrapper and
the resulting failures looked like translator bugs (#915). One shared rank now
treats Microsoft's vendor as a translation layer, then prefers discrete over
integrated over virtual over CPU, keeping the first device on a tie. A CPU-only
test covers the reported enumeration without needing the Compatibility Pack.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 22:58:59 -06:00
5190d597c8 Merge keyboard-pad coverage with controller reading history 2026-11-21 21:58:55 -07:00
dbc428d83c vk_image_fuzz: name the missing device feature, one per line
The skip message said 'lacks ... or the without-format reads/writes', which cost kapitche a vulkaninfo round trip on an Intel UHD 770. It now prints the exact features that are missing, plus the reason when the without-format ones are involved: the translated image_load declares those capabilities for every shader, because its uint/sint path is chosen from the T# FORMAT at run time.
2026-11-22 01:56:25 -03:00
e6c767bdd3 Tools: image_load differential fuzzer with a GPU harness
AI-assisted. docs/shader_validation.md said "Not covered yet: images", and
FUZZ-1..13 touch VALU, memory, LDS, crosslane and control flow but not a single
image instruction. This is the first slice of that gap:

- runtime/test/vk_image_fuzz.cpp: headless harness that binds one 2D sampled
  image from a key=value spec (format, size, texels, T# key) through the
  bindless set and the descriptor table, draws a 64x64 full-screen triangle with
  a caller-supplied VS/PS, and dumps RGBA32F. It enables the without-format
  storage-image reads/writes and fragment atomics the translated image path
  declares, and fails on validation errors with LEONIDA_VK_VALIDATION=1.
- tools/image_fuzz.py: assembles a pixel shader that reads one texel with
  image_load (dmask 0xf, T# in s[8:15]), translates it with rdna2spirv.py, runs
  the harness, and compares every pixel with an independent CPU oracle for the
  T# format. A fetch is a memory read, so the oracle is exact.
- tests/test_image_fuzz.py: the oracle, the texel mapping, the T# word and the
  generated shader, without a GPU.

Covered: R8G8B8A8_UNORM, R16G16B16A16_SFLOAT, R32G32B32A32_SFLOAT and
R32_SFLOAT, at 8/16/32/64 square sizes that divide the draw; a fifth of the
values are NaN, +-inf, +-0 or denormals.
Not covered yet: dmask variants, UINT/SINT formats (they read through the
storage views), mips, 1D/2D-array/3D/cube, image_sample/gather with filters and
borders, and texel offsets with VK_KHR_maintenance8.

Verified on an NVIDIA RTX 2060 SUPER (Linux, 620.73.04, Vulkan 1.4.357):
40/40 programs match under LEONIDA_VK_VALIDATION=1; ctest 11/11; the GPU suite
is unchanged with a clean build. Synthetic fixtures only, no game data.
2026-11-22 01:56:25 -03:00
072620be0c d3d12_vulkan_device_test: the last two waits on fence use submit_and_wait
#850 moved the waits to a counter, but the 1D-texture block still signalled 8 and #858's predication block
12/13. Once the counter had passed those values, SetEventOnCompletion returned at once and the blocks read results
the GPU had not written yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:51:42 -05:00
b72fc5a4fe Keep gamepad readings in order between title polls 2026-11-21 21:46:14 -07:00
482aa3c33f test: isolate typeless volume descriptors from multisample views
The pending multisample fixture already owns the next slots on the common heap. Give the two typeless views their own CPU descriptors so both sampling regressions can run in the same command list.
2026-11-22 05:33:07 +01:00
fb31cc780e tests: rename the multisample levels in d3d12_descriptor_test
The multisample-quality check declared a local 'levels' that hid the footprint array 'levels[3]' still used later in the function, which MSVC /W4 reported as C4456. Rename the feature struct to quality_levels; no behavior change.
2026-11-21 20:30:57 -08:00
5517ed7ac0 Merge remote-tracking branch 'origin/main' into presentx-core-v2
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
2026-11-22 05:28:42 +01:00
daff874493 XboxPresentation: present null/stale/repeated tokens with a log, MSAA gives DXGI_ERROR_UNSUPPORTED, SuspendX never waits on a present; tests and docs
xbox_present_test presents with null, repeated and stale tokens (the present
happens) and refuses never-issued ones, and presents MSAA, integer and BC sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:34 +01:00
5241cf2cfe FramePacer: lenient tokens, SetFrameIntervalX keeps the origin armed, schedule keeps this period's origin
Only a token that was never handed out is refused; null, stale and repeated
tokens are reported through TokenIssue and presented. SetFrameIntervalX re-bases
the grid and leaves the origin event armed. ScheduleFrameEventX takes the origin
whose offset has not passed yet. ManualFrameClock calls its wake under the lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:21 +01:00
b7a0232523 runtime: XboxPresentation (PresentX 0/1/2 planes, frame events, Suspend/ResumeX) and xbox_present_test
Provisional struct layouts and constants of ours; real slots unmeasured (TODO
table in the header). The test reads the swapchain image back on a Vulkan
device and runs the frame events on a fake clock, then 30 frames in real time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:06 +01:00
bb6bb741fd Compile large Vulkan shader modules exclusively 2026-11-22 01:27:49 -03:00
70f184a636 feat(runtime): add D3D12 CBV/SRV/UAV buffer views and VkPipelineLayout root signatures 2026-11-22 01:27:04 -03:00
5ccbd36f39 runtime: FramePacer for the Xbox frame events (interval, origin event, latency, tokens, statistics, suspend/resume)
Header-only, injectable clock, tested on a fake clock (frame_pacer_test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:26:41 +01:00
69b1d114cc d3d12_translated_draw_test: rename the global size (it shadowed locals in vulkan_replay.h, C4459)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 05:26:10 +01:00
5aef74c8c6 Merge remote-tracking branch 'origin/main' into m15-translated-draw-v2
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 05:25:09 +01:00
9552f0d899 M1.5 review: structured V# out-of-range mode via gfx10::encode, stricter edge assert, softer 436 and V# docs
make_vsharp used OOB_SELECT raw with stride 32, which on hardware checks the byte offset
against num_records; the test only passed because the translator ignores OOB_SELECT. It now
encodes a gfx10::Buffer with OobSelect::structured. The 32 diagonal pixels must be the clear
colour (a right edge under the top-left rule). Docs: 436 is not in the tree (identical result
with its translator change applied); the V# failure follows from the upload buffer lying below
the arena, which is allocation order, so the rule stays: anything behind a V# is an arena range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:25:01 +01:00
082fdd048e M1.5 (D3D-53): a draw whose VS and PS are translator output
vs_m15.asm and ps_m15.asm are hand-written RDNA2 (gfx1013), built by
test/shaders/build.py through llvm-mc and tools/rdna2spirv.py. build.py now also
writes the synthetic FSSM program a shader's header asks for (fssm-at, fssm-data)
to fssm/, so the translator records its fssm_sha256 in index.json.
d3d12_translated_draw_test creates a graphics PSO from containers carrying those
programs; the layer finds both stages by hash in the translator's own index. It
covers a descriptor-table root argument and root constants (s0..s5), vertex fetch
through a V# the application wrote into a descriptor slot (s_load, then
buffer_load_dwordx4 idxen), the PS reading constants through the code base
(s_getpc_b64), and compares a float render target bit for bit. All draws use
StartVertexLocation 0, so the result is the same with and without PR 436's
zero-based ids; verified both ways. docs/d3d12_vulkan.md records the milestone and
the measurement that a V# cannot point at an upload buffer (48-bit base, negative
console VA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:24:46 +01:00
b962a709f6 Vulkan devices enable shaderInt64; the test device also shaderDrawParameters
Every translated shader declares Int64 (64-bit addresses) and lists shaderInt64 in
its index metadata, but neither the standalone device nor the test device enabled
it: vkCreateShaderModule was a validation error and the first translated draw
lost the queue. The test device also enables shaderDrawParameters, which the
translator's zero-based VS ids (PR 436) will need. Two names in the test device
no longer shadow each other after the merge with main. The standalone-device
change is PR 291's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:24:27 +01:00
46f5ce2f1d fix: sample linear and sRGB views of typeless RGBA8 volumes
A committed RGBA8 typeless image already permits mutable Vulkan views. Let explicit UNORM and sRGB Texture3D SRVs select their formats so shaders can read either interpretation of the same voxels.
2026-11-22 05:23:59 +01:00
53d2c6126b Report application-cache feedback for compiled Vulkan pipelines 2026-11-21 21:22:43 -07:00
8a58c59d71 Merge pull request #876 from sanuk369 2026-11-21 23:15:39 -05:00
12e53efa62 Merge pull request #875 from Cozma 2026-11-21 23:15:39 -05:00
7123be6c5e Merge pull request #869 from Ayoze Torres 2026-11-21 23:15:37 -05:00
e73037732f Merge pull request #868 from Størm 2026-11-21 23:15:37 -05:00
6b8b2e5f6e Merge pull request #865 from Felix Croasdale 2026-11-21 23:15:36 -05:00
f54d1f3f89 Merge pull request #864 from omardev29 2026-11-21 23:15:36 -05:00
524bb1fb7b Merge pull request #862 from sanuk369 2026-11-21 23:15:35 -05:00
5ff488901c Merge pull request #861 from adonizm 2026-11-21 23:15:35 -05:00
9b21cde473 Merge pull request #858 from traeb0n 2026-11-21 23:15:34 -05:00
67bb661453 Merge pull request #850 from sanuk369 2026-11-21 23:15:33 -05:00
a03a3db26b Merge pull request #737 from AlxcBTW 2026-11-21 23:15:27 -05:00
8d8c528aa1 Merge pull request #561 from Ayinaki 2026-11-21 23:15:23 -05:00
e28b1d63fb Merge pull request #423 from kotorvr 2026-11-21 23:15:23 -05:00
cce77b65ef Normalize binary occlusion results in Vulkan replay 2026-11-22 01:13:30 -03:00
enx
943e5f8048 Build the Windows runtime on Linux with clang-cl and xwin
runtime/cmake/clang-cl-xwin.cmake cross-compiles gta6rt, its shims and
tests with clang-cl and lld-link (LLVM 19+) against an MSVC CRT and
Windows SDK laid out by xwin, and makes ctest run them through Wine (or
Proton's wine). llvm-ml64 stands in for ml64, so the register-
preservation check in unimplemented_policy_test runs too.

Changes that let a cross build work without a Developer Prompt:
- gen_d3d12_stubs.py gets the d3d12.h CMake finds (--header) instead of
  relying on INCLUDE; without one the COM targets are skipped.
- d3d12_trace names the interpreter by path, so ctest doesn't prepend the
  emulator to Python, and check_d3d12_trace.py starts the fixture through
  the emulator (--runner).

docs/testing.md describes the build and the Wine and Proton runs.
2026-11-21 21:09:12 -07:00
9528e239e8 Tests: replay_cpu_bench, the layer's CPU cost per command
A benchmark of the D3D12 -> Vulkan replay's own CPU time: CommandList
recording, prepare and emit, with no-op Vulkan entry points that count
their calls and fake resource bindings, so no GPU, driver or game files
are involved. Bindings and image views are looked up the way
VulkanContext does (unordered_map, std::map view cache), and each
execution makes a new PreparedList, as VulkanQueue::execute does.

It reports, for every command kind on its own and for a frame mix
(barriers, whole-view and rectangle clears, buffer and texture copies,
a UAV clear, queries, predication), the median ns per command of each
phase, heap allocations per command and Vulkan calls per command, plus
the cost of just making and freeing the PreparedList entries.
--self-test (in ctest) checks that every kind and the frame record and
replay, and that the counts are the same on a second run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:07:56 -06:00
a6e3198607 Fuzzers: find vk_compute_test in a Visual Studio build
valu_fuzz.py and lds_fuzz.py ran <build>/vk_compute_test, so with the Visual
Studio generator (runtime/build/RelWithDebInfo) every program stopped with a
FileNotFoundError traceback. They now look in <build> and then its
RelWithDebInfo/Release folder, as run_gpu_tests.py does, and stop with one line
when it isn't built. crosslane_fuzz.py's default --exe gets the same fallback.
2026-11-22 09:37:03 +05:30