Commit Graph
83 Commits
Author SHA1 Message Date
Enzo Souza Duarte eb30a0d9f4 GPU: write half subnormals from f32 rectangle outputs 2026-11-24 00:09:56 -03:00
Marvis d2a4bae1f4 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 7102a4989c 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 9aef3d9c06 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 8a8a38d12c 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 4c0bb89788 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 91e9bc9924 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 6168fc64f0 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 97464baa91 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 93bc9786db 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 fa5ef73495 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 0f35dfc135 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 fc0c4dd331 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 683278b0f5 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 eda38aa4df 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 237f2e85c4 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 4926f72874 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 46610eb846 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 4a8a058988 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 8fe0b7419c 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 a6888a6831 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 062ad14eae 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 bf6c557c5f 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 cc519270ee 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 cbd71a9bde 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 27e64428ca 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 7d33c4633c 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 0e5953d1dd Merge branch 'main' into fix/windows10-import-directory 2026-11-23 16:23:29 -08:00
FIocker 38ae55dc13 Keep the diagnostic skip outside indirect argument validation 2026-11-24 01:22:49 +01:00
tedin7 a2f5f4351d 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 c963b7168d 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 73d776b9c9 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 4c1766c235 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 9a5cbbeb64 fix: skip unused export address slots instead of reporting them at RVA 0 2026-11-24 01:15:10 +01:00
Henrique Bueno c4e915f95e loader: a clwb write-back loop runs in one exception 2026-11-23 21:14:15 -03:00
FIockerandClaude Opus 5.5 0eca412a46 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 78b84047e5 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 25a3e9596f 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 f3c7f0f2ad 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 35b054ec03 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 fc807b6e76 Reuse texture row spans when converting Xbox pixel layouts 2026-11-23 15:59:58 -08:00
TG0000andClaude Opus 5.5 4e94c2b05a 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 0c560918b3 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 071487fb2d 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 5fbea4730b 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 4da3d63666 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 2e5001cf9d 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 ef22723e84 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 7e42fefebc Report Windows commit-limit failures in crashes.log 2026-11-23 18:48:23 -05:00
Vanthys 4cca76795f Reject empty XMA test fixture directories 2026-11-24 00:46:54 +01:00