fix(water,shaders) & perf(gpu,hle): fix water black squares and broad RAM/CPU/GPU optimizations #408

Closed
github-bot wants to merge 5 commits from github-bot/gh-408 into main AGit
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 00:18 UTC · original
ZerefDragnee1l:fix/water-black-squares-and-perf-optimizations → main · +4376 −1743 · 68 files · 5 commits · closed without merging

Summary

This PR combines fixes for black squares on water, targeted replacement compute shader correctness/performance fixes, and broad RAM, CPU, GPU, DirectStorage, audio, input, and build optimizations rebased cleanly onto main (d2a79dd).

  • 68 files changed across shaders/replace/, crates/larp-shader, crates/larp-gpu, crates/larp-hle, crates/larp-formats, crates/larp-loader, crates/larp-game, crates/larp-pipeline, apps/larp, Cargo.toml, and docs/.
  • Pipeline PSO blob cache reuse is preserved: On-disk PSO blob keys (blobs::name), VICBLOB1 headers, and pipeline_cache/blobs/ paths are unchanged, so existing host driver pipeline blobs continue to load from disk without recompilation (only shaders whose translated DXIL actually changes from the water/shader bugfixes generate new DXIL keys).

1. Water Black Squares Fixes

Root causes identified across fog/transmission compute shaders, translator LDS synchronization, NIS linear HDR luminance, and D3D12 copyback transitions:

  • Volumetric / water fog shaders (6871d6e4, a10179ab, 926c46ba): Guarded log2(max(..., ...)), filtered NaN/non-finite lanes before WaveActiveSum / WaveActiveCountBits, clamped z/top slice bounds and cluster lookup (max(d514, 1u) - 1u), sanitized aS/aT with HLSL-2021 select(), and gated run_copy LDS InterlockedMin/InterlockedMax on go.
  • Bounds & scissor guards (07fb4c72, d3c33084): Guarded w > x && h > y around mask evaluation / InterlockedOr in 07fb4c72 and clamped fx1/fy1 in d3c33084.
  • LDS hazard synchronization (crates/larp-shader): Updated lds_meetings in emit/lower.rs to also synchronize overlapping plain (ds_write*) + atomic DS writes, and added CS_TV_Tiled (0x5dc3b25986622949), CS_AlphaTransmissionDepthTileGenerationMip1 (0x5c6224a6bc3a4066), and CS_AlphaTransmissionDepthTileGenerationMip25 (0x9bdd33d77fb8ca0f) to idle_lds_reads.rs.
  • NIS linear HDR NaN (NIS_Scaler.h): Clamped the getY dot product inside sqrt(max(..., NVF(0.0f))) under NIS_HDR_MODE_LINEAR.
  • D3D12 copyback transitions (barriers.rs, copyback.rs): Added LAYOUT_DIRECT_UNORDERED_ACCESS / LAYOUT_DIRECT_SHADER_RESOURCE handling and emitted a Global SYNC_ALL -> SYNC_COPY (ACCESS_COMMON -> ACCESS_COMMON) barrier in copyback::behind when sources transition from COMMON.

2. Replacement Shader Fixes & Wave32 Optimizations

  • 07c93bfb (RT shadow): Added Wave32 cross-wave groupshared reductions for 8x8 tile hit ballots and min/max/sum stats, gated tile UAV writes to a single lane, and removed redundant barriers.
  • 2561af95 (LightAtlas sprites): Added finite-checked quad_uv_grad to execute QuadReadLaneAt under uniform control flow outside divergent branches.
  • 0f9382de, ca91c139, d5f6125b, f76abe01 (ScreenProbes): Replaced early returns before GroupMemoryBarrierWithGroupSync() with exited flags + neutral sentinels so every thread participates in trailing barriers without corrupting UAVs or wave ballots.
  • e4a9f58e, c4183d3c, b9688048, 1f1fbd86 (Decals & tiles): Clamped chained sqrt inputs against negative-zero rounding NaNs, guarded 1-based object index underflow, and replaced O(N²) LDS loops with wave intrinsics in 1f1fbd86.
  • 559d9f01, 002e93a6, 0e64f14f, 191ecaed (Shadow & tile RMW): Guarded +inf neighbor depth NaNs in 559d9f01 and serialized per-tile UAV read-modify-write races.

