Skip to content

window: offscreen captures keep the requested size under an OS clamp - #5186

Merged
jakildev merged 1 commit into
masterfrom
claude/4852-gl-offscreen-request-size
Nov 19, 2026
Merged

jakildev merged 1 commit into
masterfrom
claude/4852-gl-offscreen-request-size

Conversation

@jakildev

Copy link
Copy Markdown
Owner

Summary

In offscreen mode the engine now owns the capture size. IRGLFWWindow keeps the requested extent and a framebuffer/window ratio it measures at creation, so a Windows/OpenGL capture whose request exceeds the desktop work area renders at the requested size instead of the OS-clamped one (2560×1440, not 2560×1421). IRWindow::setWindowSize is the resize path; in offscreen it resizes the screen target synchronously. A GL target beyond the driver limits ends the run non-zero, and a presented mode the OS clamped logs a WARN naming both sizes.

Screenshots

No visual change at master's configs: render-verify on IRShapeDebug and IRCanvasStress shows the same pass/fail rows as a same-session master control (table below).

Acceptance evidence

Criterion Check run Observed
1. Offscreen 2560×1440 request, Windows fleet-run IRCanvasStress --config-preset <init_window 2560×1440, game 1280×720> --auto-screenshot 10 The OS clamped the hidden window to 2560x1421; the offscreen surface keeps the requested 2560x1440., then OpenGL offscreen screen target attached (2560x1440). 12/12 PNGs have IHDR 2560×1440. RESULT=CLEAN
1. Master control same command, master 44955ae9f screen target attached (2560x1421), 12/12 PNGs 2560×1421
2a. Hidden mode keeps the OS surface, with a WARN same preset, --window-mode hidden [warning] Requested a 2560x1440 window but the OS gave 2560x1421; …. 12/12 PNGs 2560×1421. RESULT=CLEAN
2a. Master control same, master no WARN, 12/12 PNGs 2560×1421
2b. Request over the GL limit fails loudly offscreen, init_window_width = 40000 exit 1, 0 PNGs: FATAL: OpenGL offscreen screen target 40000x1440 exceeds the GL limit 32768x32768 (GL_MAX_TEXTURE_SIZE 32768, GL_MAX_FRAMEBUFFER_WIDTH/HEIGHT 32768x32768, GL_MAX_VIEWPORT_DIMS 32768x32768). …
2b. Master control same, master exit 0, RESULT=CLEAN, screen target attached (7684x1421), 12 PNGs 7684×1421
3. Scale derivation suite fleet-run IrredenEngineTest --gtest_filter='WindowMode*:WindowFramebufferScale*:WindowOffscreenSurface*' [ PASSED ] 12 tests., none skipped
3. Mutation control OFFSCREEN getFramebufferSize returns glfwGetFramebufferSize (master's behaviour) ExtentIsTheRequestNotTheOsWindow FAILED (1421 vs 4000); SetWindowSizeResizesSynchronously FAILED
4. render-verify IRShapeDebug python3 scripts/render-verify.py --target IRShapeDebug, PR vs master PR and master both 24 of 103 checks FAIL (83 skipped — references pending); the 24 failing rows are the same set (zoom4_yaw180/yaw270/yaw45_inter_cardinal, zoom8_yaw180, zoom4_pan16_yaw180/yaw45_pivot across the default, glitch_standard_off, glitch_subject_standard_off and post_effects_standard_off passes); text_scale1_legibility PASS on both
4. render-verify IRCanvasStress python3 scripts/render-verify.py --target IRCanvasStress, PR vs master PR and master both 8 of 31 checks FAIL (28 skipped): the same 8 rows (so3_* ×5, revoxelize_solids, compare_yaw0, compare_yaw_q) with identical max_delta / match%
4. --framebuffer-size fixture under offscreen fleet-run IRShapeDebug --config-preset configs/gui_text_scale1.lua --framebuffer-size 1280 960 --text-size-sample --auto-screenshot 10 OpenGL offscreen screen target attached (640x480), then Framebuffer fixture size: 1280x960 (window 1280x960). RESULT=CLEAN
5. #4813 polygon oracle, 10 non-origin placements, native #4813 cap.py/grade.py with a 2560×1440 window, upscale path removed (a non-2560×1440 frame is an error), fog16, opt-in on default palette: 8/10 pass 0/0/0, counts equal Metal's; subpos-yaw0.6 and subneg-yaw0.6 21/26/0 (Metal 0/0/0). Every frame is 2560×1440, fog=compose fogComposed=1, RESULT=CLEAN
5. Second palette same, --sun-ambient 0.15 the same 8/10 at 0/0/0; subpos/subneg 21/26/0
Reviewer notes

Plan departures

  • The branch was implemented by an earlier claimant (pool-5) against master d72f88820 and parked on a full host disk. This PR rebases it onto 44955ae9f. Two conflicts: ir_glfw_window.hpp (master added CloseGuard m_closeGuard; beside the new measureSurface() declaration; both kept) and engine/window/CLAUDE.md (master reworded the Metal pacing sentence; the new offscreen-size paragraph follows it).
  • Criterion 5 covers the default palette and --sun-ambient 0.15. The 0.55 and local-light palettes were not run: GPU-lock contention on the host stretched single captures past an hour. The criterion asks for the fog-composed arms of the 10 placements; the default palette is that set.

Notes for reviewer

Closes #4852

🤖 Generated with Claude Code

In offscreen mode the window, not the OS, owns the surface size.
IRGLFWWindow records the requested extent in window points and the
framebuffer/window ratio measured once at creation; getWindowSize and
getFramebufferSize return the extent and extent x ratio, so a request
Windows clamps to the desktop work area (2560x1440 -> 2560x1421) still
renders and captures at the requested size, and a 1280x720-point macOS
request stays a 2560x1440 retina target.

- IRWindow::setWindowSize(points) is the resize API. Offscreen, it fires
  the backend's framebuffer-size callback synchronously; the hidden OS
  window's framebuffer events never reach that callback. shape_debug's
  --framebuffer-size fixture moves to it from raw glfwSetWindowSize.
- The GL offscreen target exits non-zero naming the size and the limit
  when a request exceeds GL_MAX_TEXTURE_SIZE, GL_MAX_FRAMEBUFFER_* or
  GL_MAX_VIEWPORT_DIMS, instead of handing back a smaller frame.
- Presented modes keep the OS surface and WARN with both sizes when the
  OS gave less than the request (fullscreen exempt).

Closes #4852

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — window: offscreen captures keep the requested size under an OS clamp

Verdict: approve

The window-owned offscreen extent, one-time backing-scale measurement, callback gating, and explicit OpenGL limit failure form a coherent implementation of the plan without changing presented-mode sizing.

Acceptance (issue #4852)

5 of 5 criteria met. The Windows evidence distinguishes the requested-size path, presented clamp warning, and over-limit failure from master; the scale/resize suite includes a mutation control; render-verify rows match their same-session controls; and the native 2560×1440 #4813 follow-up recorded its two non-zero sub-pixel readings as the non-blocking renderer finding the plan anticipated.

Praise

  • OpenGLRenderDevice::exitIfBeyondTargetLimits keeps the release-build failure path explicit and emits the complete diagnostic before _Exit, while checking every allocation/raster limit named by the plan.
  • The real-window tests cover both offscreen callback isolation and presented callback registration, not only the pure scale helpers.

Checked

  • Reviewed head ac7c4649d0c16a6c434c954b309047d0cebc923b, the complete PR/issue thread, all changed files, and the Metal resize counterpart.
  • fleet-jobs wait --timeout 540 20261118T072445Z-build-1458ca: fleet-jobs: 20261118T072445Z-build-1458ca succeeded exit=0 for IrredenEngineTest on macOS.
  • fleet-run IrredenEngineTest '--gtest_filter=WindowMode*:WindowFramebufferScale*:WindowOffscreenSurface*': 12 tests passed, none skipped.
  • git diff --check origin/master...HEAD: clean. Live overlap audit found only clean shared-file merges; #4921's conflict is inherited from master.
  • Current CI has format, header, comment, whitespace, closes, instruction, and fleet gates passing. Linux build, perf gate, and aggregate status remain pending and are not claimed green here.

🤖 Reviewed by Codex GPT-5 (runtime: codex; review-pr skill)

Opus recheck not required (reviewed at opus class).

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:needs-macos-smoke PR needs macos-debug build + smoke-run validation and removed fleet:reviewing-mac-pool-2 labels Nov 18, 2026
@jakildev jakildev added fleet:verified-macos Cross-host smoke passed on macos-debug and removed fleet:needs-macos-smoke PR needs macos-debug build + smoke-run validation labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Cross-host smoke OK on macos (fresh checkout + IRShapeDebug --auto-screenshot 10 — build clean, exit 0, no log warnings).

@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-xeon-6975p-c-03-0-vga

perf comparison: b309c9f → daedb4e-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-xeon-6975p-c-03-0-vga/b309c9f6048632dbfc29df976605a00b49aa3523
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/daedb4e31-ci

host calibration

  • host: linux-x86_64-xeon-6975p-c-03-0-vga (matches baseline)
  • ref_ms: head 70.03 vs baseline 69.98 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@b309c9f60 (branch tip); master 40cb99890, finished 2026-11-18T00:35:20Z, 0.3 d before the head run, ref_ms 69.98
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master 40cb99890 and merge base 18a91f694 (7 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.598 → 0.598 (+0.0pp) 156630 → 156630 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.975 → 0.975 (+0.0pp) 255592 → 255592 1024 → 1024 0 → 0

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 451.04 → 448.00 (-0.7%) 1173.32 → 1182.12 (+0.8%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 959.09 → 961.09 (+0.2%) 1732.18 → 1739.65 (+0.4%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 503.95 → 527.99 (+4.8%) 6730.35 → 6971.13 (+3.6%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1357.59 → 1358.73 (+0.1%) 2036.00 → 2093.01 (+2.8%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 16.87→16.77 48.76→47.22 41.56→40.65 0.78→0.75 41.64→41.26 70.15→70.46 — 0.00→0.00 1.53→1.55 17.83→17.48 14.46→14.34 12.15→12.44 2.90→2.74 ↓ 0.99→0.98 0.16→0.17 — 6.71→6.74
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 17.38→17.45 241.92→239.15 182.43→180.03 3.04→3.03 172.59→171.01 114.14→114.72 — 0.00→0.00 1.29→1.30 30.18→29.87 12.93→12.19 ↓ 10.14→10.57 5.01→5.00 1.09→1.05 0.16→0.15 ↓ — 6.35→6.30
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 15.45→15.62 55.69→56.79 44.44→44.35 6.62→6.77 37.16→37.12 65.84→66.08 1.29→1.30 0.00→0.00 4.16→4.42 38.79→40.39 12.29→12.99 29.16→29.31 4.86→4.96 1.38→1.39 0.15→0.17 ⚠ 0.00→0.00 7.13→7.36
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 16.48→16.47 393.12→392.85 292.56→291.22 4.66→4.67 268.53→267.11 127.72→127.26 1.33→1.34 0.00→0.00 1.31→1.34 38.63→39.07 13.79→14.43 11.02→11.27 4.34→4.05 ↓ 1.18→1.15 0.15→0.15 0.00→0.00 6.24→6.27

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 221.593 → 219.033 (-1.2%)
RENDER ComputeLightVolume 26.250 → 26.396 (+0.6%)
RENDER CanvasToFramebuffer 14.773 → 14.662 (-0.8%)
RENDER ComputeSunShadow 13.119 → 12.793 (-2.5%)
UPDATE FogRevealEval 8.618 → 8.908 (+3.4%)
RENDER BakeSunShadowMap 6.145 → 6.100 (-0.7%)
UPDATE PropagateTransform 3.668 → 3.797 (+3.5%)
RENDER UpdateVoxelSetChildren 3.194 → 2.951 (-7.6%) ↓

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 729.250 → 723.129 (-0.8%)
RENDER ComputeSunShadow 26.492 → 25.985 (-1.9%)
RENDER ComputeLightVolume 22.641 → 22.371 (-1.2%)
RENDER CanvasToFramebuffer 14.167 → 13.772 (-2.8%)
UPDATE FogRevealEval 7.354 → 8.066 (+9.7%)
RENDER ComputeVoxelAO 6.886 → 6.905 (+0.3%)
RENDER BakeSunShadowMap 5.002 → 5.196 (+3.9%)
RENDER LightingToTrixel 5.192 → 5.092 (-1.9%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 235.817 → 237.522 (+0.7%)
RENDER ComputeSunShadow 34.222 → 35.841 (+4.7%)
RENDER ComputeLightVolume 23.624 → 24.191 (+2.4%)
RENDER LightingToTrixel 18.734 → 19.224 (+2.6%)
RENDER CanvasToFramebuffer 14.799 → 14.957 (+1.1%)
RENDER BakeSunShadowMap 8.113 → 8.308 (+2.4%)
UPDATE FogRevealEval 7.265 → 7.260 (-0.1%)
UPDATE PropagateTransform 4.769 → 5.924 (+24.2%) ⚠

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1101.999 → 1098.691 (-0.3%)
RENDER ComputeSunShadow 34.622 → 35.071 (+1.3%)
RENDER ComputeLightVolume 24.498 → 25.321 (+3.4%)
RENDER CanvasToFramebuffer 13.496 → 13.492 (-0.0%)
UPDATE FogRevealEval 7.735 → 7.955 (+2.8%)
RENDER ComputeVoxelAO 5.662 → 5.675 (+0.2%)
RENDER BakeSunShadowMap 5.175 → 5.162 (-0.3%)
UPDATE PropagateTransform 4.747 → 4.876 (+2.7%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-windows PR was opened from a Windows (MSYS2) host fleet:verified-macos Cross-host smoke passed on macos-debug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render: GL offscreen capture target inherits the OS-clamped window size (2560x1440 request yields 2560x1421)

1 participant