Commit Graph

4696 Commits

Author SHA1 Message Date
26dd394107 Cover sparse texture copies across Vulkan queue families 2026-11-22 18:52:55 -03:00
b8273c0e39 runtime: buffer_at prefers an aliasing buffer that holds the whole view
With placed buffers aliasing in one heap, a large buffer B and a small S
inside it, a vertex or index view that starts in S and runs past its end
resolved to S, the closest start below the VA, and buffer_at cut it at
S's end: the rest read as out of bounds, though B holds all of it. Found
by traeb0n in the review of #2823.

BufferVaIndex::find takes the bytes the lookup needs and returns, among
the ranges that hold the VA, the closest start (larger ID on a tie) that
also holds all of them; when none does, the closest that holds the VA,
as before. Without overlaps the first range it looks at is still the
answer. With a fallback found, the walk stops once no range can hold all
the bytes, bounded by the longest live range. buffer_at passes the
requested size.

buffer_va_index_test checks views that fit in the small buffer, run past
it into the large one, run past every range and have size 0, and three
quarters of the random-table lookups now name a view of up to 32 KiB,
checked against a scan with the same rule.
2026-11-22 22:50:57 +01:00
18024dd3a4 runtime/README: say what the shims and the Vulkan device cover today
Two passages were out of date or vague.

The d3d12_xs bullet said the Vulkan device covers submission, heaps,
views, committed resources and copies. It also creates root signatures,
graphics and compute pipeline states, and records draws, dispatches and
ExecuteIndirect (shims/d3d12_vulkan_device.cpp, shims/d3d12_com.cpp).

"Current limits" listed what the missing executable blocks without saying
what exists. Now, per item, checked against the code:

- D3D12XboxCreateDevice exists (shims/d3d12_xs.cpp) and wraps the PC or the
  Vulkan device in the proxy; the params/flag layout and the Xbox vtable
  beyond slots 62, 67 and 76 are unmeasured (shims/d3d12_xs_device.h,
  docs/d3d12_vulkan.md);
- the queue and fence proxies forward the public slots and refuse the
  console's PresentX/SuspendX/ResumeX slots, which are unknown; PresentX and
  the frame events are implemented in shims/xbox_present.* and tested
  (xbox_present_test) but not reachable through those slots yet;
- xgameruntime: QueryApiImpl serves XThreadingImpl, XErrorImpl,
  XNetworkingImpl and XSystemImpl and refuses other classes with a log
  (shims/xgameruntime.cpp, xgameruntime_test).

Say that none of this was measured against the real executable.

Claimed in #3574. Written with AI assistance (Claude, via OpenBot).
Tested: python -I tests/test_docs_{design_rows,links,list_items,repo_paths}.py,
tests/test_i18n_index.py and tests/test_text_write_line_endings.py pass;
git diff --check is clean (Windows 11, docs only; no GPU involved).

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
2026-11-22 18:49:18 -03:00
f722ab298c Share sparse reserved images across Vulkan queue families 2026-11-22 18:47:55 -03:00
557a25ed3e vk_compute_test: VKC_HEAP_FILE takes decimal or 0x offsets only
strtoull(..., 0) accepted a leading zero as octal (@0256 loaded at 0xae), and a
sign or spaces. Parse decimal or 0x hex explicitly, cap the offset at 4 GiB, and
document the two overlaps: bvh mode writes its synthetic scene after the copy,
so 0x100..0x264 is overwritten there, and the output V# starts at heap offset 0.
Reported by @wildheathen.
2026-11-22 18:43:33 -03:00
421bf0bf34 d3d12_compute: skip the CachedPSO host comparison under Wine
#1683's comparison expected Wine to have no host D3D12 device or no compiler. Wine has
both (vkd3d and its d3dcompiler_47), but vkd3d's GetCachedBlob is a stub, so
cached_pso_cases returned no answers for each host adapter and `host == layer` failed
on every run (line 388; Apple M3 Max, CrossOver 26.3 / Wine 11 with MoltenVK 1.4.3).
Like the other host comparisons (host_wine.h), it now skips under Wine and says why;
the layer's own 11 answers are still checked against the expected list.
2026-11-23 01:41:31 +04:00
b28832bab4 Tests: give each process its own temp folder for its shader library
d3d12_compute and the other tests that write a translator-style shader library under
the temp directory (d3d12_draw, d3d12_set0_compute, d3d12_msaa_draw, d3d12_fspx_compute,
d3d12_pipeline_library, d3d12_subgroup, d3d12_bundle, d3d12_typeless_families,
shader_library) used one fixed folder name. Two copies running at once (ctest -j, or two
suites in one Wine prefix or TMPDIR) shared it, and one copy's remove_all deleted the
modules the other was loading: on an Apple M3 Max under Wine with MoltenVK 1.4.3, four
copies of d3d12_compute at once failed 6 of 40 runs (PSO creation at lines 245/357, or
exit 3 from an uncaught filesystem_error in copy_file), while 125 runs one at a time all
passed.