3. GPU, VRAM & Pipeline Optimizations (larp-gpu, larp-pipeline)

  • draw.rs: Keyed HostList::first_use per strides_buffer(), refined WHOLE throttle gating so secondary lists hold copies properly with bounded map pruning, moved per-draw Vec scratch (twins, viewed, kinds) onto Scratch, cached Picks spans/slots (FastMap + spans_cache), and replaced linear built.bytes.contains scans with a BYTES bitflag.
  • descriptor/host.rs: Added lock-free Acquire/Release fast hits in HostHeap::make_from, replaced Vec<bool> free search in dynamic/release with a 64-bit word bitset (trailing_zeros), batched COM retirements, and short-circuited no-op keep updates.
  • pipeline/{make,blobs,host}.rs, pipeline.rs, shader_cache.rs, larp-pipeline/cache.rs:
    • Accounted actual elapsed wait time in run_with_frame_budget (fixing multi-thread budget starvation) and deduplicated Queue::bump (with unit tests).
    • Indexed blobs/ in memory (ON_DISK) to eliminate repeated stat() syscalls during warming/writes.
    • Cached serialized root signatures, rect_list_gs bytecode, and quad_mask_stage (OnceLock); deferred COM CreateRootSignature / ID3D12Device2 QI and Plan::of allocation until after blobs::unless_on_disk prewarm checks.
    • Switched shader_cache::cached to incremental CacheKey::hasher + direct store/lookup without redundant .concat() allocations or miss read-backs.
  • host.rs, copyback/buffers.rs, slotfree.rs, allocators.rs, staging.rs, rt.rs, overlay/perf.rs, capture.rs, stall.rs, watch.rs:
    • Selected DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE adapter, bumped internal BUFFERS from 2 to 3 (all swap-chain consumers query dynamically), skipped redundant COPY_DEST present barrier when overlay is hidden, and gated diagnostics-only HostList::pipelines and CardClock background activity.
    • Added KEPT_COUNT fast skip and single-lock forget() in copyback/buffers.rs; added an unstamped cursor in slotfree.rs; capped idle allocators (MAX_FREE_PER_KIND = 64) and idle 16 MiB staging arenas (MAX_IDLE_ARENAS = 16).
    • Inserted intra-batch BLAS → TLAS UAV barrier and reused RecordScratch buffers in rt.rs; switched overlay/perf.rs percentile/median selection to O(N) select_nth_unstable_by; cached capture-folder check and LARP_STALL_S=0 fast path; pruned unguarded/freed/unclean entries and bounded found capacity in watch.rs.

4. HLE, RAM, DirectStorage, Audio, Input & Loader Optimizations

  • xmem.rs: Reclaimed freed physical page place slices once all mapped views unmap, switched non-alias allocations to SEC_RESERVE (committed on demand across CPU/GPU/VEH paths), and dropped PHYSICAL across title_memory_remapping while re-validating mapped spans.
  • dstorage.rs: Released staging right after decode when landing into Destination::Buffer, bypassed Head-of-Line stalls on tight staging budgets, reused thread-local scratch buffers, and reserved headroom in default_worker_count (with unit tests).
  • bcpack.rs, texture.rs, files.rs, apu.rs, audio.rs, dsp.rs, xma.rs: Reused thread-local/voice scratch buffers, eliminated modulo division in ConvolutionState::process, preserved XMA2 prior half-frame overlap on corrupt frames + stack-allocated IMDCT butterflies + lock-free Xma::pump inactive/drained slot skipping.
  • storage.rs, xasync.rs, xgamesave.rs: Cached storage used bytes with FindFirstChangeNotificationW change invalidation; consolidated delayed XTaskQueue submits onto a shared background Timer thread with pool wakeup accounting; moved xgamesave onto RwLock + targeted root migration + serialized background SaveWorker.
  • host.rs, theme.rs, gameinput/{sdl,playstation}.rs, settings/{menu,look,extra}.rs, tls_watch.rs, console_insn.rs, prompts/hook.rs: Dropped MODULES lock around LoadLibraryExA (preventing OS loader lock inversion), cached DWM dark-mode state, throttled SDL controller hotplug enumeration to 1 Hz + dirty-checked rumble, cached DualSense env lookup, added lock-free closed-menu fast path + OnceLock GDI/path caches, gated tls_watch behind opt-in LARP_TLS_WATCH=1, expanded console_insn VirtualQuery cache to 16 slots, and validated prompts/hook movies in-place before boxing.

5. Build, Subrender Safety & Documentation

  • apps/larp/build.rs: Parallelized DXC HLSL replacement compiles (both heap sizes) across up to 8 worker threads.
  • Cargo.toml: Added codegen-units = 1 under [profile.release] (keeping lto = "thin" and diagnostics logging compatibility).
  • apps/larp/src/subrender.rs: Added length/bounds guard before indexing dirty_words rows.
  • docs/environment-variables.md: Added Memory, Threading, Shaders & Caching documentation for --card-budget, LARP_ALIAS_SHARE, LARP_CORES, LARP_DSTORAGE_CACHE_GB, LARP_RT_WHOLE, LARP_SHADER_OPT, and LARP_SKIP_PIPELINES.

Verification

  • On the rebased d2a79dd tree: cargo check -p larp exited 0 with 0 errors and 0 warnings in any modified file lines.
  • Pre-rebase (at c36328d after final warning fix): cargo build --release -p larp exited 0 (compiling target/release/larp.exe and all 85 .dxil replacement shaders for both 1M and 2M view heaps via DXC).
  • Note: Full cargo test and runtime in-game testing were not executed after the edits and remain recommended during review/CI.
