Commit Graph
83 Commits
Author SHA1 Message Date
Luiz Neves c8b4604ff2 Shaders: lower v_cvt_norm_i16_f16 and v_cvt_norm_u16_f16
The f16 source (with abs/neg) is clamped to [-1, 1] or [0, 1], scaled by
32767 or 65535 and rounded to nearest even once from the exact product;
NaN gives 0. The product is formed in integers from the f16's bits,
because in f32 it has up to 26 significant bits and would round first.
2026-11-23 23:43:35 -03:00
Marvis 35e8407c9c Merge pull request #129 from Luislariosss/fix/duplicate-test-module
GPU: rename the second test module in host.rs so the tests compile
2026-11-24 01:57:52 +01:00
LUIS LARIOS 7c59cc6f48 GPU: rename the second test module in host.rs so the tests compile
cargo test --workspace does not compile on main: host.rs declares
#[cfg(test)] mod tests twice, once near the top for the warp adapter test and
once at the end for the Batch::texture_due tests, so rustc rejects the crate
with E0428 before running anything:

    error[E0428]: the name 	ests is defined multiple times
    --> crates\victory-gpu\src\host.rs:1974:1

The second block only touches Batch, so it becomes mod batch and keeps its
two tests. cargo test -p victory-gpu --lib goes from "could not compile" to
43 passed, 0 failed, 1 ignored, and cargo test --workspace compiles again.
Nothing else changes: one line, no test bodies touched.
2026-11-23 18:46:19 -06:00
Marvis 2e52345f19 Merge pull request #51 from BaggyALPHA/fix/windows-commit-limit-diagnostic
Report Windows commit-limit failures in crashes.log
2026-11-24 01:43:50 +01:00
Marvis 23a6fe2539 Merge pull request #53 from a55uka/fix/wine-physical-pages
xmem: commit physical-page sections whole under Wine
2026-11-24 01:43:31 +01:00
Marvis 3fe3f1b09f Merge pull request #41 from LaunchDoesntCode/codex/proton-warp-safety
GPU: reject non-software WARP adapters under Proton
2026-11-24 01:43:06 +01:00
Marvis 73bdf6db84 Merge pull request #46 from 9hvn9yt2vk-netizen/shader-loop-limit
shader: VICTORY_SHADER_LOOP_LIMIT to find what makes world frames slow
2026-11-24 01:42:45 +01:00
Marvis 66670005fe Merge pull request #70 from FIocker/gpu/diagnostic-pipeline-filter
GPU diagnostics: skip pipelines by shader hash
2026-11-24 01:42:21 +01:00
Marvis 4229e5f9a8 Merge pull request #61 from TG0000/hle/physical-page-runs
xmem: write DirectStorage page destinations one view per run
2026-11-24 01:41:55 +01:00
Marvis 346379e331 Merge pull request #60 from ifBars/perf/reuse-texture-row-spans
Texture: reuse contiguous column runs across rows
2026-11-24 01:41:34 +01:00
Marvis e43a7379f6 Merge pull request #79 from TG0000/perf/texture-check-once-per-submission
GPU: check a sampled texture once per submission, not once per list
2026-11-24 01:41:12 +01:00
Marvis d43be4ffbe Merge pull request #66 from AndyLatimer/fix/gpu-rect-element-past-stride
GPU: leave rectangle vertex components past the stride alone
2026-11-24 01:40:50 +01:00
Marvis 5b4e38d7e6 Merge pull request #77 from Exorion1er/fix/guard-fault-race
GPU: keep a guarded block's write fault from being declined in a race
2026-11-24 01:40:25 +01:00
Marvis 69c43d71aa Merge pull request #36 from jeremygold02/codex/root-parameter-fixture
test(gpu): use the SDK root parameter in the serializer fixture
2026-11-24 01:40:04 +01:00
Marvis 45863ced7b Merge pull request #57 from Yaekai/fix/null-buffer-views
GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource
2026-11-24 01:39:35 +01:00
Marvis 64c51313af Merge pull request #37 from alessiodeia/fix/valu-med3-fract-trig
shader: keep fract(NaN) as NaN on NVIDIA and add synthetic GPU VALU tests
2026-11-24 01:38:41 +01:00
Marvis bfd36dc4af Merge pull request #80 from tedin7/vic-far-jump-backward
shader: decode backward far jumps (signed offset literal)
2026-11-24 01:37:00 +01:00
Marvis 2ff52dae91 Merge pull request #81 from tedin7/vic-scalar-carry
Shaders: set SCC from the carry of s_addc_u32 and s_subb_u32
2026-11-24 01:36:05 +01:00
Marvis 32704bb307 Merge pull request #58 from Yaekai/feat/shader-xnor-swap
Shaders: lower v_xnor_b32 and v_swap_b32
2026-11-24 01:35:31 +01:00
Marvis 0d7b42a3a9 Merge pull request #56 from 9hvn9yt2vk-netizen/find-input-underflow
shader: look up an input channel without underflowing
2026-11-24 01:34:59 +01:00
Marvis acd540dc18 Merge pull request #43 from 9hvn9yt2vk-netizen/shader-mask-cycle
shader: a lane mask that needs its own value fails instead of overflo…
2026-11-24 01:34:43 +01:00
Marvis b70bb6871a Merge pull request #50 from Vanthys/fix/format-offset-overflow
Guard texture and XMA offsets against overflow
2026-11-24 01:34:04 +01:00
Marvis a1f014d94b Merge pull request #75 from tedin7/vic-pe-export-holes
PE: skip unused export slots instead of reporting them at RVA 0
2026-11-24 01:33:39 +01:00
Marvis f5626996c3 Merge pull request #30 from AndyLatimer/fix/pe-rva-offset-overflow
PE: checked offsets in rva_to_file_offset and layout, remove dbg_tls
2026-11-24 01:33:20 +01:00
Marvis 5f540cd231 Merge pull request #38 from raffclar/emulation-tests
Loader: test the AMD-only instruction emulation on any CPU (including AMD!)
2026-11-24 01:32:45 +01:00
Marvis 056cc6b3f2 Merge pull request #28 from ifBars/fix/windows10-import-directory
Loader: preserve an empty import table for Windows 10 static TLS
2026-11-24 01:31:11 +01:00
Marvis 2179ee8d1f Merge pull request #45 from HenriqueSBueno/clwb
loader: emulate clwb on Intel CPUs before Ice Lake, a write-back loop in one exception
2026-11-24 01:30:02 +01:00
ifBars 247cd6baa2 Merge branch 'main' into fix/windows10-import-directory 2026-11-23 16:23:29 -08:00
FIocker bd9c5600e4 Keep the diagnostic skip outside indirect argument validation 2026-11-24 01:22:49 +01:00
tedin7 d46789485c Shaders: set SCC from the carry of s_addc_u32 and s_subb_u32
Both returned no carry, so SCC was missing and a branch or select on a 64-bit scalar add or subtract failed to translate. They now share the carry logic of v_add_co_ci_u32 and v_sub_co_ci_u32.
2026-11-24 01:17:24 +01:00
tedin7 ee6041788f fix: read a far jump's offset as signed so backward far jumps decode 2026-11-24 01:17:00 +01:00
TG0000andClaude Opus 5.5 2ef31abee1 GPU: check a sampled texture once per submission, not once per list
A title texture's staging refresh ran as a host step of every list that
sampled it. When several lists in one submission sampled the same
texture, it was checked again for each of them. In physical-page memory,
which cannot be write-watched, each check is a VirtualQuery walk and a
blake3 hash of the whole texture. Every list's GPU copy reads the same
staging buffer after all submission-time steps have run, so checks after
the first one in a submission did nothing unless title memory had been
written in between.

