跳到正文
Richard Erectus 🇫🇮 🇮🇱· 来源· @richard_erectus · X·· 1 小时前AI 评分8
正文 · 原文

LETS GO FURTHER ROADMAP TO GTA STABLE PC BUILD

THIS THE WAY U PROMPT

Phase 0: Observability & Plugging the 40 MB/Frame Leak

Audit Per-Frame GPU Object Creation:
Hook ID3D12Device::CreateCommittedResource, CreateDescriptorHeap, CreateCommandAllocator, and CreateGraphicsPipelineState with Tracy Profiler call-stack sampling. Any allocation whose live count rises monotonically across 50 frames is the culprit.

Implement a Fence-Gated Deferred Deletion Queue: In DirectX 12, you cannot free a buffer or command allocator while the GPU is still executing commands referencing it—which often leads rushed AI patches to simply never release objects at all. Wrap all transient allocations in a 3-frame-in-flight ring buffer (kFramesInFlight = 3) paired with a DeferredReleaseQueue that destroys objects automatically once the ID3D12Fence passes their submission value.

Sub-Allocate via D3D12MA: Replace raw CreateCommittedResource calls (which have massive OS page overhead and fragmentation) with AMD's D3D12 Memory Allocator using pooled upload and default heaps.

Build a Headless CI Benchmark Runner: Automate a 200-frame capture booting straight to a saved checkpoint, emitting JSON telemetry (ram_delta_mb, p99_frametime_ms, dred_faults, pso_compiles). Every future pull request or agent commit must pass this gate automatically.

Phase 1: Frame-Loop Determinism, UMA Bridging & Killing

Right now uidraw is reading garbage memory because the frame loop is unstable, and devlost keeps firing intermittently. Both bugs share the same root cause: Xbox Series X assumes Unified Memory (UMA) and console-specific synchronization that do not exist on discrete PC GPUs.

Solve the Unified Memory (UMA) Split: On Xbox, CPU and GPU share one coherent GDDR6 pool; the game writes directly to GPU-visible memory (including UI vertex buffers and BVH inputs) and queries permissions via XMemVirtualQuery. On PC, discrete VRAM sits across the PCIe bus.

Allocate guest-writable GPU buffers in shadow system memory (UPLOAD heap or pinned host memory), track dirty 4 KB pages using Windows GetWriteWatch / page-guard faults, and emit batched CopyBufferRegion commands strictly before the command list consumes those buffers.

This eliminates the race condition where uidraw reads uninitialized or half-overwritten VRAM.

Enforce Strict Resource State Barriers: Xbox D3D12.X relies on explicit cache flushes and hardware-implicit transitions that standard PC D3D12 treats as undefined behavior (triggering instant DXGI_ERROR_DEVICE_REMOVED / devlost). Implement a per-subresource state tracker inside the shim and emit DX12 Enhanced Barriers (or strict legacy D3D12_RESOURCE_BARRIER transitions) between every COPY_DEST, RENDER_TARGET, UNORDERED_ACCESS, and PIXEL_SHADER_RESOURCE state change.

Handle Xbox Texture Tiling (XG Swizzling): Xbox assets use hardware-tiled memory layouts (XG micro/macro-tiling) and BCPack compression. Implement a compute-shader detiling pass on upload so PC GPUs sample valid BC7 / BCn blocks instead of garbage noise.

DRED & GPU-Based Validation (GBV) Sweep: Run the headless test under the DX12 Debug Layer + GBV + DRED (Device Removed Extended Data). Feed the exact faulting draw-call breadcrumb and GPU virtual address directly into debugging until 1,000 consecutive frames pass cleanly.

Phase 2: Breaking the 2 FPS Wall (500 ms to ~33 ms)

Hunt Down Hidden WaitForIdle Stalls: Capture a single frame in PIX for Windows or RenderDoc and inspect the GPU timeline. If the GPU sits 95% idle waiting between tiny draw bursts, the shim is calling WaitForSingleObject on a fence after individual draw calls, texture uploads, or Map/Unmap operations. Rip out all mid-frame CPU waits so the CPU stays 1 to 2 frames ahead of the GPU.

Asynchronous Persistent PSO Disk Cache: Compiling translated shaders into DirectX 12 Pipeline State Objects on the main render thread causes massive multi-hundred-millisecond freezes. Hash every incoming Xbox shader binary, compile translated DXIL asynchronously on a worker pool, and serialize compiled PSO blobs to a local disk cache (ID3D12PipelineLibrary1) so shaders compile once and load in microseconds on subsequent runs.

Eliminate Unnecessary PCIe Readbacks: Audit every D3D12_HEAP_TYPE_READBACK allocation. Never copy GPU buffers back to system RAM unless the guest CPU actually dereferences that virtual address.

