Skip to content

render: load GL string queries; qualify SDF occupancy on Windows/OpenGL - #4927

Merged
jakildev merged 1 commit into
masterfrom
claude/4762-sdf-occupancy-windows-gl
Nov 6, 2026
Merged

jakildev merged 1 commit into
masterfrom
claude/4762-sdf-occupancy-windows-gl

Conversation

@jakildev

@jakildev jakildev commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix an OpenGL crash in the GL loader. GetGLAPI.py read the function name from the fourth token of each glcorearb.h prototype. That is the name only for void APIENTRY returns. glGetString and glGetStringi return const GLubyte *APIENTRY, so they were never loaded or injected and their GL4API slots stayed null. The GL_NVX_gpu_memory_info lookup in OpenGLRenderDevice::gpuMemoryStats(), which feeds the SDF-RESIDENCY witness, then crashed (SIGSEGV) at the end of every --sdf-voxel-scene auto-profile, in both Debug and Release.
    • The generator now takes the last token.
    • The checked-in GLAPITrace.h gains the four missing INJECT/LOAD_GL_FUNC lines.
    • New GLApiLoader.* tests check that every dispatch slot is requested and loaded.
  • Windows power witness. repeat_profile.py reads host_power and battery state through GetSystemPowerStatus on Windows. The manifests now record AC Power instead of null.
  • OpenGL timing-off controls. The OpenGL backend has no whole-frame GPU timer, so a timing-off run carries no GPU measurement and the runner rejected it. New --allow-unsupported-gpu-frame (in repeat_profile.py and sdf_controls.py) accepts a run only when its report witnesses Coverage: supported=0, and records gpu_measured: false. sdf_controls.py refuses the flag unless every selected case is timing-off. The flag is off by default, so the strict gate is unchanged. The summary note no longer claims that timing-off cases keep a GPU envelope on every backend.
  • Retained Windows/OpenGL Release slice in docs/perf/sdf-voxel-profile/windows-gl-release-memory/:
    • 66 guarded runs: 11 cases (density, 16-copy overlap, root/parent motion) × 3 rounds × timing off/on.
    • All runs RESULT=CLEAN / QUIET=guarded, with both SDF witnesses.
    • One binary, shader and AC-power identity across both arms.
    • The README, the runner summaries and a path-free runs.json are retained.
    • The measured use cases and limits are folded into docs/design/voxel-and-sdf-rendering.md; the slice indexes and scripts/perf/README.md are updated.
  • Small test fix. test_repeat_profile patches os.getloadavg with create=True, so it runs on native Windows.

Test plan

  • fleet-build --release --target IRShapeDebug and fleet-build --target IrredenEngineTest --target IRShapeDebug: both built clean on Windows (MSYS2 mingw64).
  • fleet-run IrredenEngineTest --gtest_filter='GLApiLoader.*:ProcessMemory.*:SdfBake.*': [ PASSED ] 12 tests., RESULT=CLEAN.
  • Mutation control: with the four header lines removed, both GLApiLoader tests fail ("GL4API slot 118 is never loaded", "slot 119"). The same Debug build's SDF scene also SIGSEGVs. With the lines restored, all 12 tests pass.
  • fleet-run IrredenEngineTest --gtest_filter='*Gpu*:*GPU*:*OpenGL*:*Readback*': [ PASSED ] 56 tests.. These are the GL-context tests that dispatch through the same table.
  • Release and Debug IRShapeDebug --auto-profile … --sdf-voxel-scene baked: before the fix, RESULT=CRASH … signal=SIGSEGV after 6 s. After the fix, SDF-RESIDENCY … gpu_device_capacity_bytes=8589934592 … and RESULT=CLEAN.
  • python3 -m unittest discover -s scripts/perf -p 'test_*.py': 144 tests. One error is pre-existing and unrelated: test_replay_attribution hits WinError 1314 because native Windows lacks symlink privilege.
  • ruff check scripts/: all checks passed. clang-format-18 (WSL) on test/render/gl_api_loader_test.cpp: no diff. python3 scripts/lint_comment_refs.py: ok.
  • Matrix audit over both arms: 11 cases × 3 runs each. Every run clean, fresh, guarded, exit 0, configuration unchanged, both witnesses present, zero overflow drops. One identity tuple (binary 6d19cab1…, AC Power, Release).

Acceptance evidence

Criterion Check run Observed
Independent occupancy/transform controls and native captures verify self/external shadowing, AO and isolated local-light blocking for moving root/parented cases and the named presentation modes; resampled steps distinguished from parity/face-ownership errors Merged native presentation qualification plus the moving root/parent arms of this slice GRID is qualified for lit, coloured subjects with isolated local light. Both detached routes stay documented diagnostic failures in the guide ("unqualified for lit game geometry"). This PR changes no visual output; its moving root/parent arms run clean on OpenGL.
Bake tests cover supported descriptors, oversized admission, scratch accounting and beyond-64³ input within budget fleet-run IrredenEngineTest --gtest_filter='…:SdfBake.*' on Windows SdfBake.* passes inside the 12-test run. On OpenGL, baked asset and scratch bytes (62.4 / 434.1 KiB, 5.2 / 36.2 KiB) match the Metal slice byte for byte.
Guarded paired Release profiles on stable AC and Windows/OpenGL report bake time, CPU temporary/peak/resident memory, GPU residency, steady whole-frame and GPU costs across density/overlap/motion; instrumentation-off controls retained sdf_controls.py --release --rounds 3 [--allow-unsupported-gpu-frame] × 11 timing-off and 11 timing-on cases Metal: 33 runs (merged). Windows/OpenGL: 66 clean guarded runs on AC Power, with bake µs, asset/scratch bytes, working-set final/peak deltas, NVX device used, steady mean/p95, and per-stage GPU ms. Timing-off is the instrumentation-off control. OpenGL exposes no process GPU residency (recorded as 0, unavailable). NVX is device-wide and does not resolve per-scene differences.
Update voxel-and-sdf-rendering.md with measured use cases and limitations; no public SDF API removal or automatic migration git diff origin/master -- docs/design/voxel-and-sdf-rendering.md The guide adds bake cost, motion behaviour, the overlap-lane cost and heavy tail, when to bake vs keep direct, and the OpenGL counter limits. No SDF API or entity migration is touched.
Composed/custom recipes and dynamic GPU baking stay follow-ups unless measurements justify a bounded implementation; no new shape-specific shadow algorithm Diff review Neither is added. The only engine code change is the GL loader fix.

Plan departures

  • The issue has no ## Plan comment. The 2026-11-01 decline scoped the remaining acceptance work to the Windows/OpenGL profile that render: measure SDF occupancy process and GPU memory #4832 left open; that is what this PR delivers.
  • The issue asks for "GPU costs" from the guarded profile. OpenGL has no whole-frame GPU timer, so GPU cost comes from the timing-on stage rows, and timing-off stays the instrumentation-off control. The new flag makes that split explicit rather than loosening the default gate.

Notes for reviewer

Closes #4762

🤖 Generated with Claude Code

GetGLAPI.py took the function name as the fourth token of each
glcorearb.h prototype, which is the name only for `void APIENTRY`-shaped
returns. glGetString and glGetStringi (`const GLubyte *APIENTRY`) were
never loaded or injected, so their GL4API slots stayed null and the
GL_NVX_gpu_memory_info lookup behind the SDF-RESIDENCY witness
segfaulted every --sdf-voxel-scene auto-profile on OpenGL. The generator
now takes the last token, the checked-in GLAPITrace.h gains the four
missing lines, and GLApiLoader tests assert every dispatch slot loads.

The profile runner records the Windows power source through
GetSystemPowerStatus. OpenGL has no whole-frame GPU timer, so an
explicit --allow-unsupported-gpu-frame lets an all-timing-off matrix
accept runs whose report witnesses that, while timing-on runs supply
GPU stage costs.

The retained Windows/OpenGL slice holds 66 guarded clean Release runs
across density, 16-copy overlap and root/parent motion, with the
measured use cases and limits folded into the representation guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-windows PR was opened from a Windows (MSYS2) host labels Nov 6, 2026

@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 — render: load GL string queries; qualify SDF occupancy on Windows/OpenGL