test_temp_dir.h names the folder <temp>/<name>_<pid>, removes it on scope exit (early
returns included), and copies the compiled-in LEONIDA_TEST_*_SPV files with an error
code, so a missing file is reported by name instead of ending the test with abort().
docs/testing.md lists both symptoms.
2026-11-23 01:41:31 +04:00
654e666416 d3d12: D24 depth stored as D32 gets D24 depth bias and 24-bit depth in draws (D3D-309)
On a GPU without a D24 attachment (AMD) the layer stores D24_UNORM_S8_UINT as
D32_SFLOAT_S8_UINT. Draws then broke two D3D rules: the integer DepthBias was
scaled by the primitive's exponent instead of D24 units, and fragment depth was
not quantised like the clears, so an EQUAL test at a cleared value failed.

Single-sampled graphics pipelines with depth enabled on such a target now have
their pixel stage write FragDepth = quantise(z + D3D bias), with the bias in D24
units and the quantisation of depth24_convert.comp; the rasterizer's own bias is
off for them. A pipeline without a pixel shader, with or without a geometry
shader, gets a built-in one. d3d12_depth24_draw_test covers the finding's cases,
stored depth with constant and slope-scaled bias, a shader that writes depth, and
a VS + GS pipeline without a pixel shader.

Co-authored-by: UlteriorMotive00 <132296248+UlteriorMotive00@users.noreply.github.com>
2026-11-22 22:39:37 +01:00
77bb727419 loader: the thread handles of the TLS swap are closed on every way out
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:38:24 +00:00
dac96d2d65 DXGI: CreateSwapChainForHwnd checks MSAA, buffer count and format before the size, like the host
A description with width 16385 and MSAA 4, one buffer or a bad format is
DXGI_ERROR_INVALID_CALL on the host runtime's DXGI, not E_INVALIDARG
(found by Kam471 in the review of #3531). Five multi-fault cases added
to the side-by-side comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:37:10 +01:00
99fb9e372a TEST-837: Require fresh GPU test readbacks 2026-11-22 22:36:56 +01:00
b1fdafc2f3 loader: lookups take the range table's lock shared
Concurrent throws on different threads no longer queue on it; map_image
takes it exclusively for the one push.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:36:51 +00:00
a8773a46b1 Runtime: the single-list replay() gives overlapping queries segment pools (D3D-399)
With a `keep` vector and ReplayFunctions::create_segment_pool (plus the sum
helpers), replay() makes one occlusion and one pipeline-statistics segment pool
sized to the list, plans them as the batched path does and hands them to the
caller, instead of refusing a list whose queries overlap. Without them the list
is still refused. replay_query_predication_test case 14 checks both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:34:08 +03:00
d9b6883e1d d3d12_vulkan_device_test: print why a host comparison of a new format is skipped, and count the compared ones
Follow-up to #2438 from the review of pwu2775-dev. A failed host FORMAT_SUPPORT query was treated as 'no such texture' without saying so, and the summary printed '(host compared)' even when every comparison was skipped. The query's answer is now printed (E_FAIL on Windows 10 build 19045, E_INVALIDARG seen on another 19041 host, so a single code is not assumed) and the summary says how many formats were compared and how many the host lacks.
2026-11-22 22:33:00 +01:00
6c6843fced fix(runtime/test): warm up two CreateProcessW starts in queue_proxy_test handle check
On Windows 11 26200, check_child_runner() previously ran one successful
CreateProcessW and one failed CreateProcessW before recording handles_before.
However, NtQueryObject shows that the second successful CreateProcessW still
opens and caches one persistent HKCU registry key handle (\REGISTRY\USER\<SID>)
in the parent process before stabilizing at +0 handles on the third and later
calls. That caused `handles_after == handles_before` (e.g. 123 vs 124 under
ctest) to abort queue_proxy_test before testing WARP, hardware D3D12, or
Vulkan queue/fence proxies.

Warm up two successful `run_self(L"--child-flood 0", 30000)` starts before
recording `handles_before`, while keeping the strict `handles_after == handles_before`
handle-leak assertion intact.

AI-assisted with Argon (Antigravity).
2026-11-22 18:27:05 -03:00
9cae273a63 test(d3d12): compare POINT and LINEAR M2 draws against CPU pixels 2026-11-23 00:24:11 +03:00
f506039c95 perf(runtime): move a draw's views out of the command variant (D3D-391)
#2483 made the render targets and vertex buffers inline arrays in Draw. That is 704 of its
976 bytes, and a recorded command is sized by its variant's largest alternative, so every
command in a list, barriers included, took 984 bytes.

Draw now holds a shared_ptr to a DrawViews block that the D3D12 shim rebuilds only when the
render targets or the bound vertex buffers change, so a run of draws still allocates nothing
per draw. replay_cpu_bench: one recorded Command 984 -> 296 bytes; frame 3890 -> 3824 us,
within run-to-run noise; allocations per command unchanged.
2026-11-22 21:23:04 +00:00
3d48c4adb0 dxgi_device_test: the not-a-proxy fixture is pointer-sized
The helpers read a vtable pointer (8 bytes) from the object they are given;
the fixture was a 4-byte int, so they read past it. Found in review.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:22:18 +00:00
8e5b781d8a runtime/README.md: LEONIDA_CONTENT_PACKAGES, a path longer than 259 characters is ERROR_INSUFFICIENT_BUFFER
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:22:04 +00:00
48cee7c2c6 Queue holds: second review fixes (claim after submit, presenter locking and bound, teardown pump, tests)
- A Signal counts as submitted only after vkQueueSubmit succeeded: a failed submit releases no waiter and the retry goes through.
- ~VulkanQueue pumps after dropping held work; fence keep-alives are also drained in wait() and marker().
- VulkanPresenter: counters are atomics, read_back/enable_capture take the presenter mutex, set_abort has its own mutex,
  a deferred present reports not tearing, and at most 8 presents queue up before the caller waits.
- Tests: three presents (blit, blank, composed) queued behind held work run in order, a present behind a destroyed
  queue's held work runs, a failed Signal does not release its waiters; the handover modes also run on the host runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:20:36 +01:00
0f83451af9 gta6rt: the offline WinHTTP stub passes a handle's context value to its children
make_handle copied the parent's status callback and notification mask to
a new handle and left its context at 0. The host's winhttp.dll also
passes WINHTTP_OPTION_CONTEXT_VALUE on: a connection and a request start
with the context their parent has when they are made, WinHttpQueryOption
returns it and their HANDLE_CREATED and HANDLE_CLOSING callbacks carry
it. A context set on the handle itself, or given to WinHttpSendRequest,
still replaces it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 00:19:59 +03:00
75f1351a07 file_system_test: the MAXIMUM_ALLOWED write is shorter than the file
A two-byte write leaves the rest of the file to compare, so the test also shows the
overlay copy began as the package file's bytes (suggested in review).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:19:55 +00:00
a83d28fbdb Tests: the no-CRT fixtures link in Debug
dll_thread_calls and tiny_tls_cb_only link with /NODEFAULTLIB, but the Visual Studio generator's Debug config compiles with /RTC1,
whose checks reference _RTC_InitBase and _RTC_Shutdown: LNK1120 in Debug. Both fixtures define the two as no-ops when
__MSVC_RUNTIME_CHECKS is set. Release and RelWithDebInfo are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 22:19:14 +01:00
1fc162f4ba gameinput: track which kind of device the player used last
The shim tells the title every pad is an Xbox One pad, so nothing could
say what the player is really holding. rt::gameinput::active_input()
now returns the family of the device used last (Xbox, PlayStation 5,
PlayStation 4, PlayStation 3, Nintendo, or the keyboard pad), a
generation that counts changes, and whether LEONIDA_PROMPTS forced it.
It is groundwork for button prompts that follow the device in use.

Only deliberate input counts: a button going down, a trigger past 0.3
or a stick leaving a 0.35 radius. Held input, stick drift and noise do
not; a pad's first reading after it connects is its baseline; and
after a change the next one waits LEONIDA_PROMPTS_SWITCH_MS (300 ms).
The rules live in runtime/src/active_input.h with no SDL, tested by
active_input_test; gameinput_test drives them on SDL virtual pads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:17:56 +00:00
a41173a1ae Tests: gameinput_host fails instead of skipping when GameInput.dll is present (review)
- gameinput_host_test decides the skip before mapping: LoadLibraryExW of GameInput.dll from System32. Only "not found"
  skips (77); an import that then binds to nothing is a failure. Breaking host ordinal binding in Loader::resolve now
  fails the test (4 failures) instead of skipping.
- The gameinput_host fixture links in Debug: /RTC1 with /NODEFAULTLIB left _RTC_InitBase, _RTC_Shutdown and
  _RTC_CheckStackVars unresolved, so the fixture defines them as no-ops when runtime checks are on.
- The fixture reports E_FAIL, not S_OK, when GameInputCreate fails, and the test counts a gamepad as attached only when
  the library was created.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 22:15:41 +01:00
d5317f0149 d3d12: validate Device10 barrier layouts, clear values and placed/reserved descs 2026-11-22 23:13:58 +02:00
b37028eb9c runtime/README.md: document the five xgameruntime environment overrides, with a docs test
LEONIDA_DEVICE_TYPE, LEONIDA_ANALYTICS_FORM, LEONIDA_PACKAGE_ID,
LEONIDA_CONTENT_PACKAGES and LEONIDA_PACKAGED are read by
runtime/shims/xgameruntime.cpp and were named in no document, while the
README documents the runtime's other variables one by one.

Adds a table read from the code (default, accepted values, which call each
one changes) and tests/test_docs_env_vars.py: every LEONIDA_*/GTA6RT_*
variable that appears as a string literal in runtime/src, runtime/shims
or make_game.py is named in some tracked Markdown file, except the two the
runtime sets for itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:13:11 +00:00
389f949bc9 fix: share sparse D3D12 buffers across queue families and require sparse-capable queues 2026-11-22 16:13:00 -05:00
292c917822 loader: harden the TLS swap on running threads
- After writing a thread's slot, read its array pointer again and repeat on
  the new array if Windows replaced it; if the block is not in the current
  array after four attempts, take it back and log.
- Read and write another thread's TEB and TLS array inside __try, right
  after the thread was seen running, so a TEB freed by TerminateThread is a
  skipped thread.
- Bound the list of ended thread ids.

loader_tls_test: a thread terminated while it holds a block, and a load()
with a dead thread still open.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:12:56 +00:00
5edd926878 xgameruntime: serve XGameImpl (IXGameImpl3) offline through QueryApiImpl
IXGameImpl3 : IXGameImpl2 : IXGameImpl (xgameruntime include/xgame.idl), slots
3-5: XGameGetXboxTitleId gives MicrosoftGame.Config's <TitleId> (E_FAIL without
one, E_INVALIDARG for a null pointer), void XLaunchNewGame is logged and
returns, XLaunchRestartOnCrash succeeds with nothing registered. A retail Gen9
title asks QueryApiImpl for this class (Freminet/ScarlettX's observation).

The config reader is shared with XPackageGetUserLocale. The two tests that used
XGameImpl's id as their example of an unserved class now use XGameSaveImpl's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:10:59 +00:00
f74b8eb87e xgameruntime: read LEONIDA_GAME_DIR wide for MicrosoftGame.Config
GetEnvironmentVariableA narrowed a game folder named outside the ANSI code page
(e.g. a runic or CJK character on cp1252), so the package locale lookup missed
its MicrosoftGame.Config. Read the variable and open the file wide. The test
uses U+16A0, which no ANSI code page has (it fails with the narrow read).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:10:40 +00:00
f8fe26dd5d d3d12_vulkan_device_test: excuse only the measured Windows 10 pair
Review of the previous commit (@kacper-serewis): the ID3D12Device10
predicate excused any unequal answers for the seven cases on a Windows 10
host, where only one pair was measured. Each case is now marked
windows10_refuses, and windows10_refusal() excuses exactly the layer's
S_OK against the host's E_INVALIDARG on a host without ID3D12Device10.
Any other difference there, and any difference on a newer host, is a
mismatch again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:09:59 +00:00
mz
b40df7a58d RT-115: hold --run to the Windows sequence under Wine
run_tiny_atexit compared `gta6rt --run` with the native run. Under Wine the
native leg uses Wine's own CRT, which differs from Windows in two places
(it drops a handler registered while handlers run, and its _exit from a
second thread does not wait for the exit lock), so the test failed there
although --run gave the Windows sequence (reported on #2152).

--run is now held to the expected sequence directly. On Windows this is the
same check, since the native run must match that sequence too. With RUNNER
set (Wine), a native difference is reported without failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:09:55 +00:00
974da138db d3d12_xs: a device created as IDXGIDevice1 keeps the proxy as its identity and the layer's adapter
create_device_proxy returns the proxy's DXGI pointer when the title asks for
IDXGIDevice1. D3D12XboxCreateDevice passed that pointer to set_device_outer,
so the Vulkan device's outer identity was the DXGI pointer, and
set_device_adapter_provider, which knew only the primary vtable, set nothing:
GetAdapter then loaded the host's dxgi.dll and returned a host adapter.

set_device_outer resolves the proxy first (device_proxy_primary), and
set_device_adapter_provider takes either pointer, returns whether it set the
provider and says so on stderr when it did not.

dxgi_device_test creates the device as IDXGIDevice1 on WARP, a hardware
adapter and the Vulkan device. Found by @kacper-serewis in review.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:09:31 +00:00
467660963d d3d12: a placed resource reports its heap's flags as they are
d3d12_heap_properties_test compares what ID3D12Resource::GetHeapProperties
returns on the Vulkan-backed device and on the host runtime: the properties
and heap flags of committed resources in every heap type (custom ones and
SHARED, ALLOW_DISPLAY, CREATE_NOT_ZEROED, CREATE_NOT_RESIDENT included), of
placed resources in heaps of each kind, and of reserved resources, with null
arguments too, and whether each call wrote its outputs: 561 values. On main 4
differed (RTX 3060, driver 610.88), all the same rule: a placed resource
reports its heap's flags as they are, so one in an ALLOW_ALL heap reads back
0, while the layer added the DENY bits of the resource classes it isn't (0xC0
for a buffer, 0x44 for a texture). Those bits are the runtime's choice only for
a committed resource's implicit heap, where the layer already matched.

Builds on #2864, which adds the placed_ flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:06:27 +01:00
ceccc784f5 runtime: correct the comment above PipelineState::create_graphics
The comment said hull, domain and geometry stages, and more than one
sample, are refused. The code accepts both: a geometry shader is the
translator's Vulkan geometry stage (it needs the geometryShader feature and
a triangle topology type), and sample counts above one are accepted
(d3d12_geometry and d3d12_msaa_draw cover them).

