Commit Graph
19 Commits
  • Loader: test the AMD-only instruction emulation on any CPU
    The test for the emulation runs the real instructions. AMD CPUs, and
    most CI runners, execute them natively, so the emulation was tested
    only on Intel CPUs.
    
    The new tests give the emulation instruction bytes and saved registers
    directly, so they work on any CPU. They cover clzero, monitorx/mwaitx,
    the immediate and register forms of extrq/insertq, xmm8 to xmm15,
    length 0, and the instructions and exceptions it must not emulate.
    
    The old test stays: on an Intel CPU it is the only test of the full
    path through the vectored handler.
  • Merge pull request #14 from 9hvn9yt2vk-netizen/fix-xma-zero-length
    xma: stop at a zero-length frame instead of looping forever
  • GPU: the world stays up; indirect execution behind a switch
    The host device was removed seconds into the world because a shader read
    a descriptor of the wrong kind: empty slots held a null 2D texture view
    where the shader expected a buffer, which gave a garbage heap index and
    a read far past the view heap. Null descriptors now have the kind the
    shader expects (raw buffer, constant buffer, or a texture of the title's
    own dimension). The world then ran to a 240 s time limit with no removal.
    
    Also:
    - Host lists hold the textures, pipelines, root signatures and heaps they
      name, and heap slots hold the resource they view (the title releases
      objects before submitting lists that use them).
    - The device-removed report places the fault against the host descriptor
      heaps and names our own uploads; VICTORY_D3D12_GBV turns on GPU-based
      validation, VICTORY_DUMP_TARGETS works.
    - Indirect execution (draw, indexed draw, dispatch, mesh dispatch): the
      world draws most of its geometry this way. Arguments are clamped and
      charged to a per-list budget by a small compute pass first, so garbage
      cannot hang the GPU. Off by default (VICTORY_INDIRECT=1): with it on
      the title's own GPU watchdog ends the run about 30 s into the world.
    - Shader-written ranges are copied back once per submission and only
      where they differ; refreshes beside them copy only stale pages. The
      frame-rate line counts copy-backs and dropped draws.
    
    Not working yet: the world's picture is black (indirect draws off, and
    hundreds of draws per frame have no translated shader).
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • Shaders: sine and cosine in turns, exact zeros at half and quarter turns
    v_sin and v_cos (f32 and f16) take an angle in turns. The whole turns
    now come off first (x - round_even(x), exact), so a large angle keeps
    its fraction of a turn instead of losing it when scaled to radians.
    The sine of a half turn and the cosine of a quarter turn are exactly +0,
    as the hardware gives; the host's functions of the rounded angle give
    about 1e-7. A zero operand passes unreduced, so sin(-0) stays -0.
    
    float_semantics_are_the_consoles asserts the exact zeros (it failed
    before this change). The compiler the tests use takes whole turns off
    itself, so the large-angle path cannot be reached from HLSL and rests
    on the measurements cited in issue #2.
    
    Left from the issue: denormal operands of the legacy multiply, which
    needs the float mode register as state first.
    
    Refs #2
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • Shaders: med3 with NaN, fract below 1.0, signed bit fields past bit 31
    Three lowerings gave results the console's GPU does not (issue #2, from
    hardware measurements published by another project):
    
    - v_med3_f32/f16: with a NaN operand the hardware gives the minimum of
      the three; we gave the median of the other two.
    - v_fract_f32/f16: the hardware never reaches 1.0 (a tiny negative
      input gives the largest value below it); the host's own fract differs
      by vendor and can give 1.0.
    - v_bfe_i32/s_bfe_i32: a signed field running past bit 31 extends from
      bit 31; the shift is arithmetic now. Fields that fit are unchanged.
    
    The fract case is asserted in float_semantics_are_the_consoles (the
    console compiler emits v_fract_f32 for frac). The other two cannot be
    produced from HLSL with the compiler the tests use and rest on the
    measured values in the issue.
    
    Still open from the issue: range reduction before sine and cosine, and
    denormal operands of the legacy multiply.
    
    Refs #2
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • Merge pull request #10 from ismailchaka1/emulate-amd-only-instructions
    loader: emulate AMD-only instructions on Intel CPUs
  • xma: stop at a zero-length frame instead of looping forever
    next_frame walks the frames before `start` to learn whether the frame at
    `start` is the packet's last. A damaged packet whose earlier frame has a
    length of 0 never advanced `at`, so the walk spun forever (in a debug build
    it overflowed `number` after about 4 billion rounds and panicked).
    
    Apply the rule read_frame already uses: a length that does not cover its
    own 15-bit field is not a frame, and the search ends.
    
    Found with a random-input harness. The new test hangs without the fix and
    passes at once with it.
  • loader: emulate AMD-only instructions on Intel CPUs
    The title is built for Zen 2 and uses clzero, monitorx/mwaitx and SSE4a's
    extrq/insertq, which Intel CPUs lack: it died at startup with an illegal
    instruction on an i7-14700KF. The vectored handler now does their job and
    resumes: clzero zeroes the 64-byte line at rax, monitorx is skipped, mwaitx
    yields, extrq/insertq run on the saved XMM registers.
    
    Tested: victory-loader crash tests (new one runs each instruction), and the
    title now gets past startup on an i7-14700KF with an RTX 4070 SUPER.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Merge pull request #4 from Exorion1er/fix/tls-callbacks-reloc
    Loader: keep the cleared TLS callback pointer out of base relocations
  • Loader: keep the cleared TLS callback pointer out of base relocations
    prepare() zeroes the title's TLS AddressOfCallBacks but left the
    IMAGE_REL_BASED_DIR64 entry that patches it. When the loader maps the
    prepared copy away from its preferred base, that entry turns the 0 into
    the rebase delta and the loader reads TLS callbacks from there. On
    Windows the copy lands at 0x140000000 so the delta is 0; under Wine,
    which maps DYNAMIC_BASE images high, LoadLibraryExW faults in ntdll
    before any title code runs.
    
    The entry is now rewritten as IMAGE_REL_BASED_ABSOLUTE (a no-op), and
    the prepare test checks that no relocation targets the cleared field.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • README: status, subsystem table, how to run, debugging switches
    Says how far the title gets (menus at 30 fps, the world reached but not
    rendering), what each subsystem does and still needs, and warns that the
    world can reset the display driver on a real GPU. Adds how to run the
    title, the translate command, and tables for the keyboard pad and the
    debugging switches.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • Run Grand Theft Auto VI from first boot into the world
    The title now boots through every first-boot and menu screen at its own
    30 fps, drawing with translated shaders, with input, sound, saves and
    loading served; it reaches the world, where the host GPU path still
    fails (see "Not working yet").
    
    Loader and runtime
    - Crash reports unwind properly, name C++ throws and host GPU failures,
      carry the title's last debug lines and are appended to crashes.log.
    - Thread notices on our own threads, reentrant late DLL loading, exit in
      the console's order, relaunch on a launch-new-game request.
    - Offline guard: the title cannot reach the network (sockets, name
      lookups, WinHTTP, the media source resolver); by-name lookups and
      loads follow the import rules.
    - Every runtime area the title calls is served (networking hint,
      packages, store, saves, display, UI, speech stubs, user, async pool).
      Saves persist; an update is one rename and survives a kill at any step.
    - DirectStorage reads for real: shared worker pool, priorities, zlib and
      BCPack. BCPack is our own decoder; the format's constant tables ship in
      crates/victory-formats/src/bcpack-tables.bin (the asset policy's one
      exception, see docs/asset-policy.md).
    - GameInput from XInput pads and the keyboard, with a keyboard stand-in
      pad; console timers (1 ms) for the whole process.
    - Audio: XMA2 decoding on the emulated contexts, Opus on the decoder
      queues, the DSP interface as a stub; title memory placed below 2^40.
    - Console texture layouts (sizes, tiling, detiling) and the layout
      library's imports.
    
    GPU
    - Draws, mesh dispatches and compute dispatches run on the host with
      shaders translated at first use and cached on disk; descriptor heaps,
      views, root signatures, barriers and host texture states; rectangle
      lists; comparison samplers.
    - Title memory reaches the host through persistent mirrors that copy
      only pages written since the last copy; shader-written buffers are
      copied back.
    - Presentation with frame pacing per event kind; framerate in the window
      caption.
    
    Shaders
    - DXIL emission for vertex, pixel, compute and mesh programs from the
      console's native code, with a differential test suite against the PC
      compile. World set: mesh 8,191 of 8,506, vertex/pixel 10,617 of
      12,346, compute 1,643 of 2,539; utility set complete.
    
    Build
    - Debugging aids (debug logs, frame capture, stack dumps, scripted keys,
      the host debug layer, the software adapter) exist only with the
      `diagnostics` feature; `[profile.diag]` keeps that build apart.
    
    Not working yet
    - In the world the host device is removed within seconds (descriptor
      handling fixes are in, unproven by a surviving run) and frames present
      black.
    - 64-bit image atomics, merged geometry stages and the BVH builder's own
      shaders do not translate; reverb is silent.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • Thread notices: leave out threads Rust's std starts
    Their TLS callbacks run before std's start routine records the thread,
    and std aborts if anything asks for the current thread first (stdout and
    stderr locks do, so title code calling our logging functions would).
    Threads starting in our exe (the title's main thread and our runtime's
    workers) now get no notices; the probe test starts its thread in title
    code.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Thread notices for title images
    The prepared images get no DLL_THREAD_ATTACH/DETACH from Windows. A TLS
    callback in our exe, called on every thread of the process, passes each
    start and end on to the attached images: their TLS callbacks, then a
    DLL's DllMain. DisableThreadLibraryCalls stops the DllMain calls and
    fails for images with static TLS, as on Windows.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Title DLLs at run time: find by name, map on first LoadLibrary
    GetModuleHandle* and LoadLibrary* find the title's images and our
    console modules by file name. LoadLibrary* of a title DLL nothing
    imports maps, binds and attaches it on the calling thread (a title's
    own loader DLL may load its backends this way). FreeLibrary never
    unloads title images.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Run Minecraft: runtime HLE, D3D12.X device on the host GPU, shader IR
    Loader: map title-shipped DLLs, patch static TLS loads to slot 0, crash
    reporter, title paths for GetModuleFileName*.
    
    HLE: task queue and async, XUser (one offline user), system ids,
    title id, features, invites, game events, persistent local storage,
    GameInput with no devices, xmem, console audio hardware queues, life
    cycle (close suspends, then terminates), and a file layer with virtual
    drives rewritten in path-taking imports.
    
    GPU: D3D12.X device, DXGI chain, heaps, resources, fences, queues and
    command lists translated onto a host D3D12 device; clears, barriers,
    copies, resolves and PresentX into the title's window.
    
    Shaders: SGD5 reader and `victory translate`; SSA IR with node
    splitting for irreducible flow; structurisation removing EXEC.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • GFX10 operand fields and SP3 text; FSSM wave size
    Decode the operand fields of every GFX10 encoding (Instruction::fields)
    and print them in SP3 syntax (Instruction::text, shader-info --disasm).
    Read the wave size from the FSSM stage record flags.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Initial commit
    Rust workspace for VIctory: PE analysis, loader, HLE skeleton,
    DXBC/DXIL parsing with a GFX10 decoder, conversion cache, CLI and
    asset-policy enforcement.
    
    Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>