Restore Multi-Threaded Command Recording: Rockstar's RAGE engine records command lists across multiple CPU worker threads simultaneously. Ensure the shim's command-list wrapper uses lock-free thread-local allocators instead of a single global mutex serializing all draw calls onto one core.

Phase 3: RDNA2-to-DXIL Shader Lifting & Turning the Lights On

Unlike PC games that ship portable DXIL bytecode, Xbox Series X ships precompiled raw AMD RDNA2 machine code packed inside console containers (XBCH / FSSM) alongside PSV0 and RTS0 root signature metadata. Fixing 300+ shaders by hand is a dead end—you have to fix the compiler/translator.

Histogram-Driven Opcode Coverage: Dump all failing Xbox shader binaries and run an offline disassembler script to build a frequency histogram of unsupported RDNA2 mnemonics. In practice, 300+ broken shaders usually boil down to 15 to 30 missing hardware instructions—typically SDWA/DPP sub-dword swizzles, v_readfirstlane, s_getpc constant loads, packed FP16/INT8 vector math, and raw structured buffer loads.

Lift RDNA2 ISA to Clean SSA IR → SM 6.6 DXIL:

Parse the PSV0/RTS0 metadata to reconstruct exact shader stage inputs, outputs, and bindless resource descriptors.

Lift the RDNA2 ISA into an intermediate representation (or structured HLSL) and compile through Microsoft's dxcompiler.dll (DXC) into Shader Model 6.6+ DXIL.

Validate every lifted shader in an offline headless corpus test against the Windows WARP software rasterizer and real hardware before launching the game.

Solve the Wave32 vs. Wave64 Architecture Mismatch: Xbox's RDNA2 GPU switches freely between 32-wide and 64-wide wavefronts. NVIDIA PC GPUs are strictly Wave32 (32-thread warps), and AMD PC drivers select wave width dynamically. Any Xbox Wave64 compute shader using cross-lane operations (ballot, WaveReadLaneAt, WavePrefixSum) will silently corrupt shadows, tiled light culling, or screen-space effects on NVIDIA hardware unless the lifter either enforces [WaveSize(64)] where supported or splits Wave64 intrinsics into dual-half emulated 32-lane operations.

Map Xbox Bindless Tables to SM 6.6 Dynamic Resources: Modern RAGE lighting relies heavily on massive bindless descriptor arrays. Map Xbox's inline descriptor heaps directly to PC Shader Model 6.6 ResourceDescriptorHeap[] / SamplerDescriptorHeap[] to eliminate CPU descriptor-copying bottlenecks and bring the G-buffer, PBR materials, shadow maps, and deferred lighting passes online.

Phase 4: Hardware Ray Tracing (DXR 1.1), Streaming & Audio

Translate Xbox BVH & Ray Tracing to PC DXR Tier 1.1:

Intercept calls to XboxBvhBuilder and map Xbox bottom-level (BLAS) and top-level (TLAS) acceleration structure descriptors to standard PC ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure.

Translate inline ray-tracing RDNA2 instructions (image_bvh64_intersect_ray) directly into standard DXIL DXR 1.1 RayQuery intrinsics so both NVIDIA RT Cores and AMD Ray Accelerators execute GTA 6's ray-traced global illumination (RTGI) and reflections natively in hardware.

Schedule BVH refits and RTGI denoising passes on a dedicated Async Compute Queue (D3D12_COMMAND_LIST_TYPE_COMPUTE) so they run concurrently alongside rasterization instead of stalling the main graphics pipeline.

Build an RT Debug Toggle: Add a runtime config flag to scale RTGI ray bounce count and half-res/quarter-res ray tracing so mid-range GPUs can maintain 60 FPS without turning off global illumination entirely.

Replace Xbox Velocity Architecture with DirectStorage 1.2+: Xbox relies on dedicated hardware decompression blocks for BCPack and Zlib streams to feed Vice City's dense asset streaming at high driving speeds. Route those I/O queues to PC DirectStorage 1.2+ GPU decompression (with a lock-free multi-threaded CPU decompression worker pool as a fallback so SATA SSDs don't cause traversal hitches).

Offload XAudio2 / XMA2 Decoding: Stubbing audio gets you booting, but Xbox uses hardware XMA2 audio blocks that don't exist on PC. Intercept xaudio2_9.dll ordinals and decode XMA2 / Opus packets via FFmpeg (libavcodec) on dedicated low-priority background threads so audio decoding never contends with the main simulation or render threads.

来源:Richard Erectus 🇫🇮 🇮🇱 · x.com