Say what create_graphics refuses today, each checked against the code:

- hull, domain and stream output: E_NOTIMPL with a log;
- the centre multisample pattern (needs custom sample locations);
- two stages that both read their code base (still refused with
  E_NOTIMPL, "two stages read their code base");
- state that needs a Vulkan feature the device lacks.

Comment only, no behaviour change. Claimed in #3381.
Written with AI assistance (Claude, via OpenBot).
Tested on an RTX 4070 (NVIDIA 621.01, Windows 11, MSVC 14.44): the runtime
builds (431 targets) and ctest d3d12_draw, d3d12_msaa_draw, d3d12_geometry,
d3d12_translated_draw, d3d12_compute, d3d12_m4_compute and
d3d12_set0_compute pass 7/7, as on the base f847748c.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
2026-11-22 18:05:55 -03:00
a74e1dcbd1 runtime: keep /utf-8 out of the MASM rule (A4018 from ml64)
The directory also enables ASM_MASM for test/fixtures/abi_probe.asm, and
a plain add_compile_options(/utf-8) reaches ml64 too, which has no such
option: "MASM : warning A4018: invalid command-line option : /utf-8".
The option is now limited to C and C++ with $<COMPILE_LANGUAGE:C,CXX>
(@Hanioe2's review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:05:22 -06:00
3e70baa099 d3d12_residency_test: a child that can't run its step fails the test
From the review on #2864. The exit code a host-step child gives when it
couldn't run its step (kNoChild, 0xC41DFA11) fell into the crash-status mask
and counted as a host fault, so a broken child path would have left those
steps "not compared" and passed. It is now checked first and fails the test,
and the values left out may not exceed the 11 measured (the nine null-pointer
steps the host faults on and the backwards fence twice), so the comparison
can't go vacuous. The summary and docs now say 58 steps and 110 values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:04:47 +01:00
173ce07977 d3d12: residency calls answer as the host runtime does
d3d12_residency_test runs the same 110 MakeResident / Evict /
SetResidencyPriority / EnqueueMakeResident steps on the Vulkan-backed device
and on the host runtime, with a committed buffer, a heap, a placed buffer, a
descriptor heap, a query heap and a fence of each. It compares every HRESULT,
the device-removed reason after each step, and the value EnqueueMakeResident
leaves the fence at. Steps that leave the host runtime unusable run there in a
child process with a fresh device (--host-step). On main 7 steps differed (RTX
3060, driver 610.88); now none do:

- SetResidencyPriority takes a priority only for objects that own their
  memory, committed resources and heaps. A placed resource (a reserved one too,
  by the same rule; not measured), a descriptor heap, a query heap or a fence is E_INVALIDARG, also inside a
  longer list (the layer accepted all of them). The host also removes its
  device then (DXGI_ERROR_INVALID_CALL); the layer doesn't, since a title that
  sets priorities on placed resources would lose its device over a hint.
- EnqueueMakeResident accepts a null fence and signals nothing (the layer
  answered E_INVALIDARG).

Not compared: a nonzero count with a null array and a null entry in an array,
which the host dereferences; and a value below the fence's current one, which
moves the host's fence back but not the layer's (Vulkan timelines only go up,
already documented).

d3d12_vulkan_device_test's residency checks expected the old answers for a
fence and an allocator's priority and for a null fence, and now expect the
host's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:04:47 +01:00
f3442f6cbd loader: the address lookup reads its own table, not the module vector
lookup_in_loader walked Loader::modules() with no lock while map_image
appends to it under Loader::mutex_. The lookup runs on any thread: behind
the RtlPcToFileHeader redirect on every C++ throw from a mapped image, and
for trace and stop lines. A throw during another thread's run-time load
read a vector that was being reallocated.

find_address reads a table of (base, size, name) under a leaf lock;
map_image adds an entry once the image's memory exists.

loader_test: lookups from one thread while another loads 300 images. With
the old code it crashes under AddressSanitizer at the vector read.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 21:02:46 +00:00
61d8911cee d3d12: build against every Windows SDK 10.0.26100 d3d12.h (BUILD-970)
The README asks for "Windows SDK 10.0.26100 or newer", but the SDK's
d3d12.h changed within 10.0.26100: 10.0.26100.6584 ships
D3D12_SDK_VERSION 612, later builds 616. main used names from newer
headers, so it stopped compiling on the older 10.0.26100 builds:

- D3D12_FEATURE_D3D12_OPTIONS21 and its payload, with
  D3D12_WORK_GRAPHS_TIER_NOT_SUPPORTED and
  D3D12_EXECUTE_INDIRECT_TIER_1_0 (header 613);
- D3D12_INDIRECT_ARGUMENT_TYPE_INCREMENTING_CONSTANT (613);
- D3D12_FEATURE_D3D12_OPTIONS20 with D3D12_RECREATE_AT_TIER_NOT_SUPPORTED,
  and D3D12_FEATURE_PREDICATION (611).

They join the two feature values d3d12_feature_compat.h already declares
for the same reason: ABI values and payload structs in rt::d3d12::compat,
used by the device and its test. Where the header has the real
declarations, static_asserts check that the values, sizes and offsets
agree.

The runtime and every test now build against DirectX-Headers v1.610.2,
v1.611.0 and v1.613.0's d3d12.h (put ahead of the SDK's) and against the
SDK's own 616 header. Before this change, 611 failed with 18 errors and
610 with more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GN11jcpJWD4phrXJyDgED6
2026-11-22 21:02:24 +00:00
96830e58f2 dxgi: keep BufferCount at the app's request when Vulkan's native count differs (D3D-389)
Vulkan may return more images than minImageCount, and caps.minImageCount can exceed the requested count, but GetDesc/GetDesc1 must report the app's BufferCount and GetCurrentBackBufferIndex must stay inside it.