Texture refreshes are now their own step. The submission's Batch, which
already merges buffer refreshes, records the staging buffers it has
refreshed. A Copy into title memory or a Run step (work that may write
title memory) clears that record, so a texture is checked again after
any such write, as buffer refreshes are.

A synthetic benchmark (ignored test, release build, 12 lists sampling
48 textures of 4 MiB): 576 hashes in ~690 ms before, 48 in ~60 ms
after (~11x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 01:16:34 +01:00
ExorionandClaude Opus 5.5 bedd85e4ed GPU: keep a guarded block's write fault from being declined in a race
The write-fault handler opens the guarded block under the guard lock,
then, if it found none, asks whether the address is writable without
it. Between the two, another thread's fault could open the block and a
copy could guard it again: the handler then saw a read-only block that
is in fact ours, declined the fault, and the title crashed on a plain
write (seen 1-3 minutes into the world under Wine, where exception
dispatch is slow enough to hit it every run).

The lock is now held across both checks, so a block that is not ours
while it is held really is not ours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 01:15:23 +01:00
tedin7 85d03354fb fix: skip unused export address slots instead of reporting them at RVA 0 2026-11-24 01:15:10 +01:00
Henrique Bueno 0369ebe42a loader: a clwb write-back loop runs in one exception 2026-11-23 21:14:15 -03:00
FIockerandClaude Opus 5.5 3c96ef4734 GPU diagnostics: skip pipelines by shader hash
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-24 01:12:41 +01:00
meower 4841cc7107 xmem: commit physical-page sections whole under Wine
XMemAllocatePhysicalPages makes SEC_RESERVE sections and commits their
pages one view at a time. Under Wine each commit is a wineserver request
that scans every range committed so far, so wineserver ran at full load
while the title's threads waited on it, and loading hardly moved.

Under Wine (detected by ntdll's wine_get_version export) the sections
are now SEC_COMMIT and the per-view commit is skipped. Wine backs a
committed section with a sparse file, so untouched pages still cost
nothing. Windows keeps SEC_RESERVE, since a busy host may be unable to
commit the 6.1 GiB the title asks for in one go.

Tested: Linux (Wine 11.21), i7-12700K, RTX 4070. wineserver load drops
after the first seconds and the title gets to its loading screen,
drawing and dispatching.
2026-11-24 00:08:51 +00:00
ifBars 178bbb7915 Keep an empty import descriptor so Windows assigns static TLS
Use the descriptor count already validated by the PE parser, so the directory size need not include the null terminator. Check the OS-assigned static TLS index on a mapped test DLL.
2026-11-23 16:07:09 -08:00
Manuel PérezandClaude Opus 5.5 3c12f385a5 GPU: leave rectangle vertex components past the stride alone
Expanding a rectangle list makes the fourth corner from the other three,
element by element. An element that reaches past the vertex stride (the
input layout allows it to overlap the next vertex) was read and written
past the vertex's bytes, which panicked at submission. Only the
components inside the vertex are computed now; the rest keep the first
vertex's bytes, as unknown formats already do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 01:06:44 +01:00
MarvisandClaude Fable 5.2 62b737a69b GPU: pipelines off the render thread and cached; indirect execution on
With indirect execution the world's first frame asked for over 1,200
pipelines at once and took more than 30 s, so the title's own GPU
watchdog ended the run. Host pipelines are now made by worker threads: a
first use waits at most 0.5 s per title frame, and that pipeline's draws
are dropped until it is ready. The world presents frames again, and
indirect execution is the default (the switch is gone).

Pipelines are cached across runs:
- every host pipeline goes into a pipeline library saved under the cache
  folder (named by a hash of the translated code, our root signature and
  the state; a blob the device rejects starts an empty library);
- the pipelines drawn with are remembered and started during loading on
  the next run.
One cold and one warm run: the last pipeline was ready 38 s after the
world's first frame cold, 1.4 s warm; the first world frame took 3.2 s
cold, 0.37 s warm.

Also:
- Copy-backs of shader-written ranges return only the bytes the GPU
  changed; they used to overwrite what the title's CPU wrote meanwhile,
  which crashed the title.
- Indirect dispatch records are bounded (group counts were not), and the
  console's single-dispatch argument type runs as a dispatch.
- Per-shader counts of dropped draws in the diagnostics log; a switch
  that submits and times each list alone.

Not working yet: the world shows no geometry, and runs end on a GPU page
fault after at most about 55 s.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 01:02:11 +01:00
ifBars 8eaaf79c7b Reuse texture row spans when converting Xbox pixel layouts 2026-11-23 15:59:58 -08:00
TG0000andClaude Opus 5.5 cf703ccf77 xmem: write DirectStorage page destinations one view per run
write_physical mapped, committed and unmapped a view for every 64 KiB
page it wrote, and DirectStorage decoded each page-destination request
into a zeroed buffer first, then copied it. Every unmap flushes every
core's TLB, so with all the workers loading at once these writes were a
serial cost per page.

Pages are now looked up once and grouped into runs of consecutive slices
of one section (how titles allocate them), and each run is written
through one view. When a request's pages form a single run, DirectStorage
inflates or unpacks straight into that view instead of a buffer; pages of
several allocations still go through the buffer, written run by run.

Synthetic release benchmark (16 MiB destinations, Ryzen 9 5900X):
8 threads 3.5 -> 7.8 GiB/s; one thread, buffered then copied 0.96 GiB/s
vs in place 2.1 GiB/s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:59:56 +01:00
Yaekai e3e6dafd97 Shaders: lower v_xnor_b32 and v_swap_b32
Add lowering for v_xnor_b32 and v_swap_b32 (seen in GTA VI world compute shaders), and record v.dst as a read in ir.rs for v_swap_b32 / v_swaprel_b32 since both operands are read before being swapped.
2026-11-24 00:59:52 +01:00
Yaekai 720c23161f GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource
When a title creates a null buffer view (resource == 0, ViewDimension == BUFFER), buffer_bytes(0) returns None, so null_for() fell through to null_like() / null_view() (or a 2D texture UAV) and emitted a 2D texture descriptor into a slot where a shader expects a buffer.

Check desc[1] == 1 (D3D12_SRV_DIMENSION_BUFFER / D3D12_UAV_DIMENSION_BUFFER) in null_for() for both View::Shader and View::Unordered so null buffer views get a matching null buffer descriptor.
2026-11-24 00:59:49 +01:00
9hvn9yt2vk-netizen 0f198bf66b shader: look up an input channel without underflowing
find_input matched each input element with
`(row and channel in the element).then_some((id, channel - e.col))`.
then_some evaluates its argument first, so the subtraction ran for every
element, also those whose first channel is past the one asked for. In a
build with overflow checks (tests, debug runs) a pixel shader reading a
channel below any element that starts at z or w panicked, whichever row
that element was in, and packed inputs such as a float2 in .zw are
common. Release builds wrapped and threw the value away.

then() computes it only when the element holds the channel.

Found with a random-input harness over pixel, vertex and mesh programs
with matching signatures. The new test panics without the fix.
2026-11-24 00:57:59 +01:00
ifBars 47f321ed15 Clear the IAT directory alongside the import directory
Windows 10 maps the prepared image with both entries empty. The binder already retains the original slot RVAs, so preparation need not locate a linker-provided terminator.
2026-11-23 15:55:36 -08:00
alessiodeiaandBlueKaiman a95f6aec42 shader: keep fract(NaN) as NaN on NVIDIA and add synthetic GPU VALU tests
Fixes a real-hardware NVIDIA bug in fract() from 36eb0b4 and adds synthetic GFX10 -> DXIL -> GPU/WARP regression tests for the RDNA2 VALU lowerings from #2:

- fract(): select(OGT(r, k), k, r) is folded by NVIDIA's DXIL compiler into FMNMX (minNum), which swallows NaN and turns v_fract_f32(NaN) into 0x3f7fffff (and v_fract_f16(NaN) into 0x3bff). Comparing with pred::OGE against a distinct threshold (1.0 for f32, 1 - 2^-12 for f16) prevents the minNum fold and preserves NaN and +/-inf -> NaN on both NVIDIA hardware and WARP.
- valu_tests.rs: builds minimal synthetic GFX10 compute shaders, lowers them through the full pipeline (ir::build -> resource::track -> io::raise -> structure -> lower), validates with dxil.dll when present, and executes them via Host::dispatch on both hardware GPU and WARP without requiring console dxc. Covers v_fract_f32/f16, v_med3_f32/f16, v_sin/v_cos_f32/f16, and v_bfe_i32/u32 + s_bfe_i32.

Co-authored-by: BlueKaiman <[email protected]>
2026-11-24 00:51:42 +01:00
Manuel Pérez 058fab325d PE: remove leftover dbg_tls test and check layout offsets
Removes the print-only dbg_tls test in image.rs (TLS presence is already asserted in parses_own_test_binary) and switches layout.rs offset helpers (read_u32, read_u64, optional_header_offset, file_header_offset, data_directory_offset) to checked arithmetic so extreme offsets return None instead of overflowing.
2026-11-24 00:48:47 +01:00
BaggyALPHA 5a9ecf0f61 Report Windows commit-limit failures in crashes.log 2026-11-23 18:48:23 -05:00
Vanthys 536c5d4371 Reject empty XMA test fixture directories 2026-11-24 00:46:54 +01:00