* GPU: the depth bounds test reaches the host
Keep the kind-21 enable flag in the graphics state and pipeline cache
key. Use DEPTH_STENCIL1 for vertex and mesh streams that request the
test when the host supports it. Unsupported hosts fall back to the
plain depth-stencil state and warn once.
Forward the title's depth bounds to the host command list and replay
them when binding a graphics pipeline, including after the indirect
clamp. New and reset lists start with D3D12's 0..1 default.
Synthetic title draws and mesh dispatches on an RTX 5070 and WARP
kept excluded pixels at the cleared depth of 0.5 and wrote 0.25 to
included pixels. Fresh and reset lists also wrote 0.25. A forced
unsupported run drew all pixels, and the stream reader regression
failed with the upstream reader. Since the rebase onto 940d32f the
vertex stream also carries the rectangle lists' geometry shader and
both streams the topology type; only the draw ran again, on WARP.
The console subobject layout and call signature still need title-side
verification.
* GPU tests: drop the depth bounds mesh test that starts dxc
The triage on #158 asks for a maintainer's sign-off on new code that
starts an external process; the only such code was the mesh-dispatch
test, which ran dxc from VICTORY_PC_DXC and was skipped without it.
The stream-level test and the vertex draw test stay; the mesh path of
the shared stream builder is no longer exercised on a GPU here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: r4. <192970269+r4tedx@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A shader resource view of no resource is an ordinary view, and draw.rs
`readable` hands its null pointer to `alias_source`, which read the
resource's description through it: an access violation at the world's
start (run fps0, frame 1916, victory.exe in alias_source). The helpers
beside it (`host_resource`, `made_copy`) already answer None for null.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lower::memory previously computed the dirty bitmap bit for the last byte of a write by adding 32-bit wrapped page deltas to the first page's level-2 entry. Writes straddling a 4 GiB boundary wrapped the 32-bit addition to ~512 MiB out-of-bounds in the dirty bitmap UAV, and writes crossing a 256 MiB boundary overflowed the 12-bit page index into the wrong or out-of-bounds level-2 block. Guard the second bitmap update on non-missed 64 KiB page crossings and resolve the end address with 64-bit addition through the page table.
* GPU: no typed unordered view in a format the host cannot store to
fits() asked the host whether it stores to a typed unordered view's
format only for views cast to another family. A view in the texture's
own format went to CreateUnorderedAccessView unchecked, and on an NVIDIA
card (Windows 10) the title's B5G5R5A1_UNORM unordered views, which that
card does not take, removed the device with DXGI_ERROR_INVALID_CALL
during loading (the debug layer: "The format (0x56, B5G5R5A1_UNORM)
cannot be used with a Typed Unordered Access View", then RemoveDevice).
Every typed unordered view is now checked: one the host cannot store to
is not made, as other views the host does not allow, and its slot stays
null.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018sSQTeDQ6Kc6DEkgPbAww8
* GPU: the store check looks at the format the unordered view is made in
Review of #2462: for a view of a typed texture in another format of its
family that is not castable, fits() makes the view in the texture's own
format, but the store check looked at the requested one. It now checks
the format the view is made in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* GPU: a page whose alias cannot be guarded stays changed
guard_aliases ignored what protect returned. While a write the guards
do not see (watch::writing: a kernel read, a DirectStorage write) is
under way through one mapping of a physical page, that mapping stays
open; taking the page through another mapping still guarded it there,
dropped it from the changed pages and dropped the bytes saved of it.
Writes through the open mapping then went unseen by the copy, and when
the write ended (changed without saving) an armed page was left
changed with nothing saved, so copy_back_marked dropped the shaders'
writes to it.
watch.rs: "taking a page guards every address showing it", and "a page
that is mapped but cannot be guarded is left out (it stays changed)".
guard_aliases now returns the pages with a mapping it could not guard;
take and taken leave those changed. title_memory_aliased marks the page
changed when the new mapping of a guarded page cannot be guarded.
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* GPU: a new mapping that cannot be guarded marks its page changed without saving
Its bytes may already hold the write under way through it; saved as the
page's old bytes, they would be taken for the GPU's at a marked
copy-back (review by fyernald).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
D3D12 accepts a null description and initializes BufferLocation=0,
SizeInBytes=0. create_cbv returned early instead, so a later null call
left the previous View (and mirrored host slot) active. Record
Constant(0, 0) so the slot is cleared; host mirroring already nulls
Constant views via null_buffer_view.
Fixes VIC-BT-016 in #1242.
The title's pixel ordered-section (POPS) wait loop computes:
s2 = bfe(s_pops, 0, 10) ; collision wave id
s5 = bfe(s_pops, 16, 10) ; this wave id
s4 = ~s2
s5 = s5 + s4
...
s_cbranch_vccnz label_body
label_wait:
s0 = src_pops_exiting_wave_id + s4
s_cmp_lt_u32 s5, s0
s_cbranch_scc0 label_wait
Seeding the POPS hardware SGPR with 0 gives wave_id == collision_id == 0,
making s5 = 0 + ~0 = 0xffff_ffff so s5 <u s0 can never hold for any u32
exiting wave id. While active lanes skip the loop on overlap == 0, any
inactive lane (where EXEC is clear at s_cbranch_vccnz) falls through and
spins to LOOP_LIMIT (1 << 20 iterations).
Seeding 1 << 16 (overlap = 0, wave_id = 1, collision_id = 0) satisfies the
hardware invariant wave_id != collision_id so s5 = 0 and s0 = 0xffff_ffff
with src_pops_exiting_wave_id = 0, exiting immediately on the first check.
Add a WARP draw test reproducing the 1 << 20 spin and verifying it drops
to a single pass.
* GPU: a partial refresh of an armed page updates the bytes saved of it
Since cd94d35, a page armed for marked writes keeps its bytes from before
the title's first write (Tracked::saved), and copy_back_marked takes what
differs from them for the shaders'. A refresh of only part of that page
in the same submission (under or beside a range shaders write) leaves the
page changed and its saved bytes as they were, while the copy now holds
the title's newer bytes there. Copy-back then took the refreshed bytes for
the GPU's, putting them back over later title writes, and missed shader
writes back to the saved value.
Shadow::copy now hands what it copied to Tracked::refreshed, which updates
the saved bytes of the pages it covers, as update_busy does for the
snapshots of unmarked ranges.
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* GPU: the saved bytes of an armed page are the copy's from before the submission
Docs of Saved and Tracked::saved: refreshes lay what the copy takes over
the bytes saved at the title's first write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A pixel program with no color output ends with `exp null done vm`. When its
last loop leaves through the usual exit test on its own exit mask
(`s_andn2 X, X, exec`, then the SCC branch), structurisation took that test
for a discard's "no live lane is left" exit: the back edge became always
taken, the lanes that were done were discarded instead of leaving, and every
lane ran the loop to the loop limit (2^20 iterations). On an RTX 5090 each
such draw (a small box, 36 indices) took 203 ms.
A discard's exit ends the program with no lane live. An end that first gives
EXEC a saved mask other than the discard's live mask exports those lanes as
valid: a normal end. Such a block is no longer a kill exit.
Co-authored-by: wrothgaril <211408787+wrothgaril@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The stream is a byte slice that need not be 8-aligned; the reference made
over it was undefined behaviour and a panic in checked builds.
Co-authored-by: denkencar-sketch <224703622+denkencar-sketch@users.noreply.github.com>
shared_texture() asks GetResourceAllocationInfo for the size it saves, with
the title's description. That description may ask for uses its format does
not take on the host: on NVIDIA, unordered access on B5G5R5A1_UNORM. The
query rejects it, and the device is removed (DXGI_ERROR_INVALID_CALL) a few
seconds into the title on every NVIDIA card.
Ask it of the live texture the description is shared with, as
HostTexture::new does: a description the host made the texture from.
Co-authored-by: Bullet18x <344699838+Bullet18x@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
changed_here opened the guarded pages and then saved their bytes for armed trackers, and changed opened the faulting range before the pages that alias it. A write by another thread landing in between went unfaulted, and the save then kept the new bytes as the old ones, so copy_back_marked saw no difference and the write was overwritten. Marks and saves of the range and its aliases now come first, and the pages are opened after. Not covered by a test: it is a race between two threads.
Co-authored-by: denkencar-sketch <224703622+denkencar-sketch@users.noreply.github.com>
Heap::drop removed the heap from SHADER_HEAPS but left its page table in memory::SHARED. The table (a 16.8 MiB mapping) and the copies it names then lived on, and a heap made later at the same address found the stale table: Shared::host is the address of the HostHeap inside the Heap, which is the heap's address plus a constant, so it cannot tell the two heaps apart.
Co-authored-by: denkencar-sketch <224703622+denkencar-sketch@users.noreply.github.com>
A load still took the library's lock to clone the interface, and a save
holds that lock while it serialises the whole library (230-600 MB in the
world, #1683, #1653). Saves run every 20 s while pipelines are being
made, some on the pipeline workers themselves, so every load waited out
each save: the part of #1615 that #1000 left.
The library is kept a second time beside its lock, and loads use that
one without locking. A load adds nothing to the library, so the size a
save asks for still holds when it serialises; the library is
free-threaded but for loads of one name, which NAMES keeps apart. Stores
and saves keep the lock.
New test: a stored pipeline loads while the lock is held as a save holds
it. With the old locking it times out.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A marked UAV view shorter than 64 KiB, or not page-aligned, refreshed only
its own range, and Shadow::update split tracked refreshes at the ranges
earlier lists' shaders write. Either way Tracked::take saw only part of
the enclosing 64 KiB page, so the page was neither guarded nor taken: it
stayed changed, and copy_back_marked kept the title's bytes, dropping
every GPU write to the page.
Marked UAV refreshes (table views, root UAVs, heap hulls) now widen to
the 64 KiB pages they touch, cut to the copy (Shadow::page_range); the
range declared as written stays exact. Tracked copies take the refreshed
range in one call, still updating the snapshots under ranges shaders
write. Only pages the title changed are copied, and no shader of the
submission has run yet, so the wider refresh overwrites no GPU writes.
Each writable depth twin made a scratch buffer of its planes' size for
its copies and held it as long as the twin: about 325 MB of video memory
for Grand Theft Auto VI's 315 twins in the menu. The twins now take one
shared buffer per power-of-two size, at most twice the largest in all.
Every copy through a scratch buffer starts in the common state and
returns it there, so copies in one list are ordered by those transitions,
and lists run one after another on the host's single queue.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
State::bind sets the view-mark table SRV and written-pages bitmap UAV root descriptors before iterating over pipeline stages. When a compute shader reads a 16-bit depth texture whose writable twin is newer, State::tables transitions the texture through Twin::copy's compute converter, replacing the command list's compute root signature and setting need_rebind.
The subsequent take_rebind block restored SetComputeRootSignature(&p.root) and SetPipelineState(&p.pso), invalidating all previously bound compute root parameters while only per-stage root arguments were set afterward, leaving VIEW_MARKS and VIEW_WRITES unbound for the dispatch.
Rebind the compute view-mark SRV and UAV root descriptors immediately after restoring the compute root signature on rebind.
Tracer::sum treated dword 0 of every root parameter as a base address,
which made dword 0 of RootType::Constants behave unlike dwords 1 and up:
passing it as an SMEM soffset or global vaddr failed with "an offset from
a root parameter", and adding it to a descriptor table or root descriptor
base dropped the base because both terms carried one.
Exclude RootType::Constants from the dword-0 base arm so all root-constant
dwords trace as dynamic terms, while 64-bit pointers passed in root
constants still classify as title memory through why_no_base.
* GPU: ranges shaders may write are armed as runs of pages, not page by page
A range declared as written through views whose writes shaders mark is
armed, so that the title's first write to one of its pages keeps the
page's bytes from before. Arming put every page of the range into a
set: a root view declares its copy from its address to the end, so each
declaration on the world's 174 MB heap cost up to 2,784 set entries,
31-36 microseconds in a synthetic measurement, however many
declarations before it had armed the same pages.
The armed pages are now kept as the runs declared, none inside another,
with the single pages a copy-back takes out of them kept apart until
the tracker is disarmed. Which pages are armed is the same as before.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* GPU: armed runs stay sorted and apart, merging those that meet
Runs armed end to end or overlapping (descriptor tables' UAV sub-ranges)
each stayed a run of their own, so arming was quadratic in them and the
write handler's check of a page, under the guards' lock, scanned them
all. Arming now merges every run it overlaps or touches, and a page's
check is a binary search. Reported by nathanbzrr on #2147.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: r4. <192970269+r4tedx@users.noreply.github.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: r4tedx <r4tedx@users.noreply.github.com>
* Shaders: a program's constant table starts after its instructions
The table code_dword reads was the program's code from the lowest offset
any load or descriptor names, and a load at a computed offset names
offset 0: the table was the whole program, up to 64 KiB. Under
vkd3d-proton that constant array becomes a private one, which NVIDIA's
Vulkan driver keeps in every thread's local memory, and the driver
reserves that per thread for the whole GPU: one 57 KiB table made it
reserve GBs of video memory.
The program's constants follow its instructions, and a load at a
computed offset reads them, so the table now starts where the
instructions end, unless a load at a fixed offset reads below that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Shaders: code_table_start's comment says only what it does
As suggested in the triage: the vkd3d-proton/NVIDIA background stays in
the pull request's description.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Pass scope == PASSWORD into the host text-entry dialog and add ES_PASSWORD to its edit control style so password prompts do not display typed characters in clear text.
`Lower::live_edges` walks every phi a lane reads back through its
incoming edges, carrying the last few branch conditions known along the
path. Each step allocated a `Vec` for those conditions (cloned for every
edge and for the seen list) and asked the lane-condition diagram whether
some lane meets them, though paths into one join ask again for the same
sets: on a synthetic program of 256 blocks, 4,915 work items asked 3,047
times for 883 distinct sets.
The conditions (at most four) are now a small `Copy` value, and whether a
set is met is kept per set for the walk. The walk and its answers are
unchanged.
Measured with synthetic wave32 compute programs (divergent ifs, uniform
loops, gathers) through range::build, resource::track, io::raise and
emit_with, release build, two rounds each:
- emit_with: 4.67-4.74 ms -> 4.15-4.27 ms (256 blocks), 1.28-1.31 ->
1.19-1.21 ms (64 blocks), 3.50-3.52 -> 3.26-3.30 ms (512 small
blocks); allocations in emit_with down about 40%.
- The DXIL is byte-identical for every program (FNV hash of the output).
On a miss, `shader_cache::cached` had the cache write the new entry and
then read and decoded that file to return it. The first read of a file
just written is slow where a virus scanner looks at new files: measured
here (Windows Defender on) at about 0.5 ms for an 8 KB entry and 3.3 ms
for 60 KB, against 70-85 us for a later read, which is on the order of
a 1-12 ms translation. `translate --cache` misses on every container the
first time (some 25,000), and a run misses on every shader not cached.
The converter now keeps the translation it encoded, and a miss returns
it; entries are read only on hits. A translation whose entry could not
be written is returned as made too, where it was translated a second
time before.
The new test makes the cache folder unusable and checks the translation
is made once (twice before).
From a checkout about 170 characters deep, blake3's build script fails in
ml64.exe with "A1009: line too long" even with long paths enabled, because
its object files are written under target; a short CARGO_TARGET_DIR avoids
it (measured in #2029: 150 characters built, 170 failed, a 33-character
CARGO_TARGET_DIR built). The note also says where victory.exe lands then,
since the commands below name target\release.
Fixes#2029
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Loader: append crash reports as single records
AI-assisted (OpenAI Codex).
* Loader: the crash-record test sits below the test module's imports
Placement only, as the triage on #2033 noted; the test is unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: BaggyALPHA <257889696+BaggyALPHA@users.noreply.github.com>
Co-authored-by: BaggyALPHA <col.chipmunk@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* GPU: heap samplers keep point mips when anisotropic, as static samplers do
A sampler the title makes in a descriptor heap from the console's
description (`CreateSamplerX`, `sampler::console`) became D3D12's plain
anisotropic filter (0x55) whenever its magnification or minification was
anisotropic, whatever its mip filter: an anisotropic sampler with point
mips blended between mip levels on the host. Static samplers in shader
code keep point mips since #1337 (`StaticSampler::filter_for_host`), on
hosts with anisotropic point-mip filtering (`D3D12_OPTIONS19`).
Heap samplers now do the same: 0x54 (with the comparison and min/max
reduction bits) where the console asks for point mips, or none, and the
host has the feature; linear mips (0x55) otherwise, as before. The
feature is asked once (`sampler::aniso_point_mip`), and pipeline
creation uses the same answer instead of asking per pipeline.
Tests: `anisotropic_samplers_keep_point_mips_where_the_host_can` checks
the filter for point, linear and no mips with and without the feature,
and with comparison and maximum reduction (on main the point-mip case
gives 0x55); `the_host_takes_its_anisotropic_samplers` makes such a
sampler in a sampler heap on the host device and checks the device is
not removed (an RTX 5070 Ti reports the feature, so it takes 0x54).
* GPU tests: minimum-reduction anisotropic samplers, and whether a sampler was made
Review (#2031): the mapping test now also checks minimum reduction (0x154
with point-mip support, 0x155 without) and maximum reduction without it
(0x1d5). The device test prints whether it made its sampler (and with
which filter) or skipped for want of a device, so a green run shows
which it was.
The library is serialised into one buffer of its whole size, allocated infallibly. On NVIDIA the library holds each pipeline's machine code, about 1.7 GB after translate --cache --pipelines, and a save in the world aborted the process: 'memory allocation of 2650101862 bytes failed' (RTX 4050 Laptop, 32 GB). The buffer is now reserved fallibly; without memory the save is left for later (the pipelines stay counted as added).
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* GPU: composite multiple PresentX planes (fixes Series S black UI/menus)
* Serialize the PresentX compositor root signature explicitly
* Exercise PresentX pipeline creation with the installed shader compiler
* Initialize the PresentX compositor before opening the copy list
* Test PresentX recovery after compositor initialization fails
* GPU tests: verify composited pixels after present initialization recovers
* GPU tests: inspect composed pixels before flip-discard Present
* Update queue.rs
* Update queue.rs
* GPU: a failed compositor still presents the first plane
When the multi-plane compositor cannot be created, the frame was dropped
(`return None`). Show plane 0 through the single-plane copy path instead,
and keep retrying the compositor on the next present. The test now asserts
that the failing frame is presented, not skipped.
* GPU: present the primary plane when compositor setup fails
(cherry picked from commit 5a1b9ad5ae79f1e7b0bb6e29ea89af928d43e6bf)
* GPU: restore each presented host texture state once
(cherry picked from commit 660568e673b20f333bc9c8c2d37267190b3b1093)
* GPU: keep the composed plane list's host textures owned
The ported fix in the previous commit was written against a `host_resource`
that lent its host texture; on `main` it returns a clone, so the composed
list cannot hold `&ID3D12Resource` across the `host.present` call. Hold the
clones and lend them to `present`; the per-texture state bookkeeping is
unchanged.
---------
Co-authored-by: Yaekai <21324379+Yaekai@users.noreply.github.com>
Co-authored-by: swarm <swarm@swarm.swarm>
Co-authored-by: Blitz Studios <271002048+jamesn-xt@users.noreply.github.com>
Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>
`victory inspect` named six of the optional header's DllCharacteristics
bits and dropped the rest without a trace. The title executable of
Series 1.0.2.1 carries 0x8160, so its line read
"0x8160 (high-entropy-va, dynamic-base, nx)": the terminal-server-aware
bit (0x8000) was missing from the names while present in the number.
Name the remaining documented bits (no-isolation, no-seh, no-bind,
wdm-driver, terminal-server-aware) and show any bit still without a name
(the reserved ones) in hex instead of dropping it. The new constants sit
with the others in victory-pe's layout::dll_flags.
* GPU: view addresses for tables made afresh (dynamic slots)
A table reaching past a host view heap smaller than the title's (NVIDIA: 1,000,000 slots) is made afresh in dynamic slots, and the shader gets that table's offset. A shader reading a view's address as data (e.g. the BVH builder's base) indexes the view addresses at the table's slots: past the buffer, which had an entry per title slot only, through a root view without bounds, and with no address entered there. The view addresses now have an entry per title and dynamic slot, entered whenever a dynamic slot is made: a view's address, zeros for a null view and for the raw views of ours that root views and host copies' view pairs put in dynamic slots, so no entry of an earlier table stays.
* GPU tests: a table made afresh has its view addresses at its dynamic slots
The test reads an entry only inside the view addresses' buffer (none past it, where the buffer had an entry per title slot only), checks the slot's entry before it is made, after, once it is given back (it stays until the slot is made again: every table made afresh makes all its slots) and once it is made null, checks that a root view and a host copy's view pair made in dynamic slots clear the entries an earlier table left there, and puts a mark past the last entry that a view address noted for a slot past the dynamic ones leaves as it is. It takes any heap size the host gives: a title heap of 4 slots has dynamic slots past it either way.
Decode R32_UINT and R32_SINT numerically and scale their full integer span. Render constant nonzero targets white so they remain distinguishable from all-zero targets.
Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>