When the native count differs, expose a stable offscreen ring of exactly the requested size and blit the current slot into the acquired native image at present; direct native mapping is unchanged when the counts agree. Add a fake-Vulkan regression test (extra native images, min above request, request above min) and DXGI-level desc/index assertions.
2026-11-22 21:01:27 +00:00
3a1ed28beb Merge main into hw4-ps-formats (#3499)
docs/shader_validation.md

AI-assisted.
2026-11-22 22:01:03 +01:00
b6213c91dc xgameruntime_user: review fixes (unregister, IsStoreUser, slot 15, handles)
From @CharlyRien's review of 056661d:
- XUserUnregisterForChangeEvent returns true for every token: false means
  "still pending", which never happens offline, so a title polling with
  wait = false spun on an unknown or repeated token.
- XUserIsStoreUser is true, also for a null handle (_In_opt_; documented
  as always true on console).
- Slot 15 (no public signature) answers E_NOTIMPL instead of S_OK with
  nothing written. XUserIsSignOutPresent (47) stays 0: it is read as a
  bool, and E_NOTIMPL's low byte would mean true.
- Handles are validated by lookup in a live set rather than by reading a
  magic in memory that may already be freed; a double close is a no-op.
- LEONIDA_GAMERTAG of any length reaches the "longer than 15" message
  (the length is queried first; 64+ characters fell back silently).

Tests: 42 checks; a new ctest run with a 70-character gamertag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:59:07 +01:00
4f6b753693 xgameruntime_test: the IXSystemImpl5 check's flag no longer hides the entry-point check's (C4456)
93e65132 added the IXSystemImpl5 inheritance check with a `bool all`,
which hides the `bool all` of the GetProcAddress check at line 188;
MSVC reports C4456 at line 400. The inner flag is now all_inherited.
No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:58:05 -06:00
8e28bd70bf Merge main into gpu-far-branch (#2697)
docs/design.md
runtime/test/shaders/check.py
scripts/run_gpu_tests.py

AI-assisted.
2026-11-22 21:57:04 +01:00
c533c1d638 tests(runtime): cover 1.2 feature-bit rejection, enable flags, and 1.3 choose() 2026-11-22 17:56:12 -03:00
49ea89f201 file_system: CopyFile2 falls back to CopyFileExW where the host has none
The shim's CopyFile2 called ::CopyFile2 directly. Wine 9's kernel32 and
kernelbase don't export it, so Wine binds that import to a stub that
aborts the process: under Wine 9 (or a Proton built on it), a title that
calls CopyFile2 is killed. The file_system test shows it: it aborts at
its CopyFile2 check and runs into ctest's timeout.

The host's CopyFile2 is now looked up with GetProcAddress (kernelbase,
then kernel32) and used where it exists, so Windows behaves as before.
Where it doesn't, the copy goes through CopyFileExW: the flags both calls
define and the cancel flag are passed on, the CopyFile2-only hints are
dropped, and a COPYFILE2 progress routine is not called. pe_loader.cpp
and loader_tls_test.cpp already avoid CopyFile2 for the same reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GN11jcpJWD4phrXJyDgED6
2026-11-22 20:55:57 +00:00
66c53d04d9 RT-182: the BVH builder container created twice is GetBVHCompactedSize
bvh_builder_test measures 53 PSO creations over XboxBvhBuilder.dll's 52 containers.
With LEONIDA_BVH_RECORD62=1 the test now prints each container's ILDN module name and the
first bytes of its digest, which answers the open question in docs/embedded_shaders.md:
creations 1-51 are 51 distinct containers (GetBVHCompactedSize at 47), 52 is
CopyAndCompactBVH (0x1134 bytes) and 53 is GetBVHCompactedSize again (0x14a4 bytes, same
digest): the container FUN_18001d400 passes for "XDXR PostBuildInfoQuery".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:55:54 +01:00
dc6068cc68 rdna2spirv: BVH box test as measured on RDNA2: NaN planes skipped, near/far by direction sign (SHADER-650)
Native image_bvh_intersect_ray on an RX 6900 XT (gfx1030, tools/hw_oracle, 338 cases) picks each axis's near
and far plane by the sign of the inverse direction, takes the inverse direction as given (0 x inf is NaN),
reduces the three near and the three far t with NaN skipped (all-NaN is a miss), and sorts by max(tnear, 0)
through the network (0,2) (1,3) (0,1) (2,3) (1,2). A lone NaN bound leaves its plane open and an empty box
misses without a separate check, so #3373's empty-box test is folded into this rule.

The translator now matches all 338 measured cases (main 43). cs_bvh/cs_bvh32 and vk_compute_test expect the
scene's NaN box at t = 0, as native gfx1030 returns. tests/semantic/test_image_bvh_box_hw.py holds 241 of the
measured cases. docs/design.md Ray tracing row updated; the descriptor base is measured too.

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