Commit Graph

4696 Commits

Author SHA1 Message Date
457e08460e Keep Vulkan isolate batches inside the requested slice 2026-11-23 03:43:59 +01:00
b82cb5e4ad Report Vulkan pipeline statistics write failures 2026-11-23 03:38:27 +01:00
71d8f86853 Translator: v_permlane16/x16 FI=0 and BOUND_CTRL for source lanes off in EXEC (SHADER-74)
op_sel:[FI, BOUND_CTRL] decides what a lane gets when the lane it reads is off in EXEC (or absent from a
workgroup smaller than the wave): FI=1 reads its value, FI=0 keeps the destination (BOUND_CTRL=0) or writes 0
(BOUND_CTRL=1). Measured on RDNA2 (issue #374). The activity of the source lane is shuffled with absent lanes
redirected first, as ds_lane_read does, and the old destination is a plain load, as dst() does.
cs_w32_permlane_fi (GPU) and test_permlane_fi (CPU); the shuffle-count and destination-select controls of
test_valu_permlane16 follow the extra activity shuffle on the FI=0 path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 21:37:38 -05:00
eb324590ea d3d12_xs: the header says to read a counter before the calls a test counts
Review of #4500: the note at the counter declarations now gives the rule
directly. Comment only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 05:35:49 +03:00
a5412e0d73 Runtime: report device loss from blocking multi-fence waits 2026-11-22 21:32:39 -05:00
dea6c38354 vulkan: skip later same-batch callbacks cancelled re-entrantly
FenceWaitDispatcher recorded every entry of a ready batch with the dispatching thread as owner, and in_flight() ignored all same-owner entries. A callback for semaphore A that re-entered cancel(B) therefore returned while B was still queued in the same batch and would run with a semaphore the caller had already destroyed.

Give each batch entry its own dispatch slot. cancel() marks not-yet-started slots for that semaphore as cancelled so dispatch skips them, while a callback actually running on another thread is still waited for. The skipped entry's event is completed so no waiter is left behind.

Regression: two ready callbacks in one batch; A cancels B and B must not run. Red before (B ran), green after.
2026-11-23 05:31:10 +03:00
9f2284455a d3d12_xs: the counter readers set the count flag one time only
Review of #4500: the *_slot_hits readers and reset_device_proxy_stats call
start_hit_counts, which writes g_count_hits only when it is not set.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 05:22:00 +03:00
112368dc22 frame_pacer: the new test case cannot hang on a blocked waiter; the comment states the unpaced condition
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 05:18:02 +03:00
f22661fef4 Report sampler readback write failures 2026-11-23 03:12:55 +01:00
6b690ec3a1 d3d12: OpenExistingHeapFromAddress, OpenExistingHeapFromFileMapping and CreateLifetimeTracker answer the host's argument errors 2026-11-22 21:12:10 -05:00
c3afb65c2f Report Vulkan pipeline binary export failures 2026-11-23 03:08:22 +01:00
0519bc2c81 gameinput: a reading callback's inputKind filter checks what the device supports
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 03:05:55 +01:00
c4486309c9 replay tests: compare the bench row name by content, count aligned allocations
Review of #4468: replay_cpu_bench compares the row name with std::strcmp
instead of by pointer, and replay_texture_barrier_test also replaces the
aligned forms of operator new and delete, so that an allocation of an
over-aligned type is counted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 05:05:01 +03:00
61c9aaa318 Keep Wave64 benchmark dispatches within Vulkan device limits 2026-11-23 03:03:33 +01:00
ea10c8e5fe tests: d3d12_options1_first_use yields when idle, compares named fields, has a bounded wait and a CTest timeout
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 05:02:08 +03:00
9b693ecd8a d3d12_xs: name the measured list tail slots in the first-call log
D3-445, contributed by shdann (tested on Windows 11, MSVC 14.51, RTX
4090; xs_proxy_mock passes, negative control fails as designed).

From CopyTextureRegionX on, the newer console layout sits two slots
later than the older one (docs/d3d12_xs_console_abi.md 5.3). A table
keyed by the older-layout slot gives every measured pair one name, so
list slot 85 under the newer layout and 83 under the older both log
"CopyTextureRegionX"; the seven unmeasured pairs print "tail method,
older slot N". A slot gets no name while the layout is unknown or when
it is not a measured slot of that layout, so a number never wears the
other layout's name. Naming only - console_to_pc_list_slot and the
forwarding are untouched.

Co-Authored-By: shdann <28006689+shdann@users.noreply.github.com>

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 19:00:35 -07:00
399b30f69b gameinput: GetRawReport holds hid_mu while it reads the raw reports
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 02:59:55 +01:00
8728339f9e Runtime: preserve fence signal and report blocking wait device loss 2026-11-22 20:57:54 -05:00
7b82b01e0b xgameruntime: XNetworking register calls send their initial callback
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 02:57:24 +01:00
b1fffe8357 d3d12: GetResourceAllocationInfo resource flag and sample quality parity (D3D-467) 2026-11-23 07:24:34 +05:30
f4e0cf2baa tests: read the realtime queue desc on the real queue; tools: check prebuilt .spv magic
Two leftovers from the console-ABI review round:

- PC GetDesc shares console slot 18 with the newer layout's
  GetTimestampFrequency; the proxy deliberately serves the frequency
  getter while the layout is undetected, so the GLOBAL_REALTIME
  priority check reads the desc on the real queue instead of trusting
  an 8-byte frequency written into a desc-shaped out-buffer.
- shaders_into() accepted any two files named vs.spv/ps.spv when
  spirv-as was absent; a stray file would reach vk_harness and fail
  far from the cause. The prebuilt pair is now checked against the
  SPIR-V magic first.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 18:53:55 -07:00
c69810257c Link the Windows Vulkan pipeline checker with the static CRT 2026-11-23 01:52:17 +00:00
00832c18cd Runtime: propagate queue progress counter device loss 2026-11-22 20:51:10 -05:00
a1ec0cbca9 d3d12_xs: a proxied call writes no shared atomic after the first call of its slot
note_slot, note_heap_slot and note_child_slot did a fetch_add on the slot's hit
counter and a compare_exchange_strong on its first-call flag for each proxied
call. The compare-exchange takes the cache line for writing also when it
fails, and the flags of all slots share one or two lines, so threads that
call different slots slowed each other.

The first-call flag is now read before the compare-exchange. The hit counters
are test helpers: they count from the first call of a *_slot_hits reader or
of reset_device_proxy_stats, so a title's calls do not write them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:50:46 +03:00
a0cf874d24 Merge buffer-formats-all-v2 (merged with main 03b09a08) into buffer-stores-rdna2
Conflict in docs/design.md only: v2's rows (main's with the Typed buffer loads sentence) kept, with
this branch's "Others (code 0 and 78 up) give 0".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 02:48:55 +01:00
0f0c85ccbc d3d12: committed resources accept ALLOW_SHADER_ATOMICS with a UAV
CreateCommittedResource refused D3D12_HEAP_FLAG_ALLOW_SHADER_ATOMICS on
every resource. On an RTX 4070 Laptop (621.24) and WARP the host accepts it
on buffers and textures with ALLOW_UNORDERED_ACCESS, refuses it without,
and keeps it in GetHeapProperties. Match that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:45:39 -03:00
df99c89162 vulkan: make fence cancel wait for in-flight callbacks
run() unlocked mutex_ before dispatching ready entries, while cancel() only waited for an active vkWaitSemaphores. A cancel could return and destroy the VkSemaphore while a callback for it was still running. Record each dispatched entry with its owning thread before unlocking; cancel waits for entries it does not own, so callbacks can still re-entrantly cancel their own semaphore. All four run() dispatch paths use the same helper. Adds a deterministic regression where cancel must block until a blocked callback has used the semaphore; reverting only the wait fails it.