**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 00:18 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408) `ZerefDragnee1l:fix/water-black-squares-and-perf-optimizations` → `main` · +4376 −1743 · 68 files · 5 commits · closed without merging ## Summary This PR combines fixes for **black squares on water**, targeted **replacement compute shader correctness/performance fixes**, and broad **RAM, CPU, GPU, DirectStorage, audio, input, and build optimizations** rebased cleanly onto `main` (`d2a79dd`). - **68 files changed** across `shaders/replace/`, `crates/larp-shader`, `crates/larp-gpu`, `crates/larp-hle`, `crates/larp-formats`, `crates/larp-loader`, `crates/larp-game`, `crates/larp-pipeline`, `apps/larp`, `Cargo.toml`, and `docs/`. - **Pipeline PSO blob cache reuse is preserved:** On-disk PSO blob keys (`blobs::name`), `VICBLOB1` headers, and `pipeline_cache/blobs/` paths are unchanged, so existing host driver pipeline blobs continue to load from disk without recompilation (only shaders whose translated DXIL actually changes from the water/shader bugfixes generate new DXIL keys). --- ### 1. Water Black Squares Fixes Root causes identified across fog/transmission compute shaders, translator LDS synchronization, NIS linear HDR luminance, and D3D12 copyback transitions: - **Volumetric / water fog shaders (`6871d6e4`, `a10179ab`, `926c46ba`):** Guarded `log2(max(..., ...))`, filtered NaN/non-finite lanes before `WaveActiveSum` / `WaveActiveCountBits`, clamped `z`/`top` slice bounds and cluster lookup (`max(d514, 1u) - 1u`), sanitized `aS`/`aT` with HLSL-2021 `select()`, and gated `run_copy` LDS `InterlockedMin`/`InterlockedMax` on `go`. - **Bounds & scissor guards (`07fb4c72`, `d3c33084`):** Guarded `w > x && h > y` around mask evaluation / `InterlockedOr` in `07fb4c72` and clamped `fx1`/`fy1` in `d3c33084`. - **LDS hazard synchronization (`crates/larp-shader`):** Updated `lds_meetings` in `emit/lower.rs` to also synchronize overlapping plain (`ds_write*`) + atomic DS writes, and added `CS_TV_Tiled` (`0x5dc3b25986622949`), `CS_AlphaTransmissionDepthTileGenerationMip1` (`0x5c6224a6bc3a4066`), and `CS_AlphaTransmissionDepthTileGenerationMip25` (`0x9bdd33d77fb8ca0f`) to `idle_lds_reads.rs`. - **NIS linear HDR NaN (`NIS_Scaler.h`):** Clamped the `getY` dot product inside `sqrt(max(..., NVF(0.0f)))` under `NIS_HDR_MODE_LINEAR`. - **D3D12 copyback transitions (`barriers.rs`, `copyback.rs`):** Added `LAYOUT_DIRECT_UNORDERED_ACCESS` / `LAYOUT_DIRECT_SHADER_RESOURCE` handling and emitted a `Global` `SYNC_ALL -> SYNC_COPY` (`ACCESS_COMMON -> ACCESS_COMMON`) barrier in `copyback::behind` when sources transition from `COMMON`. ### 2. Replacement Shader Fixes & Wave32 Optimizations - **`07c93bfb` (RT shadow):** Added Wave32 cross-wave `groupshared` reductions for 8x8 tile hit ballots and min/max/sum stats, gated tile UAV writes to a single lane, and removed redundant barriers. - **`2561af95` (LightAtlas sprites):** Added finite-checked `quad_uv_grad` to execute `QuadReadLaneAt` under uniform control flow outside divergent branches. - **`0f9382de`, `ca91c139`, `d5f6125b`, `f76abe01` (ScreenProbes):** Replaced early `return`s before `GroupMemoryBarrierWithGroupSync()` with `exited` flags + neutral sentinels so every thread participates in trailing barriers without corrupting UAVs or wave ballots. - **`e4a9f58e`, `c4183d3c`, `b9688048`, `1f1fbd86` (Decals & tiles):** Clamped chained `sqrt` inputs against negative-zero rounding NaNs, guarded 1-based object index underflow, and replaced O(N²) LDS loops with wave intrinsics in `1f1fbd86`. - **`559d9f01`, `002e93a6`, `0e64f14f`, `191ecaed` (Shadow & tile RMW):** Guarded `+inf` neighbor depth NaNs in `559d9f01` and serialized per-tile UAV read-modify-write races. ### 3. GPU, VRAM & Pipeline Optimizations (`larp-gpu`, `larp-pipeline`) - **`draw.rs`:** Keyed `HostList::first_use` per `strides_buffer()`, refined `WHOLE` throttle gating so secondary lists hold copies properly with bounded map pruning, moved per-draw `Vec` scratch (`twins`, `viewed`, `kinds`) onto `Scratch`, cached `Picks` spans/slots (`FastMap` + `spans_cache`), and replaced linear `built.bytes.contains` scans with a `BYTES` bitflag. - **`descriptor/host.rs`:** Added lock-free Acquire/Release fast hits in `HostHeap::make_from`, replaced `Vec<bool>` free search in `dynamic`/`release` with a 64-bit word bitset (`trailing_zeros`), batched COM retirements, and short-circuited no-op `keep` updates. - **`pipeline/{make,blobs,host}.rs`, `pipeline.rs`, `shader_cache.rs`, `larp-pipeline/cache.rs`:** - Accounted actual elapsed wait time in `run_with_frame_budget` (fixing multi-thread budget starvation) and deduplicated `Queue::bump` (with unit tests). - Indexed `blobs/` in memory (`ON_DISK`) to eliminate repeated `stat()` syscalls during warming/writes. - Cached serialized root signatures, `rect_list_gs` bytecode, and `quad_mask_stage` (`OnceLock`); deferred COM `CreateRootSignature` / `ID3D12Device2` QI and `Plan::of` allocation until after `blobs::unless_on_disk` prewarm checks. - Switched `shader_cache::cached` to incremental `CacheKey::hasher` + direct `store`/`lookup` without redundant `.concat()` allocations or miss read-backs. - **`host.rs`, `copyback/buffers.rs`, `slotfree.rs`, `allocators.rs`, `staging.rs`, `rt.rs`, `overlay/perf.rs`, `capture.rs`, `stall.rs`, `watch.rs`:** - Selected `DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE` adapter, bumped internal `BUFFERS` from 2 to 3 (all swap-chain consumers query dynamically), skipped redundant `COPY_DEST` present barrier when overlay is hidden, and gated diagnostics-only `HostList::pipelines` and `CardClock` background activity. - Added `KEPT_COUNT` fast skip and single-lock `forget()` in `copyback/buffers.rs`; added an `unstamped` cursor in `slotfree.rs`; capped idle allocators (`MAX_FREE_PER_KIND = 64`) and idle 16 MiB staging arenas (`MAX_IDLE_ARENAS = 16`). - Inserted intra-batch BLAS → TLAS UAV barrier and reused `RecordScratch` buffers in `rt.rs`; switched `overlay/perf.rs` percentile/median selection to O(N) `select_nth_unstable_by`; cached capture-folder check and `LARP_STALL_S=0` fast path; pruned unguarded/freed/unclean entries and bounded `found` capacity in `watch.rs`. ### 4. HLE, RAM, DirectStorage, Audio, Input & Loader Optimizations - **`xmem.rs`:** Reclaimed freed physical page place slices once all mapped views unmap, switched non-alias allocations to `SEC_RESERVE` (committed on demand across CPU/GPU/VEH paths), and dropped `PHYSICAL` across `title_memory_remapping` while re-validating mapped spans. - **`dstorage.rs`:** Released staging right after decode when landing into `Destination::Buffer`, bypassed Head-of-Line stalls on tight staging budgets, reused thread-local scratch buffers, and reserved headroom in `default_worker_count` (with unit tests). - **`bcpack.rs`, `texture.rs`, `files.rs`, `apu.rs`, `audio.rs`, `dsp.rs`, `xma.rs`:** Reused thread-local/voice scratch buffers, eliminated modulo division in `ConvolutionState::process`, preserved XMA2 prior half-frame overlap on corrupt frames + stack-allocated IMDCT butterflies + lock-free `Xma::pump` inactive/drained slot skipping. - **`storage.rs`, `xasync.rs`, `xgamesave.rs`:** Cached `storage` used bytes with `FindFirstChangeNotificationW` change invalidation; consolidated delayed `XTaskQueue` submits onto a shared background `Timer` thread with pool wakeup accounting; moved `xgamesave` onto `RwLock` + targeted root migration + serialized background `SaveWorker`. - **`host.rs`, `theme.rs`, `gameinput/{sdl,playstation}.rs`, `settings/{menu,look,extra}.rs`, `tls_watch.rs`, `console_insn.rs`, `prompts/hook.rs`:** Dropped `MODULES` lock around `LoadLibraryExA` (preventing OS loader lock inversion), cached DWM dark-mode state, throttled SDL controller hotplug enumeration to 1 Hz + dirty-checked rumble, cached DualSense env lookup, added lock-free closed-menu fast path + `OnceLock` GDI/path caches, gated `tls_watch` behind opt-in `LARP_TLS_WATCH=1`, expanded `console_insn` `VirtualQuery` cache to 16 slots, and validated `prompts/hook` movies in-place before boxing. ### 5. Build, Subrender Safety & Documentation - **`apps/larp/build.rs`:** Parallelized DXC HLSL replacement compiles (both heap sizes) across up to 8 worker threads. - **`Cargo.toml`:** Added `codegen-units = 1` under `[profile.release]` (keeping `lto = "thin"` and `diagnostics` logging compatibility). - **`apps/larp/src/subrender.rs`:** Added length/bounds guard before indexing `dirty_words` rows. - **`docs/environment-variables.md`:** Added `Memory, Threading, Shaders & Caching` documentation for `--card-budget`, `LARP_ALIAS_SHARE`, `LARP_CORES`, `LARP_DSTORAGE_CACHE_GB`, `LARP_RT_WHOLE`, `LARP_SHADER_OPT`, and `LARP_SKIP_PIPELINES`. --- ### Verification - **On the rebased `d2a79dd` tree:** `cargo check -p larp` exited `0` with 0 errors and 0 warnings in any modified file lines. - **Pre-rebase (at `c36328d` after final warning fix):** `cargo build --release -p larp` exited `0` (compiling `target/release/larp.exe` and all 85 `.dxil` replacement shaders for both 1M and 2M view heaps via DXC). - Note: Full `cargo test` and runtime in-game testing were not executed after the edits and remain recommended during review/CI.
Prevent NaN propagation, out-of-bounds mask/scissor reads, LDS races, and missing copyback barriers responsible for black squares on water:
- Guard log2 inputs, WaveActive* NaN lane contamination, out-of-range cluster/slice indices, and LDS min/max election in volumetric/water fog shaders (6871d6e4, a10179ab, 926c46ba).
- Clamp bounds/dimensions in 07fb4c72 and d3c33084 before mask updates.
- Track plain ds_write* + atomic LDS writes in larp-shader lds_meetings (lower.rs) and add 3 water/alpha-transmission hashes to idle_lds_reads.rs.
- Clamp NIS_Scaler.h linear HDR luminance dot product inside sqrt().
- Add LAYOUT_DIRECT_UNORDERED_ACCESS/SHADER_RESOURCE transitions and COMMON copyback global sync barrier in barriers.rs and copyback.rs.
Fix wave-size, control-flow, NaN, and UAV RMW race bugs across replacement compute shaders:
- 07c93bfb: Add Wave32 cross-wave groupshared reductions for 8x8 tile ballots and min/max/sum, guard single-lane tile UAV writes, and remove redundant barriers.
- 2561af95: Hoist QuadReadLaneAt calls under uniform control flow via finite-checked quad_uv_grad.
- ScreenProbes (0f9382de, ca91c139, d5f6125b, f76abe01): Replace early return before GroupMemoryBarrierWithGroupSync with sentinel/exited flags so all lanes hit trailing barriers cleanly.
- Decals & tiles (e4a9f58e, c4183d3c, b9688048, 1f1fbd86): Clamp chained sqrt() inputs, guard 1-based object index underflow, and replace O(N^2) LDS scans with wave intrinsics.
- Shadow & tile RMW (559d9f01, 002e93a6, 0e64f14f, 191ecaed): Guard +inf depth neighbor NaNs in 559d9f01 and serialize per-tile UAV read-modify-write races.
Reduce CPU draw recording overhead, lock contention, allocation churn, and VRAM growth across larp-gpu & larp-pipeline:
- draw.rs: Key HostList::first_use per strides_buffer, refine WHOLE copy gating & secondary list holds, reuse Scratch vecs, cache Picks spans/slots, and replace bytes.contains with BYTES bitflag.
- descriptor/host.rs: Add lock-free Acquire/Release fast-hit path in make_from, 64-bit word bitset allocator in dynamic/release, batched COM retires, and no-op keep guard.
- pipeline/{make,blobs,host}.rs, pipeline.rs, shader_cache.rs, larp-pipeline/cache.rs: Fix concurrent frame wait budget accounting & dedupe Queue::bump; cache on-disk blob index; cache serialized root signatures, rect GS & quad mask stages and defer COM creation/Plan past on-disk prewarm skips; stream incremental BLAKE3 hashing in shader_cache without changing on-disk PSO blob keys/format.
- host.rs, copyback/buffers.rs, slotfree.rs, allocators.rs, staging.rs, rt.rs, overlay/perf.rs, capture.rs, stall.rs, watch.rs: Prefer high-perf GPU adapter & triple buffering, gate diagnostics-only fields/CardClock, skip empty KEPT locks, use unstamped cursor in slotfree, cap idle allocators (64) and staging arenas (16), add RT BLAS->TLAS UAV barrier + scratch reuse, use O(N) select_nth_unstable_by in perf overlay, fast-path disabled capture/stall, and prune write-watch journal.
Reduce RAM usage, streaming stalls, audio/format scratch allocations, and lock contention in HLE, formats, prompts, and loader:
- xmem.rs: Recycle freed page place slices safely after last unmap, switch non-alias allocations to SEC_RESERVE on demand, and drop PHYSICAL mutex across title_memory_remapping.
- dstorage.rs: Avoid Head-of-Line queue stalls on tight staging budget, release staging before mip landing, reuse thread-local scratch buffers, and leave headroom in default worker count.
- bcpack.rs, texture.rs, files.rs, apu.rs, audio.rs, dsp.rs, xma.rs: Reuse thread-local/voice scratch buffers, remove inner FFT/ring modulo division, preserve XMA2 overlap half-frame on bad frames, speed up bitreader/IMDCT butterflies, and skip idle Xma::pump slots lock-free.
- storage.rs, xasync.rs, xgamesave.rs: Cache storage used_bytes with Win32 directory change notifications, coalesce delayed XAsync tasks onto a shared Timer thread + pool wakeup tracking, and use RwLock + background SaveWorker in xgamesave.
- host.rs, theme.rs, gameinput/{sdl,playstation}.rs, settings/{menu,look,extra}.rs, tls_watch.rs, console_insn.rs, prompts/hook.rs: Drop MODULES lock across LoadLibraryExA, cache DWM dark-mode state, throttle SDL plug polling to 1 Hz + dirty-checked rumble, cache DualSense trigger env, add lock-free closed-menu fast path & OnceLock GDI/path caches, make TLS watch opt-in (LARP_TLS_WATCH=1), expand VirtualQuery cache to 16 slots, and validate prompts/hook movies in-place before boxing.
Build, subrender safety, and documentation improvements:
- apps/larp/build.rs: Compile pending HLSL replacement jobs (both heap sizes) in parallel across up to 8 worker threads.
- Cargo.toml: Set codegen-units = 1 in [profile.release] (retaining lto = "thin" and diagnostics tracing compatibility).
- apps/larp/src/subrender.rs: Guard dirty_words row length and bounds before indexing.
- docs/environment-variables.md: Document --card-budget, LARP_ALIAS_SHARE, LARP_CORES, LARP_DSTORAGE_CACHE_GB, LARP_RT_WHOLE, LARP_SHADER_OPT, and LARP_SKIP_PIPELINES.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 00:26:54 +00:00
Author
Owner

@⁠Narcotic-oa on GitHub · 2026-12-06 00:21 UTC · original

u r the man , u r killing it bro

**@⁠Narcotic-oa** on GitHub · 2026-12-06 00:21 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448290057) u r the man , u r killing it bro
Author
Owner

@⁠Heliumrich on GitHub · 2026-12-06 00:22 UTC · original

I doubt a PR this large (+5k lines of codes), that does multiple completely different things, will get merged as is.
Pretty sure you'll have to split it into multiple parts and make multiple PRs

**@⁠Heliumrich** on GitHub · 2026-12-06 00:22 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448316894) I doubt a PR this large (+5k lines of codes), that does multiple completely different things, will get merged as is. Pretty sure you'll have to split it into multiple parts and make multiple PRs
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 00:23 UTC · original

I doubt a PR this large (+5k lines of codes), that does multiple completely different things, will get merged as is. Pretty sure you'll have to split it into multiple parts and make multiple PRs

yeah ik i'll do it, have lots of prs

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 00:23 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448327464) > I doubt a PR this large (+5k lines of codes), that does multiple completely different things, will get merged as is. Pretty sure you'll have to split it into multiple parts and make multiple PRs yeah ik i'll do it, have lots of prs
Author
Owner

@⁠erdtreefaithful on GitHub · 2026-12-06 00:33 UTC · original

Yeah, even for the most powerful LLM, reviewing something like this would be tough - and I personally wouldn’t feel comfortable merging it without spending an hour or two playing the game. But changes sound good ngl

**@⁠erdtreefaithful** on GitHub · 2026-12-06 00:33 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448469290) Yeah, even for the most powerful LLM, reviewing something like this would be tough - and I personally wouldn’t feel comfortable merging it without spending an hour or two playing the game. But changes sound good ngl
Author
Owner

@⁠erdtreefaithful on GitHub · 2026-12-06 00:35 UTC · original

We need to find and fix that freeze with 0 gpu usage drop asap tho.

**@⁠erdtreefaithful** on GitHub · 2026-12-06 00:35 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448486603) We need to find and fix that freeze with 0 gpu usage drop asap tho.
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 00:35 UTC · original

We need to find and fix that freeze with 0 gpu usage drop asap tho.

yep yep working on that

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 00:35 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448490512) > We need to find and fix that freeze with 0 gpu usage drop asap tho. yep yep working on that
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 00:36 UTC · original

now im gonna split the pr.

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 00:36 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448510021) now im gonna split the pr.
Author
Owner

@⁠erdtreefaithful on GitHub · 2026-12-06 00:38 UTC · original

We need to find and fix that freeze with 0 gpu usage drop asap tho.

yep yep working on that

Thats dope, im gonna take a look at it after testing new version too, we dont wanna mess up the build. I mean once that freeze is gone, the game is basically playable with rt on high endish hardware

**@⁠erdtreefaithful** on GitHub · 2026-12-06 00:38 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448534414) > > We need to find and fix that freeze with 0 gpu usage drop asap tho. > > yep yep working on that Thats dope, im gonna take a look at it after testing new version too, we dont wanna mess up the build. I mean once that freeze is gone, the game is basically playable with rt on high endish hardware
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 00:39 UTC · original

One interaction worth checking while splitting this PR: the new build path starts up to 8 DXC processes concurrently. Issue #249 reports that compiling 191ecaed66eea3b1.compute.hlsl with -O1/-O3 can exhaust host system memory; my separate PR #421 applies -Od only to that shader and leaves -O3 on the rest.

The parallel build may amplify peak memory pressure across several compiler processes, even with that per-shader exception. It may be worth validating the worker count on lower-RAM machines or keeping the reported heavy shader serialized/bounded when you split the build-system changes. I haven't benchmarked the parallel path or measured its peak memory, so this is a risk to test rather than a confirmed regression.

**@⁠vanya890** on GitHub · 2026-12-06 00:39 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448541623) One interaction worth checking while splitting this PR: the new build path starts up to 8 DXC processes concurrently. Issue #249 reports that compiling `191ecaed66eea3b1.compute.hlsl` with `-O1`/`-O3` can exhaust host system memory; my separate [PR #421](https://git.gtahub.st/github/gamingwithhomie--larp/pulls/421) applies `-Od` only to that shader and leaves `-O3` on the rest. The parallel build may amplify peak memory pressure across several compiler processes, even with that per-shader exception. It may be worth validating the worker count on lower-RAM machines or keeping the reported heavy shader serialized/bounded when you split the build-system changes. I haven't benchmarked the parallel path or measured its peak memory, so this is a risk to test rather than a confirmed regression.
Author
Owner

@⁠Narcotic-oa on GitHub · 2026-12-06 00:40 UTC · original

u deserve a nobel prize

**@⁠Narcotic-oa** on GitHub · 2026-12-06 00:40 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448554819) u deserve a nobel prize
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 00:41 UTC · original

One interaction worth checking while splitting this PR: the new build path starts up to 8 DXC processes concurrently. Issue #249 reports that compiling 191ecaed66eea3b1.compute.hlsl with -O1/-O3 can exhaust host system memory; my separate PR #421 applies -Od only to that shader and leaves -O3 on the rest.

The parallel build may amplify peak memory pressure across several compiler processes, even with that per-shader exception. It may be worth validating the worker count on lower-RAM machines or keeping the reported heavy shader serialized/bounded when you split the build-system changes. I haven't benchmarked the parallel path or measured its peak memory, so this is a risk to test rather than a confirmed regression.

thanks. noted that

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 00:41 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7448563969) > One interaction worth checking while splitting this PR: the new build path starts up to 8 DXC processes concurrently. Issue #249 reports that compiling `191ecaed66eea3b1.compute.hlsl` with `-O1`/`-O3` can exhaust host system memory; my separate [PR #421](https://git.gtahub.st/github/gamingwithhomie--larp/pulls/421) applies `-Od` only to that shader and leaves `-O3` on the rest. > > The parallel build may amplify peak memory pressure across several compiler processes, even with that per-shader exception. It may be worth validating the worker count on lower-RAM machines or keeping the reported heavy shader serialized/bounded when you split the build-system changes. I haven't benchmarked the parallel path or measured its peak memory, so this is a risk to test rather than a confirmed regression. thanks. noted that
Author
Owner

@⁠Heliumrich on GitHub · 2026-12-06 01:14 UTC · original

Played for +30 min and works really well, lighting and graphics are really better.
I do disable the game TAA when using DLSS, otherwise it looks blurry AF (weird this project doesn't force game TAA/FSR4 off when DLSS is on...)

specular reflections are still kinda boiling but afaik it's just how the game is. I haven't felt increasing the ingame hidden settings changing anything on this regard.

**@⁠Heliumrich** on GitHub · 2026-12-06 01:14 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7449017483) Played for +30 min and works really well, lighting and graphics are really better. I do disable the game TAA when using DLSS, otherwise it looks blurry AF (weird this project doesn't force game TAA/FSR4 off when DLSS is on...) specular reflections are still kinda boiling but afaik it's just how the game is. I haven't felt increasing the ingame hidden settings changing anything on this regard.
Author
Owner

@⁠justihsann on GitHub · 2026-12-06 01:22 UTC · original

nasıl indireceğim

**@⁠justihsann** on GitHub · 2026-12-06 01:22 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7449135484) nasıl indireceğim
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:26 UTC · original

Played for +30 min and works really well, lighting and graphics are really better. I do disable the game TAA when using DLSS, otherwise it looks blurry AF (weird this project doesn't force game TAA/FSR4 off when DLSS is on...)

specular reflections are still kinda boiling but afaik it's just how the game is. I haven't felt increasing the ingame hidden settings changing anything on this regard.

thanks. i'll do more.

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:26 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7449185936) > Played for +30 min and works really well, lighting and graphics are really better. I do disable the game TAA when using DLSS, otherwise it looks blurry AF (weird this project doesn't force game TAA/FSR4 off when DLSS is on...) > > specular reflections are still kinda boiling but afaik it's just how the game is. I haven't felt increasing the ingame hidden settings changing anything on this regard. thanks. i'll do more.
Author
Owner

@⁠erdtreefaithful on GitHub · 2026-12-06 01:35 UTC · original

Im gonna do some diag now on 1.1.6 with wpr, try to capture fucker

**@⁠erdtreefaithful** on GitHub · 2026-12-06 01:35 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7449296818) Im gonna do some diag now on 1.1.6 with wpr, try to capture fucker
github-bot closed this pull request 2026-12-06 02:01:47 +00:00
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:56 UTC · original

Closing this monolithic PR in favor of focused, individually reviewable PRs against main:

  1. #444 — Series S upscaler mode 7 fallback & FSR/DLSS auto-detect (#281), with map_upscaler_mode() unit test.
  2. #447 — Proton/vkd3d alignment, RTV/copy-barrier & texevents.rs read_late() queue accounting (#250), with read_late regression test.
  3. #452 (merged) — Skip 191ecaed66eea3b1 replacement on NVIDIA 616.x to avoid compiler OOM (#249).
  4. #455 — AMD RDNA2 root/VB/IB/raw-view bounds, RT scratch barriers & wide dispatch limits (#288, #280; with scope clarification regarding #379).
  5. #457 — Shader cbufferLoadLegacy 4095 clamp + constant-row folding, Wave64 hosts, lds_meetings mixed plain/atomic write barriers, and water idle_lds_reads + CPU regression tests.
  6. #481 — Cached pipeline loading speedups (blobs-index.bin fail-open warm startup, zero cache invalidation) + codec and caller-level fail-open tests.
  7. #518 — Bypass game built-in TAA (taa=0) when an external upscaler (DLSS/FSR/DittoSR) is active (LARP_KEEP_GAME_TAA=1 opt-out).
  8. #519 — Water black-squares fog/mask shaders, NIS_Scaler.h clamp, and D3D12 copyback/barrier fixes.
  9. #521 — Replacement compute shaders Wave32 reductions, QuadReadLaneAt control-flow, ScreenProbes barriers, decal NaNs, and tile RMW fixes.
  10. #525 — Non-pipeline GPU hot-path optimizations, descriptor bitset, write-watch pruning fix, and allocator/staging pool caps.
  11. #526 — HLE (xmem, dstorage, audio, xgamesave, xasync, input, settings, loader, prompts) optimizations.
  12. #531 — Bounded parallel DXC builds (serializing >150 KiB shaders like 191ecaed66eea3b1 per @⁠vanya890 / #249), subrender bounds guard, LARP_LICENSES, automatic Windows NVIDIA shader heap (LARP_NO_AUTO_NVPROFILE=1), and env docs.
**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:56 UTC · [original](https://github.com/gamingwithhomie/larp/pull/408#issuecomment-7449571339) Closing this monolithic PR in favor of focused, individually reviewable PRs against `main`: 1. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/444 — Series S upscaler mode 7 fallback & FSR/DLSS auto-detect (#281), with `map_upscaler_mode()` unit test. 2. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/447 — Proton/vkd3d alignment, RTV/copy-barrier & `texevents.rs` `read_late()` queue accounting (#250), with `read_late` regression test. 3. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/452 (**merged**) — Skip `191ecaed66eea3b1` replacement on NVIDIA 616.x to avoid compiler OOM (#249). 4. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/455 — AMD RDNA2 root/VB/IB/raw-view bounds, RT scratch barriers & wide dispatch limits (#288, #280; with scope clarification regarding #379). 5. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/457 — Shader `cbufferLoadLegacy` 4095 clamp + constant-row folding, Wave64 hosts, `lds_meetings` mixed plain/atomic write barriers, and water `idle_lds_reads` + CPU regression tests. 6. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/481 — Cached pipeline loading speedups (`blobs-index.bin` fail-open warm startup, zero cache invalidation) + codec and caller-level fail-open tests. 7. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/518 — Bypass game built-in TAA (`taa=0`) when an external upscaler (DLSS/FSR/DittoSR) is active (`LARP_KEEP_GAME_TAA=1` opt-out). 8. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/519 — Water black-squares fog/mask shaders, `NIS_Scaler.h` clamp, and D3D12 copyback/barrier fixes. 9. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/521 — Replacement compute shaders Wave32 reductions, `QuadReadLaneAt` control-flow, ScreenProbes barriers, decal NaNs, and tile RMW fixes. 10. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/525 — Non-pipeline GPU hot-path optimizations, descriptor bitset, write-watch pruning fix, and allocator/staging pool caps. 11. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/526 — HLE (`xmem`, `dstorage`, `audio`, `xgamesave`, `xasync`, input, settings, loader, prompts) optimizations. 12. https://git.gtahub.st/github/gamingwithhomie--larp/pulls/531 — Bounded parallel DXC builds (serializing `>150 KiB` shaders like `191ecaed66eea3b1` per @⁠vanya890 / #249), `subrender` bounds guard, `LARP_LICENSES`, automatic Windows NVIDIA shader heap (`LARP_NO_AUTO_NVPROFILE=1`), and env docs.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.