Skip to content

render: draw images into the main framebuffer at pixel resolution - #5142

Merged
jakildev merged 1 commit into
masterfrom
claude/framebuffer-image-draw
Nov 17, 2026
Merged

jakildev merged 1 commit into
masterfrom
claude/framebuffer-image-draw

Conversation

@jakildev

Copy link
Copy Markdown
Owner

Summary

An image drawn on a canvas-draw layer keeps half its horizontal detail, because a canvas texel is two framebuffer pixels wide. IRPrefab::CanvasDraw::queueFramebufferImage (IRCanvas.framebufferImage in Lua) draws the same loaded image straight into the main framebuffer at one sample per pixel, through a new IMAGE_TO_FRAMEBUFFER pass. It takes the canvas path's crop, mosaic, posterize and tint options and its depth constants, so canvas text still sits over it, a world voxel still occludes it, and the glitch pass and the recorder still see it.

Screenshots

framebuffer_image_sample: top left, one probe image with one-pixel detail drawn through the canvas path and through the framebuffer path. Centre, a BEHIND framebuffer image under a world cube and under canvas text, with two FRONT images over the cube. Top right, the mosaic, posterize and tint options on the framebuffer path.

after

Existing shots: no visual change, 24 of 24 pairs identical against origin/master (the 21 default IRShapeDebug shots, --voxel-text-sample, --text-size-sample, --canvas-image-sample).

Test plan

  • fleet-build --target IRShapeDebug and --target IrredenEngineTest, macos-debug: both built
  • fleet-run IrredenEngineTest: 4035 tests passed, including the new framebuffer_image_test.cpp and lua_framebuffer_image_test.cpp
  • fleet-run IRShapeDebug --framebuffer-image-sample --auto-screenshot 10: byte-identical to the committed macos-debug/framebuffer_image_sample.png; in that shot the framebuffer tile reproduces the 192x96 probe with no mismatching pixel
  • fleet-run IRShapeDebug --canvas-image-sample --auto-screenshot 10: byte-identical to its existing reference, so moving the filter into a shared include changed nothing on the canvas path
  • python3 scripts/shader_parity_audit.py: clean, 162 glsl and 150 metal files
  • cmake -P cmake/run_header_checks_standalone.cmake, lint_comment_refs.py, lint_instruction_refs.py, lint_creation_manifests.py, fleet-build --target format-changed: all pass
  • python3 scripts/lint_instruction_size.py --against origin/master: exit 0 with two warnings (see notes)
Reviewer notes

Notes for reviewer

  • OpenGL is unverified. The four new .glsl files and the refactored kernel GLSL are written as twins of the Metal sources and pass the parity audit; none has been compiled on a Linux or Windows host. Only a macOS reference is committed.
  • Depth. The fragment writes the composite's depth for a world-tier canvas texel of the same distance plus half an encode step. On this host the shot is byte-identical without the half step; it is there so ordering never depends on two programs rounding alike.
  • Order among framebuffer images. There is no depth-function API, so the queue is drawn back to front: at one distance the later call owns the pixel.
  • No early depth test. The fragment writes its own depth, so every pixel of an image's box is shaded even where the world covers it (up to 32 atlas reads per pixel).
  • An opaque background-canvas fill sits at kDepthBehind and hides a BEHIND framebuffer image; the design doc says to leave that canvas transparent under one. A full-frame BEHIND image also writes depth below 1.0 everywhere, which FRAMEBUFFER_GLITCH's depth effect reads as non-background. That interaction was not tested.
  • Without IMAGE_TO_FRAMEBUFFER in the pipeline nothing is drawn and the queue stops growing at 256 draws. C_CanvasDrawQueue has no such bound without CANVAS_DRAW; that predates this change.
  • Instruction byte budgets. engine/prefabs/irreden/render/CLAUDE.md and engine/script/CLAUDE.md are over their byte budgets on master. Their rows were edited in place and grow by 120 and 103 bytes, inside the lint's warning band.
  • Reuse scan, not applied: clipFramebufferImage wraps clipRectToCanvas and could live beside it in trixel_rect.hpp; the framebufferImage and image Lua lambdas share a prefix; the framebuffer quad-pass setup repeats what three other *_to_framebuffer systems do.
  • The sample is static, so the recorded clip adds nothing over the still and is not embedded.

🤖 Generated with Claude Code

A canvas-draw image is sampled once per canvas texel, and a texel is
two framebuffer pixels wide, so an image on a layer canvas keeps half
its horizontal detail. queueFramebufferImage draws the same loaded
image straight into the main framebuffer, one sample per pixel, where
the glitch pass and the recorder still see it.

