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>
The stub that answers a slot a table does not fill reported only the
object kind, the slot and the caller's offset. Two reporters (#829 and
the #417 thread) had to patch it locally, logging rcx/rdx/r8/r9, to tell
what the call carried; one of them asked for it upstream.
The stub now takes the receiver and the next three registers and logs
them as `args=` alongside the rest, once per slot as before. On win64 all
four are registers, so reading them never touches the caller's stack,
and a call made with fewer real arguments only shows whatever its
registers held. That is enough to tell a call passing an interface GUID
or a module address from one passing flags, a count or an out pointer
without rebuilding with a local patch.
Co-authored-by: pablogonz12 <pablogonz12@users.noreply.github.com>
members() tested all 385 register slots to return the few that are live,
twice for every block of a program: 1.27 M tests for a 1,651-block
shader. Walk the seven set words by their lowest set bit instead, in the
same register order. The IR build is 4.5% faster on a synthetic GFX10
program of 12k and 24k instructions, and range::build 4.1% faster.
Co-authored-by: slatefield <slatefield@users.noreply.github.com>
`show_config` printed `POLICY VIOLATION` for each configured path inside
the source tree but always returned `Ok`, so a script could not tell a
clean configuration from a refused one. It now counts the violations and
fails after printing them; the stdout output is unchanged.
Fixes#831
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The RX 5700's driver zero-extends the bytes of a dot4 multiplicand it
sees as a constant, so fspx_programs_run_with_the_hardwares_dot_products
failed on RDNA1 although the DXIL asks for signed bytes. Each operand is
now a literal plus a word loaded from the zeroed UAV.
Fixes#1782
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Every root signature we make declares SAMPLER_HEAP_DIRECTLY_INDEXED, and a
list must have a sampler heap bound before such a signature is set (the
debug layer's id 1419, and NVIDIA removes the device with INVALID_CALL for
it: #1754). bind_heaps only ever bound the heaps the title bound, plus our
view-heap fallback for the case the title binds none, so a compute list that
reads views and no samplers -- the list in that report -- set the signature
with no sampler heap bound at all.
There is now a sampler heap of ours, made on first use with a point sampler
in slot 0, bound whenever the title binds no sampler heap; the decision is a
small function with a test, so which heaps a list must have can be read
without a device.
v_cubeid/sc/tc/ma_f32 pick a coordinate (or its negation) as the
result, so a denormal coordinate came out as the host's: kept on AMD,
flushed to -0 on WARP, where the console's float mode reads it as a zero
of its sign. The coordinates now go through ftz first, as min and max's
operands do (77053a0).
A semantics probe runs the four over signed zeros, denormals,
infinities and NaN in each coordinate (14,440 inputs) against the RDNA2
model. Without the change: 2,193 model mismatches on an RX 9070, 1,276
on WARP, and the two disagree on 917.
Found by the cross-device fuzzer (#1614).
Co-authored-by: alexdeliu <240865807+alexdeliu@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Shaders: 64-bit integer compares on their dwords
v_cmp_{lt,le,gt,ge}_{i64,u64} lowered to one i64 icmp give the wrong
answer on AMD's D3D12 driver when the operands share a dword: `v_cmp_lt_i64
s20, v[1:2], v[2:3]` with v1 = v2 = 0, v3 = 1 (0 < 0x1_00000000) is false
on an RX 9070 (32.0.32029.2010) and on a Ryzen 7700 iGPU, gfx1036
(32.0.21045.29003), as if the dwords were swapped; WARP gets it right.
Disjoint pairs are fine there, and so is equality.
The compare now runs on the dwords: the high ones decide (signed for
i64), equal ones leave it to the low ones (unsigned). It needs no INT64.
The GPU test runs all twelve compares over values whose dword orders
disagree, on disjoint and on shared registers; without the change it fails
on the AMD hardware.
Found by a cross-device fuzzer that compares single VALU instructions on
every adapter and WARP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Shaders: a signed 64-bit compare's literal sign-extends in the dword split too
main's src64 now sign-extends the 32-bit literal of an _i64 operand
(signed_64_bit_operands_sign_extend_their_literal). The dword compare
read the literal's high dword as zero, so v_cmp_lt_i64 v[1:2], -100
compared against 0x00000000_FFFFFF9C. It now takes the same high dword
src64 would.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: alexdeliu <240865807+alexdeliu@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A wireless receiver with its controller switched off still answers
XInputGetState with an all-zero state, which connected the empty slot
and disconnected the keyboard stand-in pad.
Keep each host slot disconnected until its current connection reports
non-rest input, reset that flag on disconnect, and keep scripted
diagnostic keys on the stand-in while no host pad has reported input.
Fixes#845.
Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>
* Pipeline: accept existing entry when concurrent cache publication races on Windows
* Pipeline: exercise the blocked Windows cache publication path
Keep the published entry open without delete sharing and assert that replacement is blocked. The regression fails with the pre-fix publication code and passes with the current implementation.
Validation: 5 pipeline tests passed on x86_64-pc-windows-msvc; pipeline Clippy with warnings denied and formatting checks passed.
* Pipeline: adapt concurrent publication test to new tempfile_in signature
* Shaders: v_med3 orders -0 below +0, as RDNA2 does
The ISA defines v_med3_f32/v_med3_f16 over v_min_f32/v_max_f32, which order
-0 below +0 (#448 settled those), so of three zeros the median is the sign
two of them share; DXIL's plain FMin/FMax chain gives either zero. The zero
the chain leaves now takes that majority's sign (11 instructions). A NaN
still gives the minimum of the three.
Noticed while porting the idea of ivall/xcl#1348 (DavidM1911).
Tests: hardware execution tests in valu_tests for both operand orders and
the halves.
Written with an AI assistant.
* Shaders: keep main's med3 lowering, leave only the signed-zero test
main's max_min_flushed chain (77053a0c) already orders -0 below +0, so the
majority-sign select this branch added gives the same result.
---------
Co-authored-by: pgm1207 <104554896+pgm1207@users.noreply.github.com>
Co-authored-by: pablogonz12 <pablogonz12@users.noreply.github.com>
The console ignores blending on integer render targets and the title
leaves it on (the world has a mesh pipeline blending into an R8_UINT
target). D3D12 does not allow it: vkd3d-proton refuses such a pipeline
with E_INVALIDARG and its draws are lost. The host pipeline now turns
blending off on integer targets; with one description for all targets,
each target gets its own copy so the others keep theirs.
(cherry picked from commit 169efcb84eb5d9d83c0af7fe525a54ada86f3a0d)
Co-authored-by: pgm1207 <104554896+pgm1207@users.noreply.github.com>
Co-authored-by: pablogonz12 <pablogonz12@users.noreply.github.com>
ir::build fills every instruction's register lists twice. `effects()`
collects `Vec<Reg>` (two allocations), and the caller immediately maps
each one into `Vec<(Reg, Value)>` (two more), freeing the first pair. For
lists that are almost always two to four entries, that is four
allocations and two copies per instruction, on every instruction of every
program.
Have `effects()` and its helpers collect the `(Reg, Value)` pairs
directly, with the placeholder the SSA pass fills in. Two allocations per
instruction instead of four; `Inst` and everything downstream are
unchanged.
Measured with the synthetic bench in #1002 (no game data), ten
interleaved rounds per arm, nanoseconds per instruction, at 256/1k/4k/16k
instructions:
ir::build 308 -> 269, 375 -> 324, 407 -> 340, 402 -> 353 (0.835-0.878)
translation 898 -> 872, 898 -> 825, 951 -> 875, 956 -> 912 (0.919-0.971)
gfx10::decode, structure, lower and the rest are unchanged. The emitted
DXIL is byte-identical at all four sizes.
cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.
Both clippy configurations clean; cargo xtask policy ok.
Co-authored-by: pes7 <pes7@users.noreply.github.com>
* xmem: keep the space below 4 GiB for the title's 32-bit memory
XMemVirtualAlloc with the 32-bit address flag has to fit below 4 GiB, where
Windows also puts the host's own memory first (it allocates bottom up). With
a large pipeline cache read at startup, the driver's, heap and cache memory
left 22 MB there, in pieces of at most 14 MB, when Grand Theft Auto VI asked
for a 185 MB 32-bit placeholder; the request was refused
(ERROR_NOT_ENOUGH_MEMORY) and the title stopped at an assertion
(+0x19f4f58). The D3D12 debug layer's memory did the same.
`low_guards::install`, at the start of `run`, reserves the free space below
4 GiB but the lowest 256 MB (left to the host). A 32-bit request that finds
no room releases the smallest guard that fits it (else the largest) and
tries again, then guards what is still free of it.
Tested: the new test releases a guard, takes part of the hole and checks the
rest is guarded again. In the title (RTX 2080, a build with a large cache):
without this the startup failed 2 of 3 times; with it, 5 of 5 starts passed,
3.7 GB below 4 GiB kept for the title.
* Bound low-address allocation retries to existing guards
* xmem: safety comments and formatting for the bounded guard retry
---------
Co-authored-by: swarm <swarm@swarm.swarm>
Co-authored-by: NuraadGit <NuraadGit@users.noreply.github.com>
The early list keeps this run's keys first, then earlier runs' others,
but those came from a HashSet, so once the list was full the keys that
made room were any earlier ones, not the oldest.
Earlier keys now keep their place in the list as loaded. The list is
saved most recent run first, so sorting by that place drops the oldest
runs' keys and keeps the order across saves. A list saved by an earlier
build (in no order) still reads.
`save` also reads the list through `used()`, so a save before anything
read it in this run keeps the saved list instead of writing an empty one.
RDNA2 flushes denormal operands of the legacy multiplies to zero, so
0 x anything = 0 also holds for them. The lowering only tested for an exact
float zero, whose result also depends on the host's denormal mode. Test the
exponent bits instead. Follow-up to #2.