Verdict: approve

The loader fix is narrowly correct: taking the last token before the parameter list handles both void APIENTRY and pointer-returning GL prototypes, the checked-in table now loads and injects both string queries, and the new OpenGL-only regression test covers both the specific failure and completeness of the dispatch table. The profiling changes preserve the strict default gate; the opt-in exception requires an explicit supported=0 report, while the SDF matrix additionally confines it to timing-off cases.

The retained artifact is internally consistent: 66 runs cover 11 cases per arm over three rounds; every retained run is clean, guarded, fresh, and carries both SDF witnesses; timing-off is explicitly unmeasured and timing-on carries stage measurements. The documentation keeps NVX device-wide usage distinct from process residency and scopes the performance conclusions to this fixture and host.

Acceptance (issue #4762)

Criterion Grade Basis
Presentation, lighting, and moving root/parent controls met The PR's first evidence row links the merged native presentation qualification, which crosses GRID, rigid DETACHED, and revoxelized root/parent poses under full and isolated-local lighting; this slice adds the OpenGL root/parent arms.
Bake coverage, admission, scratch accounting, and beyond-64³ input met SdfBake.* covers supported descriptors, invalid/oversized admission, exact output-plus-scratch budget boundaries, and a successful 65³ bake; the PR reports that suite passing on Windows.
Guarded AC Windows/OpenGL Release profiles across density, overlap, and motion met windows-gl-release-memory/runs.json contains two 33-run, three-round matrices spanning the 11 named cases. All runs are clean, guarded, fresh, configuration-stable, and carry both witnesses; the tables retain whole-frame, memory, NVX, and timing-on stage results while stating the backend's process-residency limitation.
Document measured use cases, limitations, invalidation, and no automatic migration met voxel-and-sdf-rendering.md records the measured selection boundary, invalidation/rebuild behavior, OpenGL counter limits, and the no-automatic-migration boundary.
Keep recipes/dynamic GPU baking as follow-ups; add no shape-specific shadow algorithm met The diff adds neither mechanism and retains both as follow-ups while continuing to use ordinary voxel lighting.

Validation

  • Focused reviewer run: python3 -m unittest test_repeat_profile test_sdf_controls test_shape_profile — 78 tests passed.
  • Current-head CI at review time: comment refs, format, header checks, instruction size, closes lint, Python lint, whitespace, and change detection passed. linux-build, fleet-tests, and perf-gate were still pending, so this review does not claim those checks passed.
  • The author reports the OpenGL-specific C++ tests, GL-context suite, Debug/Release crash reproduction, and corrected clean runs on the Windows/OpenGL host; those host results are consistent with the retained evidence.

Praise

  • The unsupported-timer escape hatch is positive-witnessed and opt-in instead of weakening the normal measurement gate.
  • The write-up is careful not to mislabel device-wide NVX counters as per-process residency or over-generalize one fixture's timing result.

🤖 Reviewed by Codex (GPT-5, runtime codex; opus review class)

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 6, 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 6, 2026
@jakildev

jakildev commented Nov 6, 2026

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

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-7763-64-unknown

perf comparison: a3d54c9 → 0570dfb-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-7763-64-unknown/a3d54c95a1d9a170f6543be390cf17c7aedebf10
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/0570dfb00-ci

host calibration

  • host: linux-x86_64-epyc-7763-64-unknown (matches baseline)
  • ref_ms: head 104.34 vs baseline 104.10 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@a3d54c95a (branch tip); master 6062102df, finished 2026-11-06T05:56:56Z, 0.0 d before the head run, ref_ms 104.10
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master 6062102df and merge base 8162a732c (1 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 262144 → 262144 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.788 → 0.788 (+0.0pp) 156630 → 156630 262144 → 262144 50080 → 50080 (1.000×)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 262144 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.990 → 0.990 (+0.0pp) 255592 → 255592 262144 → 262144 3862 → 3862 (1.000×)

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 479.15 → 494.48 (+3.2%) 1895.72 → 1776.50 (-6.3%) ↓
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 1272.73 → 1279.93 (+0.6%) 2588.44 → 2620.41 (+1.2%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 652.45 → 660.19 (+1.2%) 12258.22 → 12476.13 (+1.8%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1728.99 → 1730.45 (+0.1%) 2992.62 → 3038.13 (+1.5%)

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 64.10→67.83 64.35→66.50 57.32→59.15 1.29→1.01 ↓ 52.90→54.91 5.30→5.71 — 0.00→0.00 2.62→2.79 14.77→15.27 11.41→11.95 21.67→22.95 3.73→3.73 1.22→1.29 0.19→0.19 — 7.87→7.87
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 110.04→108.82 415.41→418.34 261.63→261.82 4.03→4.04 232.04→232.31 4.80→5.06 — 0.00→0.00 2.31→2.35 28.02→27.96 10.25→10.34 19.56→19.34 8.17→8.22 1.49→1.59 0.17→0.18 — 7.39→7.48
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 59.19→59.91 80.80→82.21 66.25→66.91 12.87→13.25 48.01→47.81 8.35→8.97 1.10→1.12 0.00→0.00 0.89→0.98 ⚠ 62.51→63.54 10.49→10.65 57.15→56.72 7.95→7.96 1.84→1.83 0.17→0.17 0.00→0.00 8.93→9.03
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 119.49→120.00 533.16→533.65 426.57→426.09 6.37→6.35 367.27→367.61 5.63→5.72 1.10→1.09 0.00→0.00 0.73→0.74 25.17→24.61 10.38→10.42 19.24→18.96 6.43→6.47 1.46→1.47 0.17→0.17 0.00→0.00 7.39→7.37

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 247.886 → 257.229 (+3.8%)
RENDER ComputeLightVolume 32.632 → 34.409 (+5.4%)
RENDER CanvasToFramebuffer 17.085 → 17.175 (+0.5%)
RENDER BakeSunShadowMap 9.662 → 10.347 (+7.1%)
RENDER ComputeSunShadow 7.624 → 7.593 (-0.4%)
UPDATE PropagateTransform 4.519 → 4.676 (+3.5%)
UPDATE FogRevealEval 4.190 → 4.342 (+3.6%)
RENDER ComputeVoxelAO 3.904 → 4.003 (+2.5%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1025.715 → 1028.135 (+0.2%)
RENDER ComputeLightVolume 29.338 → 29.237 (-0.3%)
RENDER ComputeSunShadow 21.864 → 21.770 (-0.4%)
RENDER CanvasToFramebuffer 15.908 → 16.128 (+1.4%)
RENDER ComputeVoxelAO 9.249 → 9.350 (+1.1%)
RENDER BakeSunShadowMap 8.417 → 8.490 (+0.9%)
RENDER LightingToTrixel 8.371 → 8.422 (+0.6%)
UPDATE PropagateTransform 4.405 → 4.578 (+3.9%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 288.688 → 292.972 (+1.5%)
RENDER ComputeSunShadow 55.366 → 56.133 (+1.4%)
RENDER LightingToTrixel 36.271 → 35.928 (-0.9%)
RENDER ComputeLightVolume 32.424 → 32.502 (+0.2%)
RENDER BakeSunShadowMap 22.377 → 23.036 (+2.9%)
RENDER CanvasToFramebuffer 17.441 → 17.264 (-1.0%)
RENDER FogToTrixel 7.107 → 7.098 (-0.1%)
UPDATE PropagateTransform 6.121 → 6.232 (+1.8%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1457.395 → 1458.686 (+0.1%)
RENDER ComputeLightVolume 29.173 → 28.990 (-0.6%)
RENDER ComputeSunShadow 18.725 → 18.125 (-3.2%)
RENDER CanvasToFramebuffer 16.205 → 16.015 (-1.2%)
RENDER BakeSunShadowMap 8.811 → 8.825 (+0.2%)
RENDER ComputeVoxelAO 8.092 → 7.817 (-3.4%)
RENDER LightingToTrixel 6.600 → 6.657 (+0.9%)
UPDATE PropagateTransform 6.104 → 6.098 (-0.1%)

@jakildev
jakildev merged commit 0554677 into master Nov 6, 2026
11 of 13 checks passed
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: qualify baked SDF occupancy across motion, density and memory cost

1 participant