Commit Graph

4696 Commits

Author SHA1 Message Date
86d92e13ad [BUILD-761] Validate SPIR-V file framing before creating modules 2026-11-22 18:59:19 +01:00
b30eead831 d3d12_vulkan_device_test: realign
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:58:47 +00:00
0e70866b9a fix(startup_trace): guard SEH unwind in VEH handler and tear down safely at exit 2026-11-22 14:58:44 -03:00
d59cf62ee5 d3d12_vulkan_device_test: don't shadow the feature-level array (MSVC C4456)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:58:40 +00:00
e14b88fc5c Runtime: reserved resources report AMD's packed tile count (D3D-65 follow-up)
The layer gave the packed tail its tight linear size in whole tiles. AMD's PC
runtime gives it one tile per tile-depth slice it spans: ceil(depth of the
first packed mip / tile depth), so 1 for every 2D layout and a step at each
tile depth for volumes (8x8x32 R8: 1 tile, 8x8x33: 2, 8x8x256: 8), even where
the bytes would fit in fewer (16x16x128 RGBA8: 8 tiles for 3 tiles of data).

Measured on an RX 9070 XT (RDNA4, 32.0.31041.1004) and a Ryzen 7 9800X3D iGPU
(RDNA2, 32.0.21045.5002), identical on both: the rule fits all 83 layouts, the
47 from #868 (where it explains the two deep volumes AMD gave 2 tiles) and 36
new volumes whose tail is deeper than a tile, including tails that start after
standard mips. It matters once sparse textures (D3D-285) reach mip tails.

- src/resource_tiling.h: packed tiles = max(1, tight size, tail depth slices).
- resource_tiling_test: the two deep volumes expect 2, plus the 36 new volumes
  with AMD's values.
- docs/d3d12_vulkan.md 4.2: the rule and the measurement.

AI-assisted (Claude Code).
2026-11-22 12:56:50 -05:00
a5fdc8bbf9 Cache GFX10 tile X offsets and per-row Y contributions
Avoid per-element bit interleaving in tile/detile copies; retain element_offset as the independent reference and validate decoded output against it.