AI-assisted (OpenCode)
2026-11-23 04:44:51 +03:00
37632c9868 file_system: refuse the overlay's reserved folders as explicit GAME: paths (RT-294)
internal_dir() hid .gta6rt-deleted, .gta6rt-temp and .gta6rt-copy from GAME:\ listings only; parse_console() still
accepted them as the first component of a GAME: or G: path, so a title could list deletion markers and write into the
runtime's scratch folder. parse_console() now refuses a reserved first component after normalisation, which every
caller already answers with ERROR_INVALID_NAME, the same as climbing out of the root. T: is unaffected: its scratch
component is pushed by the parser, not read from the title's path. The probes of the previous commit pass.

AI-assisted (Claude Code, Claude Fable 5.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
2026-11-23 02:43:40 +01:00
39d748f250 file_system_test: probes for explicit GAME: paths into the overlay's reserved folders (RT-294)
The overlay's .gta6rt-deleted, .gta6rt-temp and .gta6rt-copy folders are hidden from GAME:\ listings but an explicit
GAME:\.gta6rt-*\... path still reaches them. These probes open, stat, list, create, mkdir and delete through such
paths in the spellings parse_console() normalises (case, forward slashes, ".", ".." and the G: alias), expect
ERROR_INVALID_NAME and no side effect, and keep T:\ and an ordinary dotted name working. They fail on main.

AI-assisted (Claude Code, Claude Fable 5.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
2026-11-23 02:43:40 +01:00
128a9c0523 Avoid temporary string keys in shader lookup 2026-11-23 02:42:30 +01:00
f167f5a82f pe_loader: test a section and a relocation that start exactly at SizeOfHeaders
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 02:41:35 +01:00
7cc353106f d3d12_xs: PC-shaped lists for PC callers, atomic queue layout, S_OK queue tail
Review findings from shdann's Windows run of the new console queue/list
work:

- d3d12_debug_markers (and every GPU harness compiled against the PC
  headers) drove lists through the console-shaped proxy, so PC slots past
  26 — including the PIX markers at 56-58, which have no console
  counterpart — reached unrelated console methods or were dropped.
  create_device_proxy gains console_lists: false hands the real
  (PC-shaped) list back from CreateCommandList. The GPU tests pass false;
  the title path keeps the console default.
- queue_proxy asserted E_NOTIMPL for the queue's console tail, but those
  slots deliberately answer S_OK now — frame pacing flows through them.
  The test's contract is updated; the fence tail stays refused.
- ChildProxy::queue_layout was a plain unsigned char read and written
  from many threads; it is atomic like the device-wide detection it
  caches.

xs_proxy_mock_test and loader_test pass under Wine; the modified test
objects compile clean under clang-cl. The GPU harnesses need a real
adapter — covered by shdann's Windows run.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 18:41:23 -07:00
0e63ec7658 test: reject bogus fence progress on transient Vulkan counter error 2026-11-22 20:41:18 -05:00
1674b1be52 Merge origin/main into buffer-formats-all-v2
Conflicts: tools/rdna2spirv.py (main's x_round state next to this branch's fmt_enc_fn, and the
function types of both: both kept), docs/design.md (main's rows, our Typed buffer loads sentence
re-applied), tests/test_shader_checks.py (TOTAL: main's 13 plus cs_fmt_all = 14, and both mock
branches kept; 75 tests pass).

Main's typed-buffer work that overlaps (aa2988cc: byte size of the format from one table, SHADER-429:
DST_SEL=1 on out-of-bounds typed loads) merged without conflict and takes this branch's formats from
Gen.FORMATS. Ten tests in test_mutations, test_cmp_class_f64, test_loop_ballot_barrier and
test_vcmp16_opsel fail on origin/main itself, with and without this branch.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 02:39:02 +01:00
7de2d4461b rdna2spirv: ignore omod on f16 results with denormals kept, keep clamp (gfx1036) 2026-11-23 04:39:01 +03:00
c01e909b8a runtime/README: typeless RTV and 1D-texture lines follow the code
Three sentences said MSAA RTVs, SINT/SNORM views, mip/array ranges, typed-resource casts and 1D
textures were not supported. CreateRenderTargetView handles TEXTURE2DMS/TEXTURE2DMSARRAY and
family-compatible typeless views, a typed R8G8B8A8_UNORM resource with a castable-format list
takes listed views, 1D textures are created (only 1D attachments are refused), and
d3d12_typeless_rtv_test / typeless_rtv_test cover mips, arrays, 4x MSAA and SINT/SNORM.
Doc only.
2026-11-23 02:36:15 +01:00
92848ba954 shims: undetected queue slot 18 answers the frequency getter
shdann's second case on #2490: a title reads the timestamp frequency at
start-up, before any fence call has detected the layout. Slot 18 then
went to the PC GetDesc - a struct-return write of a whole desc through
a caller that passed an 8-byte out pointer - so the frequency came
back unset (and the write overran).

While the layout is still unknown the call is served as the newer
layout's GetTimestampFrequency instead: an 8-byte write stays inside
either interpretation's buffer. A queue or device already proven
older keeps the generic GetDesc forward; slots 19 and 20 stay no-ops
because their newer interpretations write through caller pointers an
unmodelled older method might not supply.

The mock queue's slot 16 now writes a fixed frequency (unless the
argument is a mock object - then it is a newer Signal's fence), and
check_signalx_detection covers the undetected query and the post-
detection shifted path.
2026-11-22 18:34:12 -07:00
111eb7e6f6 winhttp_offline: initialize server/port and hold ref across HANDLE_CREATED
In `open_connection()` (`WinHttpConnect`), `make_handle(Kind::Connect, s,
s->async)` previously inserted the new `Handle` into `live()` and
synchronously invoked `WINHTTP_CALLBACK_STATUS_HANDLE_CREATED` before
`c->server = server` and `c->port = port` were assigned, and without
holding a temporary reference on the handle while `HANDLE_CREATED` ran.

This caused three issues when a `HANDLE_CREATED` callback acted on the
handle inline or handed it to another thread:
1. Calling `WinHttpCloseHandle(self)` inside `HANDLE_CREATED` erased and
   freed `Handle` (`refs` 1 -> 0 -> `delete h`) before `make_handle()`
   returned, causing `open_connection()` to write `server` and `port`
   into freed heap memory (use-after-free).
2. Because `make_handle()` held no reference across `HANDLE_CREATED`,
   `WinHttpCloseHandle(self)` inside `HANDLE_CREATED` fired
   `WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING` re-entrantly before
   `HANDLE_CREATED` returned and still returned the freed non-null
   `HINTERNET` handle from `WinHttpConnect` / `WinHttpOpenRequest`,
   whereas native `winhttp.dll` (measured on Windows 11 26200) fires
   `HANDLE_CLOSING` after `HANDLE_CREATED` exits and returns `NULL` with
   `ERROR_WINHTTP_OPERATION_CANCELLED` (12017).
3. Opening and sending a request from inside `HANDLE_CREATED` (or from a
   worker thread notified by it) caused `log_refused()` / `server_of()`
   to read an empty `server` and port `0` (`:0`) or race with
   `std::wstring` assignment.

Initialize `h->server` and `h->port` inside `make_handle()` before
inserting into `live()`, hold an extra reference across
`WINHTTP_CALLBACK_STATUS_HANDLE_CREATED` so `HANDLE_CLOSING` fires after
`HANDLE_CREATED` returns, and return `nullptr` with
`ERROR_WINHTTP_OPERATION_CANCELLED` if the callback closed the handle.

Verification (synthetic tests only, no game files):
- `winhttp_offline_test`: 57/57 checks pass via CTest and direct run
- MSVC `/fsanitize=address`: 57/57 checks pass with 0 ASan errors
  (reproduced `heap-use-after-free` on unpatched `origin/main`)
- Adjacent non-GPU runtime shim tests (`loader`, `dll_thread_calls`,
  `unimplemented_policy`, `xmem`, `process_cmdline`, `file_system`,
  `winhttp_offline`, `xgameruntime`): 8/8 passed via CTest
- `python -I scripts/check_no_game_data.py`: passed

Coordination claim:
https://github.com/ItsNotRexed/Leonida/issues/4257#issuecomment-7088991989

AI-assisted implementation and testing.
2026-11-22 22:34:11 -03:00
c52b16287f test: treat native zero-scissor driver divergence as advisory 2026-11-22 20:32:34 -05:00
7d60a27a6a Create XDXR fixture output directory at startup 2026-11-23 02:32:03 +01:00
e6aa341244 shims: the per-queue layout cache is atomic like the device flag
shdann's source read on #2490: queue_layout is read and written in
child_slot with no synchronisation, so concurrent Signal/Wait calls on
one queue can race the detection write. The shared console_layout on
the device is already an atomic; give the per-queue cache the same
treatment - every use is a compare or an assignment, which the atomic
keeps answering.
2026-11-22 18:31:13 -07:00
c43942fddf d3d12: 1D render targets and depth buffers
CreateCommittedResource refused every TEXTURE1D with ALLOW_RENDER_TARGET or
ALLOW_DEPTH_STENCIL ("1D texture cannot be an attachment"), although the PC
runtime creates them: on an RX 6750 XT the AMD adapter and WARP both accept
64 color formats as 1D render targets and 20 as 1D depth-stencils. The 1D
RTV/DSV code already on main was unreachable.

Accepting them also needs a valid attachment view: VulkanBackend::view made
every attachment view VK_IMAGE_VIEW_TYPE_2D_ARRAY, which a VK_IMAGE_TYPE_1D
image can't take (VUID-VkImageViewCreateInfo-subResourceRange-01021). That
already hit rectangle clears of 1D UAV textures on main, whose UAV images
get color-attachment usage. ResourceBinding now records a 1D image, and its
attachment views are 1D arrays. A driver without the 1D attachment image
still refuses through check_image_support.

d3d12_texture1d_target_test compares creation with the host adapter and
WARP, and reads back clears through 1D and 1D-array RTVs and DSVs (whole and
rectangles, mips, slice ranges) and a 1D UAV rectangle clear against WARP.
d3d12_typeless_families_test runs its draws on a 1D target too.
d3d12_vulkan_device_test expected the old refusal.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015z45kpgzff6KvVjAnLtc4h
2026-11-22 22:30:25 -03:00
8d1556774e tests: queue and marker tests follow the console list/queue ABI
shdann's run on #2490 (Windows 11, MSVC, RTX 4090 + Radeon): two tests
that pass on main fail on this head.

queue_proxy expected E_NOTIMPL for every queue slot past the public
chain. The console contract answers those S_OK instead - frame pacing
flows through them - which xs_proxy_mock already requires. The queue
loop now expects S_OK, SignalX at slot 23 and PresentX at slot 30 are
checked as the modelled methods they are (a fence reaching 9 proves
SignalX forwarded; PresentX is handled, not refused), and the fence
tail keeps its E_NOTIMPL contract unchanged.

d3d12_debug_markers called SetMarker/BeginEvent/EndEvent through the
PC interface on what is now a console-shaped list: PC slot 56/57/58
land on console slots that map elsewhere, and the first Close failed.
The console ABI has no SetMarker or BeginEvent at all - its one marker
slot is EndEvent at console 60 - so the PC calls now go to the real
list behind each proxy via list_proxy_real_list; the proxy queue still
unwraps the proxies at ExecuteCommandLists.
2026-11-22 18:30:17 -07:00
2c3b42ec48 Exercise pipeline input protection against hard links in CTest
Use a real hard link when the test filesystem supports it. Check that the index and skip file hashes survive rejected output paths. The test passes on Debian and fails when equivalent() is replaced with lexical normalization alone.

AI-assisted (Codex).
2026-11-22 22:29:12 -03:00
7d71e8328a vulkan: retain prepared-list storage across smaller submissions
resize() down destroyed the per-list vectors that prepare refills, so a queue alternating 8 lists and 1 list rebuilt them every frame. Grow the vector only, and iterate the current list count in the query and emit loops so retained entries are never replayed. Registers the existing vk_queue_test with CTest and adds an 8-then-1 GPU regression with a negative control.

AI-assisted (OpenCode)
2026-11-23 04:28:47 +03:00
0c2e48eab1 tests: d3d12_options1_first_use uses no more threads than cores, 500 rounds
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:28:38 +03:00
51f9555131 Runtime: propagate Vulkan fence counter device loss to D3D12 2026-11-22 20:28:35 -05:00
7b1e5b40bf replay: emit keeps an enhanced texture barrier's image barriers on the stack
emit made a std::vector<VkImageMemoryBarrier2> for each TextureBarrier: one
heap allocation for each enhanced texture barrier. The barriers of the usual
one or two layout pieces are now in a stack array; a vector holds them only
when a range has more than two pieces.

replay_cpu_bench gets an enhanced texture barrier row, and its self-test
fails when emit allocates for that row. replay_texture_barrier_test checks
the barriers of a one-piece range (no allocation) and of a three-piece range.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:27:13 +03:00
844e650bfa file_system: only a T: path names the T:\ root, so GAME:\.gta6rt-temp is not refused as one
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 02:22:26 +01:00
f121a4f32a d3d12_vulkan_device: read the OPTIONS1 subgroup facts with std::call_once
subgroup_facts set a plain bool before it filled the data, so a second
thread that made its first CheckFeatureSupport(D3D12_OPTIONS1) call at
the same time could read WaveOps FALSE and lane counts of 0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:20:26 +03:00