IMAGE_TO_FRAMEBUFFER runs after TRIXEL_TO_FRAMEBUFFER and draws each
queued image as a depth-tested quad. The fragment writes the depth the
composite gives a canvas texel of the same distance, plus half an
encode step, so the canvas-draw depth constants keep their meaning:
canvas text at the image's distance or nearer covers it, and a world
voxel occludes a BEHIND image. The crop, mosaic, posterize and tint
options are the canvas path's, with the box and cell in framebuffer
pixels.

The image filter moved out of c_canvas_image_to_trixel into a shared
include that the new fragment shader also uses, so both paths resolve
a crop the same way; the canvas sample's reference is unchanged. Lua
gets IRCanvas.framebufferImage and IRCanvas.framebufferSize. The GLSL
side has not been run on an OpenGL host.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jakildev jakildev added fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Perf gate

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

perf comparison: 9e35941 → cd0bb58-ci

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

host calibration

  • host: linux-x86_64-xeon-6975p-c-03-0-vga (matches baseline)
  • ref_ms: head 70.00 vs baseline 73.97 (load_factor 0.95×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@9e35941dd (branch tip); master a661037da, finished 2026-11-17T06:40:04Z, 0.5 d before the head run, ref_ms 73.97
  • weighting: raw (class-matched capture; load_factor 0.95×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master a661037da and merge base a914699df (6 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 435.10 → 439.37 (+1.0%) 1168.04 → 1152.50 (-1.3%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 949.62 → 941.64 (-0.8%) 1698.79 → 1681.65 (-1.0%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 503.12 → 508.40 (+1.0%) 6722.30 → 6752.64 (+0.5%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1349.84 → 1344.97 (-0.4%) 2026.76 → 2076.85 (+2.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 16.59→16.34 48.09→47.22 40.94→40.50 0.76→0.74 40.78→40.98 70.21→69.25 — 0.00→0.00 1.50→1.46 17.29→17.24 14.42→13.38 ↓ 12.08→12.02 2.58→2.63 0.95→0.95 0.16→0.16 — 6.63→6.45
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 17.37→17.21 237.69→237.86 179.24→178.61 3.01→2.98 169.92→169.35 114.50→112.96 — 0.00→0.00 1.30→1.32 29.78→29.61 12.28→12.89 10.36→10.48 4.87→5.06 1.05→1.08 0.15→0.16 — 6.36→6.23
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 15.49→15.55 55.75→55.70 43.76→44.48 6.42→6.74 36.02→35.97 65.34→65.53 1.30→1.30 0.00→0.00 4.14→4.21 39.13→39.28 12.70→12.67 28.87→29.16 4.84→4.87 1.36→1.39 0.15→0.15 0.00→0.00 7.15→7.04
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 16.49→16.34 390.63→390.79 290.55→290.92 4.65→4.63 266.25→266.52 126.91→126.79 1.33→1.29 0.00→0.00 1.31→1.34 38.55→38.03 13.92→13.44 11.29→10.89 4.20→4.12 1.16→1.14 0.14→0.15 0.00→0.00 6.25→6.24

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 219.304 → 216.864 (-1.1%)
RENDER ComputeLightVolume 26.211 → 25.048 (-4.4%)
RENDER CanvasToFramebuffer 14.693 → 14.445 (-1.7%)
RENDER ComputeSunShadow 12.666 → 12.669 (+0.0%)
UPDATE FogRevealEval 7.427 → 8.497 (+14.4%) ⚠
RENDER BakeSunShadowMap 5.992 → 5.929 (-1.1%)
UPDATE PropagateTransform 3.715 → 4.079 (+9.8%)
UPDATE LuaWaveStateToOffset 2.939 → 2.750 (-6.4%) ↓

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 719.964 → 717.133 (-0.4%)
RENDER ComputeSunShadow 26.039 → 25.756 (-1.1%)
RENDER ComputeLightVolume 22.266 → 23.009 (+3.3%)
RENDER CanvasToFramebuffer 13.799 → 13.860 (+0.4%)
UPDATE FogRevealEval 7.552 → 7.097 (-6.0%) ↓
RENDER ComputeVoxelAO 6.645 → 6.657 (+0.2%)
RENDER LightingToTrixel 5.013 → 5.209 (+3.9%)
RENDER BakeSunShadowMap 5.063 → 5.203 (+2.8%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 234.552 → 235.887 (+0.6%)
RENDER ComputeSunShadow 34.668 → 34.713 (+0.1%)
RENDER ComputeLightVolume 23.793 → 24.024 (+1.0%)
RENDER LightingToTrixel 18.714 → 18.717 (+0.0%)
RENDER CanvasToFramebuffer 14.805 → 14.481 (-2.2%)
RENDER BakeSunShadowMap 7.977 → 8.142 (+2.1%)
UPDATE FogRevealEval 6.797 → 7.560 (+11.2%) ⚠
UPDATE PropagateTransform 4.687 → 4.848 (+3.4%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1094.359 → 1094.766 (+0.0%)
RENDER ComputeSunShadow 34.468 → 33.909 (-1.6%)
RENDER ComputeLightVolume 24.906 → 23.938 (-3.9%)
RENDER CanvasToFramebuffer 13.381 → 13.495 (+0.9%)
UPDATE FogRevealEval 7.813 → 7.508 (-3.9%)
RENDER ComputeVoxelAO 5.560 → 5.585 (+0.4%)
RENDER BakeSunShadowMap 5.213 → 5.272 (+1.1%)
UPDATE PropagateTransform 4.663 → 4.782 (+2.6%)

@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: draw images into the main framebuffer at pixel resolution

Verdict: needs-fix

The implementation, backend twins, depth ordering, and new C++/Lua coverage look sound, but the current head does not have a green required check.

Needs-fix

  • Current-head fleet-tests failed in test_fleet_claim_acquire_race.sh and test_fleet_claim_cross_lane.sh; the exact base commit's Fleet Tests run is green. Please rerun the failed workflow to obtain a clean head result, and investigate the claim-race failures if they reproduce. linux-build is also still pending, so it is unread rather than green.

Praise

  • System<IMAGE_TO_FRAMEBUFFER> preserves painter order at equal depth by walking the queue in reverse under the existing strict depth test, while still letting encoded distance arbitrate different-depth draws.
  • The shared sampling include keeps the canvas and framebuffer paths aligned, with explicit GLSL/Metal twins and layout assertions for the 96-byte frame block.

Checked

  • Read the complete PR thread, inline-comment stream, timeline, and all changed files at head e1a6a6453b954566589bfc7d237d4d5caa36c21c; there are no prior reviews, comments, linked closing issues, or stack base.
  • fleet-build --detach --target IrredenEngineTest: terminal result fleet-jobs: 20261117T193736Z-build-0edb3b succeeded exit=0 on macOS.
  • fleet-run IrredenEngineTest --gtest_filter='FramebufferImageTest.*:LuaFramebufferImageTest.*:LuaPipelineRegisterTest.SystemNameEnumBound': 15/15 passed.
  • Inspected the committed macOS Metal reference: pixel-detail preservation, crop/mosaic/posterize/tint, world occlusion, canvas-text overlay, and equal-depth later-draw behavior are visually represented as described.
  • Current CI: shader parity, render harness, perf gate, formatting, headers, instruction checks, closes lint, and whitespace pass; Fleet Tests fails; Linux build is pending.

Test plan the author should run before merge

  • Rerun the failed Fleet Tests workflow and confirm both claim-race suites pass.
  • Confirm linux-build completes successfully; OpenGL runtime smoke remains cross-host debt.

🤖 Reviewed by Codex (GPT-5), opus-class review-pr pass

Opus recheck not required (reviewed at opus class).

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:reviewing-mac-pool-4 labels Nov 17, 2026
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:needs-fix Fleet reviewer found issues — author must address fleet:amending-mac-pool-5 labels Nov 17, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback:

— worker (pool-5)

@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: draw images into the main framebuffer at pixel resolution

Verdict: approve

The prior CI-only send-back is resolved on the unchanged head; no substantive finding remains.

Prior-review resolution

  • ✅ Current-head Fleet Tests failure and pending Linux build — the rerun of fleet-tests and gate passed, linux-build passed, and all-checks reports all 15 checks green at e1a6a6453.

Checked

  • Read the complete PR discussion, prior review, inline-comment stream, and timeline; the head remains e1a6a6453b954566589bfc7d237d4d5caa36c21c, so this re-review is delta-scoped to the previously flagged CI state.
  • gh pr checks 5142: all 16 displayed check/status rows pass, including the rerun fleet-tests, gate, linux-build, shader parity, render harness, perf gate, formatting, and header checks.
  • The PR is standalone on master, mergeable, and clean. OpenGL runtime smoke remains cross-host debt and will be tagged separately; it is not a merge gate.

🤖 Reviewed by Codex (GPT-5), opus-class review-pr pass

Opus recheck not required (reviewed at opus class).

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-1 labels Nov 17, 2026
@jakildev
jakildev merged commit 04c0164 into master Nov 17, 2026
17 of 19 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-macos PR was authored and smoke-tested on macOS Metal backend fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant