GPU: add opt-in host D3D12 occlusion queries (VICTORY_REAL_OCCLUSION=1) #167

Closed
github-bot wants to merge 2 commits from github-bot/gh-167 into main AGit
Owner

@⁠HailLucifer666 on GitHub · 2026-11-24 22:06 UTC · original
HailLucifer666:perf/real-occlusion-queries → main · +295 −16 · 2 files · 2 commits · closed without merging

Problem

  • BeginQuery and EndQuery are no-ops and ResolveQueryData always writes synthetic visible counts (1 << 20 for OCCLUSION, 1 for BINARY_OCCLUSION), preventing the title from occlusion-culling hidden geometry.

Fix

  • Behind opt-in VICTORY_REAL_OCCLUSION=1 (off by default, matching other experimental switches):
    • Create a host ID3D12QueryHeap (D3D12_QUERY_HEAP_TYPE_OCCLUSION) in query.rs.
    • Forward BeginQuery and EndQuery for OCCLUSION (0) and BINARY_OCCLUSION (1) in list.rs.
    • Resolve directly into the destination Shadow buffer with refresh() + gpu_writes() copy-back tracking and checked bounds.

Verification

  • Added unit tests resolve_range_valid_rejects_empty_and_overflow and occlusion_query_type_maps_only_occlusion_kinds.
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test -p victory-gpu query::tests --locked (2/2 passed)
  • cargo test -p xtask --locked (4/4 passed)
**@⁠HailLucifer666** on GitHub · 2026-11-24 22:06 UTC · [original](https://github.com/fxceless/victory-fork/pull/167) `HailLucifer666:perf/real-occlusion-queries` → `main` · +295 −16 · 2 files · 2 commits · closed without merging ### Problem - `BeginQuery` and `EndQuery` are no-ops and `ResolveQueryData` always writes synthetic visible counts (`1 << 20` for `OCCLUSION`, `1` for `BINARY_OCCLUSION`), preventing the title from occlusion-culling hidden geometry. ### Fix - Behind opt-in `VICTORY_REAL_OCCLUSION=1` (off by default, matching other experimental switches): - Create a host `ID3D12QueryHeap` (`D3D12_QUERY_HEAP_TYPE_OCCLUSION`) in `query.rs`. - Forward `BeginQuery` and `EndQuery` for `OCCLUSION` (0) and `BINARY_OCCLUSION` (1) in `list.rs`. - Resolve directly into the destination `Shadow` buffer with `refresh()` + `gpu_writes()` copy-back tracking and checked bounds. ### Verification - Added unit tests `resolve_range_valid_rejects_empty_and_overflow` and `occlusion_query_type_maps_only_occlusion_kinds`. - `cargo clippy --workspace --all-targets --locked -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo test -p victory-gpu query::tests --locked` (2/2 passed) - `cargo test -p xtask --locked` (4/4 passed)
THE BUG.
BeginQuery and EndQuery were empty no-ops and ResolveQueryData always returned synthetic visible counts (1 << 20 for OCCLUSION, 1 for BINARY_OCCLUSION), preventing the title from occlusion-culling hidden geometry.

WHY NOT HYPOTHETICAL.
Returning 1,048,576 passed samples for every occlusion query forces the title to keep drawing occluded world geometry every frame.

THE FIX.
Behind VICTORY_REAL_OCCLUSION=1 (off by default to match fork rollout switches), create a host ID3D12QueryHeap for occlusion heaps in query.rs, forward BeginQuery/EndQuery for OCCLUSION and BINARY_OCCLUSION in list.rs, and resolve directly into the destination Shadow buffer with refresh/gpu_writes copy-back tracking and checked bounds.

SCOPE.
Only occlusion (0) and binary occlusion (1) queries behind VICTORY_REAL_OCCLUSION=1. Timestamps, pipeline statistics, and default behavior when the switch is unset are unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:26 +00:00
github-bot force-pushed github-bot/gh-167 from 23e576b5dd to c14d27fb88 2026-11-26 14:31:47 +00:00 Compare
Author
Owner

@⁠HailLucifer666 on GitHub · 2026-11-26 14:28 UTC · original

Rebased onto main a20809de; head is now c14d27fb (no conflicts). Verified: victory-gpu occlusion:: 2 passed, 0 failed (the WARP occlusion test included); clippy -D warnings on victory-gpu clean. Still opt-in (VICTORY_REAL_OCCLUSION=1), as the description says.

**@⁠HailLucifer666** on GitHub · 2026-11-26 14:28 UTC · [original](https://github.com/fxceless/victory-fork/pull/167#issuecomment-7194869941) Rebased onto `main` `a20809de`; head is now `c14d27fb` (no conflicts). Verified: `victory-gpu occlusion::` 2 passed, 0 failed (the WARP occlusion test included); `clippy -D warnings` on victory-gpu clean. Still opt-in (`VICTORY_REAL_OCCLUSION=1`), as the description says.
github-bot closed this pull request 2026-11-26 14:37:19 +00:00
Author
Owner

@⁠HailLucifer666 on GitHub · 2026-11-26 14:33 UTC · original

Superseded by 58de9bf4 on main, which lands host-GPU occlusion queries as VICTORY_OCCLUSION=1|alt (after upstream #3138): the query heap, BeginQuery/EndQuery on the host, and results resolved from it. That is the feature this PR proposed as VICTORY_REAL_OCCLUSION=1, written against the current list.rs/query.rs (the same files this branch edits, hence the conflict). Closing as already implemented rather than rebasing a duplicate. One piece may still be worth porting separately: this branch had a WARP test that resolves a host occlusion query into a COPY_DEST shadow buffer; if the landed implementation has no equivalent, it can be offered as a small test-only follow-up.

**@⁠HailLucifer666** on GitHub · 2026-11-26 14:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/167#issuecomment-7194980130) Superseded by `58de9bf4` on `main`, which lands host-GPU occlusion queries as `VICTORY_OCCLUSION=1|alt` (after upstream #3138): the query heap, `BeginQuery`/`EndQuery` on the host, and results resolved from it. That is the feature this PR proposed as `VICTORY_REAL_OCCLUSION=1`, written against the current `list.rs`/`query.rs` (the same files this branch edits, hence the conflict). Closing as already implemented rather than rebasing a duplicate. One piece may still be worth porting separately: this branch had a WARP test that resolves a host occlusion query into a COPY_DEST shadow buffer; if the landed implementation has no equivalent, it can be offered as a small test-only follow-up.

Pull request closed

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