Skip to content

Add interactive occlusion + WINDOW_HIDDEN throttle test to TrinityALTest - #35

Open
Schogol wants to merge 5 commits into
carbonengine:mainfrom
Schogol:test/occlusion-throttle-probe
Open

Schogol wants to merge 5 commits into
carbonengine:mainfrom
Schogol:test/occlusion-throttle-probe

Conversation

@Schogol

@Schogol Schogol commented Jul 25, 2026

Copy link
Copy Markdown

SwapChain.OcclusionThrottleProbe presents the primary swapchain to the visible test window in a loop and logs loop-fps vs actual render-fps per window state. It detects occlusion from window geometry (IsWindowOccluded: sample 5 points on the window, skipping see-through overlays like the Alt+Tab switcher; minimized counts as hidden) and, while occluded, emulates the WINDOW_HIDDEN throttle (20ms sleep + render 1-in-50) to show rendering collapse to ~1 fps and recover when visible.

Manual/interactive (needs a real GPU + visible window), run with:
--interactive --gtest_filter=SwapChain.OcclusionThrottleProbe
then cover / minimize / restore the window and read occlusion_throttle_test.log.

Used to establish that DXGI_STATUS_OCCLUDED is unavailable for flip-model swapchains (both Present and Present(0, DXGI_PRESENT_TEST) stay S_OK while covered) and that Win32 window-geometry occlusion is a reliable substitute.

Disclaimer:
Claude helped with creating the test and fix.

berkeleynerd pushed a commit to berkeleynerd/trinity that referenced this pull request Aug 9, 2026
)

Co-authored-by: rebecca <1+rebecca@noreply.localhost>
@CCP-Cortege

Copy link
Copy Markdown
Member

Thanks for opening this, and welcome. We've seen it and one of our engineers will take a look soon. We appreciate you taking the time to contribute, and we'll follow up here once someone has had a chance to review. Thanks for your patience in the meantime.

SwapChain.OcclusionThrottleProbe presents the primary swapchain to the visible
test window in a loop and logs loop-fps vs actual render-fps per window state. It
detects occlusion from window geometry (IsWindowOccluded: sample 5 points on the
window, skipping see-through overlays like the Alt+Tab switcher; minimized counts
as hidden) and, while occluded, emulates the WINDOW_HIDDEN throttle (20ms sleep +
render 1-in-50) to show rendering collapse to ~1 fps and recover when visible.

Manual/interactive (needs a real GPU + visible window), run with:
  --interactive --gtest_filter=SwapChain.OcclusionThrottleProbe
then cover / minimize / restore the window and read occlusion_throttle_test.log.

Used to establish that DXGI_STATUS_OCCLUDED is unavailable for flip-model
swapchains (both Present and Present(0, DXGI_PRESENT_TEST) stay S_OK while
covered) and that Win32 window-geometry occlusion is a reliable substitute.
Match the revised Tr2MainWindow detection exactly: 8 quasirandom sample
points per 250ms tick from the R2 (plastic ratio) sequence, hidden only
after 32 consecutive covered samples, one EnumWindows pass per tick
collecting the opaque occluder rects above us in Z-order, DWM-cloaked
windows skipped, off-monitor points counted as covered.

Log state transitions with time-in-state and the covered-sample counter,
and add a samples= column to the periodic fps lines, so engage latency
(~1s covered) and next-tick release are visible in the log.
- Open the log with _fsopen(_SH_DENYWR) instead of fopen_s, which denies
  all sharing; the log can now be read and tailed during a run.
- The window class uses DefWindowProc, so the close button destroys the
  HWND without posting WM_QUIT and the loop previously spun on forever
  (a destroyed window samples as "visible" and unthrottled, at ~30000
  fps). Detect the destroyed window, log it, and post WM_QUIT so
  DoLoopProcessing ends the RunLoop.
@Schogol
Schogol force-pushed the test/occlusion-throttle-probe branch from 48fd742 to 64e3bab Compare October 11, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants