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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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)
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
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
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>
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>
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.
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.
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.
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.
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
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.
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).
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)
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>
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>