AI-assisted.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:56:49 +00:00
5b5b69aed3 bvh_builder_test: name the container behind each PSO creation (RT-182)
LEONIDA_BVH_RECORD62=1 now prints the module of each CreateComputePipelineState
call (the file name in the container's ILDN part) and says when a creation passes
a container byte-identical to an earlier one. The constructor makes 53 creations
over 52 containers; the repeat is GetBVHCompactedSize (5,284 bytes = 0x14a4):
creations #47 and #53. The test prints a summary and checks that the repeated
container names the same module both times.

docs/embedded_shaders.md answers the open question and lists the creation order.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 18:55:53 +01:00
37c29f6c82 Tests: GPU test for the far-branch idiom, and no crash on it without encodings
ps_far_branch runs s_getpc_b64 / s_add_u32|s_sub_u32 / s_addc_u32|s_subb_u32 /
s_setpc_b64: two forward jumps, a sub/subb loop, an add/addc -1 loop and a
conditional far jump, with K derived by hand. fold_far_branches now folds the
idiom only when its instructions have encodings, so a listing without them
gives Unsupported instead of a TypeError.

AI-assisted.
2026-11-22 18:54:57 +01:00
e7ee2d7f99 Tests: the Linux cross-build compiles the FSR and BVH builder tests
clang-cl 19 and 20 crash (exit 139, in recoverAddrOfEscapedLocal) on the
__except filters of fsr_dispatch_test.cpp and bvh_builder_test.cpp: each
guard's `Call c` is also its named return value, and the filter writes it.
That stops the cross-build of runtime/cmake/clang-cl-xwin.cmake before the
rest of the tests. Return a copy instead, so `c` stays an ordinary local.
Behaviour is unchanged; both tests still skip without a package.
2026-11-22 17:54:37 +00:00
a9ae002cc0 CMake: find ml64 beside the selected MSVC compiler 2026-11-22 18:53:27 +01:00
64184fc835 Merge main into sdwa-dword-hi16 (#2187)
Conflicts:
	tests/semantic/test_value_semantics.py

AI-assisted.
2026-11-22 18:53:24 +01:00
ccc7cf8f3c Merge remote-tracking branch 'upstream/main' into d3d-msaa-quality-levels-host 2026-11-22 17:52:50 +00:00
0cb7b7bf41 [BUILD-748] Check mesh workgroup memory before pipeline compilation 2026-11-22 18:52:11 +01: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
c43291cbe1 Add standalone GFX10 RbPlus 2D tile and detile primitive
D3D-316: copy the validated Python 4KB_S and 64KB_D bit patterns into a bounded, portable helper. Cover padded bijections, round trips, Python known offsets and invalid inputs without a GPU.

AI-assisted.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:49:56 +00:00
6e65dc9ec2 xgameruntime: resolve MSVC C4201 nameless struct and C4996 strncpy warnings 2026-11-22 23:15:27 +05:30
5ab5c208c9 xgameruntime: deny mounting game package identifier with E_ACCESSDENIED 2026-11-22 23:15:27 +05:30
4a90673850 xgameruntime: validate installed package identifiers and reject unknown packages in XPackageMount 2026-11-22 23:15:26 +05:30
cb8c6445fc xgameruntime: implement XPackageMount and handle registry for mount path getters 2026-11-22 23:15:26 +05:30
48cf34f3a8 xgameruntime: implement XPackageGetMountPathSize and validate XPackageMountHandle per GDK spec 2026-11-22 23:14:50 +05:30
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
fd9bc14131 dxgi: return DXGI_STATUS_OCCLUDED on CreateSwapChain fullscreen fallback and add test 2026-11-22 23:12:44 +05:30
342eef5eb5 dxgi: match native DXGI INVALID_CALL for CreateSwapChain params and E_NOINTERFACE on Factory::GetParent 2026-11-22 23:12:44 +05:30
7ec740b9be dxgi: implement Factory CreateSwapChain delegation, GetParent, and SwapChain GetCoreWindow/GetRestrictToOutput 2026-11-22 23:12:43 +05:30
90f399e953 Runtime: warn loudly (or fail) when CMake finds no Vulkan headers
Without Vulkan headers everything under if(TARGET Vulkan::Headers) is left
out: the D3D12 COM objects, the Vulkan D3D12 device in gta6rt
(LEONIDA_D3D12=vulkan) and most of ctest. The only output was a STATUS line
naming four test tools, so a build whose VULKAN_SDK never reached CMake ran
45 of 125 tests and reported "100% tests passed".

- runtime/cmake/vulkan_headers_missing.cmake: a WARNING that names what is
  left out and that CMakeCache.txt keeps the failed lookup.
- LEONIDA_REQUIRE_VULKAN=ON turns it into a configure error; both CI
  configures pass it, and scripts/build_runtime.ps1 does when VULKAN_SDK is set.
- tests/test_cmake_vulkan_missing.py runs the module with cmake -P and checks
  that CMakeLists.txt and CI use it; docs/testing.md gets a troubleshooting row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:41:47 +01:00
b43aa8854b d3d12_state_map_test: cover the primitive-topology map
vulkan_topology (D3D12 primitive topology -> VkPrimitiveTopology) and
strip_topology (which Vulkan topologies a restart index cuts) had no test. A
wrong mapping draws the wrong primitive; a wrong strip classification restarts an
indexed strip that should not, or fails to restart one that should.

Pins both: every mapped D3D12 topology value to its VkPrimitiveTopology and strip
flag, the triangle-list fallback for list/undefined/unmapped values, and the
strip classification, with the D3D_PRIMITIVE_TOPOLOGY enum values SDK-asserted.

ctest -R d3d12_state_map passes (MSVC /W4 /permissive-, Windows SDK 10.0.26100,
Vulkan headers 1.4.363). Header-only, no GPU, no game files.
2026-11-22 14:40:03 -03:00
458c21946d Make vk_harness GPU writes visible to host readback 2026-11-23 03:39:42 +10:00
af330fcce3 gameinput: keep only the haptic calls the shim makes in the test seam (RT-160)
HapticApi carried SDL_GetNumHapticAxes and SDL_HapticEffectSupported, which
nothing calls: the motor's axes are the shim's choice and the effect kinds are
gated on SDL_GetHapticFeatures. They are gone from the table, its SDL
implementation and the test's fake, so the seam is exactly the calls a pad's
force feedback makes.

AI-assisted.
2026-11-22 18:37:28 +01:00
29b1ba10d9 Tests: GPU test for 16-bit float v_cmpx compares (all 16 f16 predicates, e32 and e64)
Two pixel tests, ps_vcmpx_f16 (e32) and ps_vcmpx_f16_e64 (swapped operands),
on the operand pairs of ps_vcmp_f16: the EXEC result of each predicate, VCC
kept, and EXEC only ANDed. Words derived by hand in the headers; semantic
fixture and test added.

AI-assisted.
2026-11-22 18:37:20 +01:00
ced616cc57 runtime: enable /EHsc on loader and proxy test targets for MSVC 2026-11-22 18:36:23 +01:00
9f41bf65f3 gta6rt: WinHTTP offline for mapped images
The package's XCurl.dll and libHttpClient.GDK.dll import 16 WinHTTP functions
(no Winsock) and bound to the host's winhttp.dll, so a mapped title could reach
the network. winhttp.dll is now a module the shims own and all 16 are answered
in-process:

- sessions, connections and requests are local handles; no name lookup, no
  socket;
- WinHttpSendRequest fails with ERROR_WINHTTP_CANNOT_CONNECT; on a
  WINHTTP_FLAG_ASYNC session it returns TRUE and reports
  WINHTTP_CALLBACK_STATUS_REQUEST_ERROR {API_SEND_REQUEST, CANNOT_CONNECT} from
  a thread-pool thread with the request's context (not after the request was
  closed);
- reading a response and WinHttpWriteData fail with
  ERROR_WINHTTP_INCORRECT_HANDLE_STATE; options, timeouts and headers are
  accepted, CONTEXT_VALUE and HANDLE_TYPE can be queried;
- callbacks are inherited by child handles (HANDLE_CREATED), and every handle
  reports HANDLE_CLOSING once, last (reference-counted, so a callback that
  closes its own request is safe);
- WinHttpCrackUrl stays the host's (parsing only, loaded on first use).

Each refused server is logged once. winhttp_offline: 40/40 checks, .invalid
names only, no connection opened.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:35:57 +03:00
98b0335c6c d3d12: log when an allocation spills from DEVICE_LOCAL to host memory (D3D-299) 2026-11-22 18:33:06 +01:00
861df84bfd image_fuzz: support --pc-tail-ubo / LEONIDA_PC_TAIL_UBO=1 on 128-byte devices
Honour LEONIDA_PC_TAIL_UBO=1 in runtime/test/vk_image_fuzz.cpp by sizing the
push-constant range and vkCmdPushConstants to 128 bytes (s0..s31; the fuzz
shaders read neither heap base nor code base, so they declare no set-1 block).

Add --pc-tail-ubo (and LEONIDA_PC_TAIL_UBO=1 env detection) to
tools/image_fuzz.py so it forwards --pc-tail-ubo to rdna2spirv.py and sets
LEONIDA_PC_TAIL_UBO=1 for vk_image_fuzz, enabling 128-byte push-constant GPUs
to run the image fuzzer instead of skipping every case.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-22 19:32:05 +02: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
2aed56c6e5 RT-176: IGameInputDispatcher::Dispatch honours its quota
Dispatch ran the whole queue whatever quota it was given. It now runs
queued events oldest first, at least one per call (a quota of 0 runs
exactly one, as the GDK documents), takes no further event once the
quota has passed, and returns whether events remain. While events
remain the wait handle is signalled again, so a title that waits on it
before each call comes back for the rest.

The automatic path (no dispatcher, poll thread) still delivers the
whole queue. gameinput_test checks Dispatch(0), a 1 ms quota against a
5 ms callback, a large quota draining the queue, and an empty queue.
2026-11-22 14:31:09 -03:00
e535568826 Tests: four D3D12 tests skip on a 128-byte push-constant GPU instead of failing
d3d12_fspx_compute, d3d12_msaa_draw, d3d12_set0_compute and
d3d12_pipeline_library build PSOs from 144-byte shaders. On a device
whose maxPushConstantsSize is 128 (AMD's Windows driver on RDNA2 iGPUs,
some Intel Arc drivers) the layer refuses those PSOs with E_NOTIMPL, as
D3D-14 intends, so the tests failed at the first CreatePipelineState and
ctest reported 4 failures on a correct runtime. They now exit 77 there
(SKIP_RETURN_CODE in CMake) with the reason; pipeline_library still runs
its library-blob checks first. Devices with 144 bytes or more are
unchanged. d3d12_compute and d3d12_draw are left to #2402, which runs
their --pc-tail-ubo path on such devices.

AI-assisted.
2026-11-22 17:29:58 +00: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
f161481d34 Merge main into valu-int-misc (#1492)
Conflicts:
	tests/semantic/regen_fixtures.py

AI-assisted.
2026-11-22 18:29:33 +01:00
dd678a7681 Merge main into coverage-gaps (#1299)
Conflicts:
	tests/semantic/regen_fixtures.py

AI-assisted.
2026-11-22 18:29:28 +01:00
abc889f5ec Initialize game command line before process-attach callbacks
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:27:41 +00:00
a3b1719c61 gameinput: report and drive force-feedback and haptic motors through SDL3 haptics (RT-160)
IGameInputDevice answered the force-feedback and haptic half of the API with
nothing: no motors in GameInputDeviceInfo, E_INVALIDARG from
CreateForceFeedbackEffect, false from IsForceFeedbackMotorPoweredOn, a no-op
SetForceFeedbackMotorGain and E_INVALIDARG from SetHapticMotorState. A pad SDL
opens as a haptic device now reports one force-feedback motor with the effect
kinds SDL lists, and a pad with trigger motors reports two haptic motors.

Force feedback goes to SDL_CreateHapticEffect/RunHapticEffect on the poll
thread, so title calls still never touch SDL; the eleven GameInput effect kinds
are SDL's eleven force-feedback effects. The trigger haptic motors play their
one waveform as an intensity on the existing trigger output. A pad with neither
keeps the old answers, and LEONIDA_RUMBLE=0 silences both. gameinput_test drives
all of it through a fake haptic backend, because SDL's virtual joysticks report
no haptics.

AI-assisted.
2026-11-22 18:26:28 +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
03d390fb95 Reject unexpected output changes in cross-device Tier C wave64 checks 2026-11-22 10:25:54 -07:00
b0a9c16d21 d3d12: private data answers as the host runtime does
d3d12_private_data_test runs the same 672 GetPrivateData / SetPrivateData /
SetPrivateDataInterface / SetName steps on the device, a fence, a buffer, a
command allocator and a descriptor heap of the Vulkan-backed device and of the
host runtime, and compares every HRESULT, returned size, byte and reference
count. On main 130 of them differed (RTX 3060, driver 610.88), the same four
rules on every object:

- SetPrivateData with null data removes the entry whatever the size: S_OK
  when there was one, S_FALSE when there wasn't. The layer answered
  E_INVALIDARG for a nonzero size and kept the entry, and S_OK for a missing
  one.
- Zero bytes with data keep an empty entry (size 0); the layer removed it.
- SetPrivateDataInterface(null) releases the interface and keeps a
  pointer-sized entry that reads back as null; the layer removed it.
- SetName is not readable through GetPrivateData: the host sets neither
  WKPDID_D3DDebugObjectNameW nor the narrow key. The layer stored the name
  there; it now keeps it apart (debug_name()).

SetName(nullptr) faults in the host runtime; the layer still clears the name,
and the test reports those 5 steps as not compared.

d3d12_debug_markers_test's private-data checks expected the old answers and
now expect the host's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:24:14 +01:00
6bbc893ea2 Tests: GPU test for 16-bit float VOPC compares (all 16 f16 predicates, e32 and e64)
Two pixel tests, ps_vcmp_f16 (e32, VCC) and ps_vcmp_f16_e64 (SGPR destination,
swapped operands), with NaN, +-0, +-inf, f16 denormals and junk high halves.
Words derived by hand in the headers; semantic fixture and test added.

AI-assisted.
2026-11-22 18:24:00 +01:00
5620a444ad Runtime: review fixes for DisableThreadLibraryCalls
- the DisableThreadLibraryCalls table entry gets its own continued line (it
  shared FreeLibrary's, 231 columns wide), and its comment is wrapped to 120;
- dll_thread_calls_test also calls the shim with a shim pseudo-handle (the
  handle GetModuleHandleA("xmem.dll") returns), which the Windows function
  would refuse: removing the pseudo(module) branch now fails the test.
  xmem.cpp is linked into the test only to give the shims a module to own.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 18:23:23 +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
84f86c5a7d test: cover XMem virtual allocation APIs 2026-11-22 17:20:42 +00:00
6a2246c299 TEST-330: check presented colour via swapchain readback under Wine 2026-11-22 18:19:43 +01:00
44a5274369 fix(tests): honor spacing in compute fixture workgroup sizes
A spaced group tuple fell back to the default dimensions and changed the LocalSize emitted by the shader translator.
2026-11-22 18:15:42 +01:00