vulkan_sampler() kept the S#'s address modes and filters when FORCE_UNNORMALIZED is set.
Vulkan requires unnormalizedCoordinates samplers to use CLAMP_TO_EDGE or CLAMP_TO_BORDER on U
and V (VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075) and equal min and mag filters
(-01072). WRAP is the S#'s default mode (word 0 = 0), so any S# with FORCE_UNNORMALIZED and
no explicit clamp produced an invalid VkSamplerCreateInfo.
U and V now clamp to the edge (a border mode stays the border); W is left as decoded; the
minification filter follows the magnification filter. gfx10_descriptors_test checks both cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The asynchronous block read `closing == 3` right after closing the
connection and the session. When the send's thread-pool callback still holds
the request's last reference, its release delivers the request's
HANDLE_CLOSING (waking the test) and only then drops the request's reference
on the connection, so the connection's and the session's notifications come
on that thread after the read: the check failed, and the late notifications
landed in the next block's count. A wait_for_closing() helper polls up to
two seconds, as the third block already did. The first two blocks now wait
for all three handles before the next block resets the counter.
Proven with temporary delays in the shim (not committed): the old test then
failed 10 of 10 with the reported failure, and the new one passed 20 of 20.
On the unchanged shim: 30 of 30 alone and 40 of 40 four at a time; full
ctest 123/123. Test-only, no runtime behaviour change.
The TEXTURE2D/TEXTURE2DARRAY/TEXTURE2DMS/TEXTURE2DMSARRAY and default
paths wrote a TargetView with the caller's mip and slice range without
any of the checks the render-target-view path makes: no mip or layer
bounds, no dimension or sample-count match, no ALLOW_DEPTH_STENCIL
requirement and no view-format legality. An invalid view was silently
recorded as valid.
Give every depth view the same checks: the resource must be a
depth-capable texture, the view dimension must match the texture's
dimension and sample count, the mip and layer range must fit inside it
and the view format must be a concrete depth format of the resource's
own family (D16/D32/D24S8/D32S8X24, or that depth format for the
matching typeless resource). A refused view writes a null TargetView.
Adds runtime/test/d3d12_dsv_test.cpp covering valid TEXTURE2D,
TEXTURE2DARRAY, TEXTURE2DMS, typeless and default views plus refused
out-of-bounds mip/slice, MSAA/non-MSAA mismatch, non-depth resource and
wrong-family format views.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The harness could only read the 0x280-byte synthetic bvh scene it builds itself. VKC_HEAP_FILE=<path>[@<offset>] copies a file into the heap, so a translated corpus shader can read a BVH, its descriptor blocks and the records from the user's work folder. Used to dispatch one of the game's RT compute shaders over a real GPU-built BLAS; the file is read at run time and never committed, so no game data enters the repository.
vk_sandbox draws the props around a point with one translated game VS/PS
pair chosen by signature and descriptor layout: a real camera through the
VS constants, DiffuseTex albedo through the bindless set and the PS's own
S#, depth, and a fly/walk/drive window. tools/sandbox.py packs the scene
(tools/sandbox_scene.py), picks the pair and runs it; --check prints
counts only. docs/sandbox.md has the table layout and the measurements.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY
Windows 10's D3D12 (no ID3D12Device10) still validates a buffer's initial
state and refuses a HARDWARE_PROTECTED heap, where newer runtimes and the
layer accept them. Seven cases compared those answers without a predicate,
so the test could not pass on a Windows 10 host:
committed: buffer in state 0x80000000
committed: buffer in RENDER_TARGET | UNORDERED_ACCESS state
heap: HARDWARE_PROTECTED
placed: upload buffer in COPY_DEST
placed: readback buffer in GENERIC_READ
placed: default buffer in state 0x80000000
reserved: buffer in state 0x80000000
They now carry the ID3D12Device10 predicate their neighbours already use,
and compare_heap_neighbours gains the same "not comparable on this host"
path as the other two comparisons. Hosts with ID3D12Device10 compare
exactly as before.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
writes() did not count MAXIMUM_ALLOWED as write access. CreateFileW/A and CreateFile2
then opened the package file itself, and a WriteFile through the handle changed the
package, which docs/runtime_imports.md says is never written. Such an open now gets
the overlay copy like any other write-open.
file_system_test: the three entry points, with the package bytes and the overlay
copy checked after a write; a plain read still makes no overlay copy.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sources are UTF-8, but 39 targets (the vk_* tools from the foreach,
the replay_* and small unit tests, xgameruntime_stub, ...) don't pass
/utf-8, so MSVC reads them in the system's ANSI code page. On code page
936 that is C4819 at vulkan_replay.h:1952 for every target that includes
it (@Hanioe2's finding). One add_compile_options(/utf-8) under if(MSVC)
covers them all, and targets added later; clang-cl accepts it too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The on-screen colour check ran whenever the test's window was the foreground window, but the foreground window
can still be covered at its centre (an always-on-top window, or one another process showed without taking the
foreground). GetPixel on the screen DC then returned that window's pixel and the test failed, although the
presented images had already been checked: 3 of 20 runs on the Radeon iGPU and 5 of 30 on the RTX 3070 with
another application in use.
A read now counts only when WindowFromPoint at the centre, taken to its root window, is the test's window before
and after the read; otherwise the check is skipped with a line saying the centre is covered, like the existing
"not in front", HDR and CLR_INVALID skips. A pixel that is not the clear colour is read again every 50 ms for up
to a second before the EXPECT, since how long the compositor takes to show the last frame is not known; nothing is
presented meanwhile, so a wrong colour that stays still fails. A click-through layered overlay is not seen by
WindowFromPoint and still fails the check; the comment says so.
docs/d3d12_vulkan.md: the sentence on the check names the new condition.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
vk_harness takes VKH_COLOR_FORMAT=<VkFormat>:<bytes> for its color target
and writes the target's texels as stored. ps_oracle.py --format picks it
(the driver then picks the export format, as for a game pipeline), with
an integer-output const template for integer targets. docs gets the
export behaviour measured on gfx1036: 32_GR / 32_R take the last enabled
channels, a compr export reaches 16-bit UNORM/SNORM/UINT/SINT targets bit
for bit, FP16 targets get the halves as f16 (a NaN half becomes 0xfe00).
AI-assisted.
load() installed the image's TLS block on its caller, and the helper DLL's
DLL_THREAD_ATTACH covers threads started later. A thread that was already
running kept the helper's one-byte block in the reserved slot, so mapped
__declspec(thread) code on it read and wrote past it. The process thread
pool's workers are such threads, and the task queue runs a title's
callbacks on them.
load() now gives every other running thread its own copy of the template
through that thread's TEB, as Windows does for a DLL it loads itself: a
block, no DLL_THREAD_ATTACH. The block comes out in the thread's own
DLL_THREAD_DETACH (after the module's TLS callbacks) or in ~Loader.
loader_tls_test: a thread and a pool worker that exist before load(),
across two mappings of the fixture.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A GDKX title asks its device for IDXGIDevice1, then GetAdapter and
EnumOutputs(0), to find the output it gives SetFrameIntervalX. The proxy
refused the QueryInterface, and a PC ID3D12Device has no IDXGIDevice to
forward to.
The proxy now answers IDXGIObject, IDXGIDevice and IDXGIDevice1 as one COM
object with the device (a second vtable pointer in the proxy, same reference
count and QueryInterface). GetAdapter and GetParent return the adapter of the
device behind it: the host DXGI adapter with the device's LUID on the host
backend, the layer's own rt::dxgi adapter on the Vulkan device
(set_device_outer installs that provider).
dxgi_device_test walks it on WARP, the first hardware adapter and the Vulkan
device.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- replay_cpu_bench: Draw::vertex_buffers is a fixed array by input slot since D3D-289; set slots 0 and 1.
- test_shader_checks: TOTAL counts the standalone cs_fmt_d16_xyz / cs_heap_init dumps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DeviceState::allocate takes the next memory type when device-local memory is
full, so on a 4 GB GPU a texture could land in system memory without a word.
leonida::spilled_to_host (vulkan_memory.h) says when that happened: the
allocation preferred DEVICE_LOCAL, needed no host access, and got a type
without it. The arena and upload heaps in system memory without Resizable BAR
are the memory type policy and are not reported. The first spill is logged
once, with its size, memory type and heap. Part of #2375.
# Conflicts:
# runtime/shims/d3d12_vulkan_device.cpp
Measured on RTX 5070 / 621.14: bitblt effects, window-incompatible
scaling and alpha modes, flags outside 0x2/0x20/0x40/0x800/0x1000/0x2000,
shared/read-only/discard-on-present/UAV usage, a null or non-queue
device, null window/description/output are DXGI_ERROR_INVALID_CALL; a
side above 16384 is E_INVALIDARG. dxgi_swapchain_test compares 40
descriptions with the host. The CoreWindow path keeps its old checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Vulkan device parsed a root signature's static samplers and dropped them,
so a shader holding one's S# by value missed in the hash table and sampled
through the fallback sampler. Each one now gets a sampler in set 0 and a key in
the hash table at root-signature creation, encoded as CreateSampler2 encodes
the same description (1.0, 1.1 and 1.2 blobs, the static border-colour enum,
the 1.2 flags).
d3d12_descriptor_test checks the key before and after for four root
signatures and samples with three of them on the GPU. docs/d3d12_vulkan.md no
longer says both that they are registered and that they are not.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tiny_frame imports d3d12_xs.dll!D3D12XboxCreateDevice from a link-time stub
and does the least a title does before its first frame: queue, allocator,
list, fence, an RTV heap with its start handle read in the console shape, a
committed target, a clear, a copy to a readback buffer, a fence wait, and a
check of every pixel. It returns from main with the device still alive.
run_tiny_frame runs it under gta6rt --run --trace-d3d12 with
LEONIDA_D3D12=vulkan; check_tiny_frame.py checks the verdict, the shim
binding and the call order, and exits 77 when d3d12_com_test, its probe,
finds no usable Vulkan device. tests/test_check_tiny_frame.py covers the
checker on synthetic output.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Conflicts in docs/design.md (main's Buffer format stores row kept, the "and the formats of the
Typed buffer formats row" suffix and the Typed buffer formats row added once) and
tests/test_shader_checks.py: TOTAL counts main's 12 fixtures (three mesh, ps_tex, ps_imgatomic, five
compute, ps_ssharp, vs_base_ids) plus cs_fmt_all, so + 13.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review (@Flyander):
- slot 7 is void XPackageGetInstallationProgress(monitor,
XPackageInstallationProgress*): it now writes an installed, launchable,
completed package instead of an HRESULT stub ignoring its output.
- slots 8, 10, 22, 34 are bool methods (UpdateInstallationMonitor, the two
Unregister* calls, UninstallPackage); E_NOTIMPL read as true. They return
false / true / true / false, as documented for nothing to do offline.
- XPackageGetUserLocale returns the package-declared locale closest to the
user's (MicrosoftGame.Config <Resource Language>, from LEONIDA_GAME_DIR or
--game-dir), never the host locale; with none declared it succeeds
without writing, as Microsoft documents.
- QueryInterface answers IXPackageImpl and IXPackageImpl2 too (the IDL
chain IXPackageImpl3 : IXPackageImpl2 : IXPackageImpl).
And @Ingenioeren's finding: XPackageGetMountPath uses gta6rt's --game-dir
(rt::fs::game_dir()) after LEONIDA_GAME_DIR, before the launcher folder.
xgameruntime_test links file_system.cpp; +6 checks (88).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows 10's host runtime (19045) creates a list of type -1 that Windows
11's refuses with E_INVALIDARG (@MeNoSkills on #2297, RTX 4070 Ti and a
Radeon iGPU). The case now carries the file's +device10 predicate, as the
other answers newer runtimes changed do: on a host without ID3D12Device10
it is printed as not comparable instead of failing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured against the host D3D12 runtime (RTX 5070, driver 621.14) with
d3d12_vulkan_device_test's compare_invalid_arguments:
- CreateCommandAllocator and CreateCommandList1 took any type (7, 99,
-1); the host refuses types past VIDEO_ENCODE with E_INVALIDARG.
- CreateCommandList and CreateCommandList1 took a node mask with bits
past node 0; the host answers E_INVALIDARG.
- A null output was E_POINTER in all three; the host answers
E_UNEXPECTED, after the argument checks.
compare_invalid_arguments gets 35 "command allocator:", "command list:"
and "command list1:" cases. Video list types are not compared: the host
hands out a video list (E_NOINTERFACE for ID3D12GraphicsCommandList),
while this layer creates a graphics list for them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GDK title links the XUser* functions statically (xgameruntime.lib); each
thunk asks QueryApiImpl for XUserImpl and calls one slot with the function's
arguments after `this` (docs/runtime_imports.md). QueryApiImpl refused the
class, so XUserAddAsync, the call a title makes at boot before nearly
anything else, could not succeed.
runtime/shims/xgameruntime_user.cpp serves it, in its own file so the other
class PRs touching xgameruntime.cpp only meet it at one line:
- ids and slot order from xgameruntime-docs (facts only), signatures, enum
values and E_GAMEUSER_* codes from the public GDK reference;
- IXUserImpl..IXUserImpl6 answer with one 50-slot vtable, IXUserGamertagImpl
(XUserGetGamertag) with a second;
- one offline user, always signed in: XUserAddAsync (silent or not;
AllowGuests with AddDefaultUserSilently is E_INVALIDARG), fixed ids,
FindUserById/ByLocalId, Duplicate/Close/Compare, not a guest, adult, every
privilege, ResolvePrivilegeWithUi, AddByIdWithUi, IsStoreUser, change-event
tokens; gamertag from LEONIDA_GAMERTAG, "Player" otherwise;
- tokens, gamer picture, MSA tokens and resolve-issue fail synchronously
before starting; no sign-out deferral; private and PC-only slots log once.
xgameruntime_user_test (40 checks) drives every served slot; a second ctest
run checks LEONIDA_GAMERTAG.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mapped EXE registered atexit handlers and static destructors with the
host CRT's process-wide table, which gta6rt never runs, so they were lost.
They now go to a table of the run's own: exit() and a return from main run
it newest first (including handlers registered during exit), _cexit() runs
it and returns, and _exit/_Exit/quick_exit/ExitProcess/abort skip it, as
natively. exit/_exit/_Exit/quick_exit share an exit lock like the CRT's,
each run starts with an empty table, and a failed registration returns an
error instead of throwing into the game.
New run_tiny_atexit compares a stand-in program run natively and through
--run for 8 termination paths. Not covered yet: at_quick_exit and the
thread_local destructor callback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libHttpClient.GDK.dll asks QueryApiImpl for XPackageImpl with IXPackageImpl3's
id through 30 thunks (slots 3-19, 22, 24-27, 30, 32-34, 37-40), each in
the argument shape of the method at that position of xgameruntime-docs'
IXPackageImpl (3-34), IXPackageImpl2 (35-38) and IXPackageImpl3 (39-40)
lists, e.g. 10 (monitor, token, bool), 14 (id, count, selectors), 24-26
the mount path trio, 39 (kind, scope, context, callback).
Slots with an offline answer forward to the XPackage functions already
on main, so the vtable and the named exports agree: 3 the package
identifier, 4 packaged process, 25 the mount path; plus 11 the host user's
locale, 24 the mount path size (exactly what 25 needs) and 26 closing a
mount (nothing to release). Every other slot logs its number once and
returns E_NOTIMPL, so the first boot lists what the title needs.
xgameruntime_test +6 (80): the IXPackageImpl3 id, 3 and 4 equal the
exports, the locale and its short-buffer error, 24/25 sizes, 5/40 stubs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/gameinput.md says that without the SDL3 shim the loader binds
GameInputCreate to the host's GameInput.dll, but nothing tested it.
gameinput_host_test maps a CRT-free fixture DLL built against the SDK's
gameinput.lib and checks that the import binds to the host copy (the test links
no shim table), that GameInputCreate and GetCurrentTimestamp work from mapped
code, that GetCurrentReading answers, and, with a pad attached, that
GetGamepadState succeeds. It skips (77) where there is no GameInput.dll, and is
only built when gameinput.lib is found.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
xmem.cpp ignores the attributes argument, and the bits of the Scarlett
XALLOC_ATTRIBUTES word are not known yet. With gta6rt --trace FILE, the first
XMemAlloc and the first XMemFree for each distinct raw attribute word now
write an "xmem_attributes" event (api, the word, the size for an allocation,
the caller as module+RVA), so the bits can be decoded from a real run without
logging every allocation. Off: one relaxed load per call.
xmem_test opens a trace and checks one event per word and API, the size of the
first call, a caller on every event, and nothing recorded while the trace is
off. README.md documents the event.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The 64-bit fold itself landed with #1948. This adds what #1938 still carries:
two semantic tests (a constant sOFF of -4 is out of bounds, not a 32-bit
wrap; a constant sOFF of 2^20 is not sign-extended) and the GPU fixture
cs_smem_sconst_off. Its run-time sOFF is now in range (4): an out-of-range
run-time sOFF made llvmpipe do the guarded load and segfault (review on
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>