Skip to content

Cheaper height ray and per-draw work in NosVille - #18

Merged
erwan-joly merged 1 commit into
mainfrom
claude/project-thread-n2c6pz
Oct 31, 2026
Merged

erwan-joly merged 1 commit into
mainfrom
claude/project-thread-n2c6pz

Conversation

@erwan-joly

@erwan-joly erwan-joly commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Height ray: the ray runs straight up in practice, so height_node now rejects most ground triangles on the first edge value, u, which it computes from four coordinates. The value is bit-identical to ray_triangle's u whenever that is not NaN, so the shortcut rejects exactly the triangles the full test would. The difftest gains upright rays and grid-snapped geometry to cover the shortcut.
  • Draw constants: blocks are now packed by the number of lights actually used (27 vec4s plus 6 per light), instead of a fixed 75-texel block.
  • Transforms: setting a transform to the matrix it already holds no longer recomputes world-view-projection.
  • Setup loggers: they check the last matching entry first.

Results (NUC, 1080p, uncapped)

Before After
NosVille 117 fps 130 fps
Chicken Farm Path 225 fps 246 fps
Height ray work 1.31 ms/frame 0.89 ms/frame
texSubImage2D 0.40 ms/frame 0.23 ms/frame
  • The difftest finds 0 mismatches: 200k ray, 20k height and 20k path cases.
  • Walks in NosVille give the same positions, heights, meshes and lighting. Chicken Farm Path also renders the same.

Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved height-ray handling for vertical rays, helping produce more consistent results in affected scenes.
  • Performance
    • Reduced redundant transform updates and improved how rendering constants are buffered, which may make rendering more efficient.
  • Tests
    • Expanded differential test coverage with grid-aligned and upright cases.

The height ray is straight up in practice, so most ground triangles are
rejected on the ray/triangle test's first edge value, now computed from
four coordinates; the difftest gains upright rays and grid-snapped
geometry to cover it. Draw constants are packed by the number of lights
actually used instead of a fixed 75-texel block, setting a transform to
the matrix it already holds no longer recomputes world-view-projection,
and the setup loggers check the last match first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014gSmkXCUwMW8pvXTj7msSU
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1f892298-4e97-48f0-9497-cfaa3d20dd98
Commits

Reviewing files that changed from the base of the PR and between 82d6252 and 2f6f41e.

Files selected for processing: 4
  • recomp/difftest/overrides.c
  • recomp/port/render.c
  • recomp/port/render_gl.inc
  • recomp/runtime/rt_game.c

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The changes add a vertical-ray triangle prefilter and broaden height-ray differential test inputs. They also update transform handling and revise WebGL draw-constant storage, upload, and addressing.

Changes: Height-ray filtering and tests

Layer / File(s) Summary
Vertical-ray filter and test cases
recomp/runtime/rt_game.c, recomp/difftest/overrides.c
height_node applies an additional triangle prefilter when the ray has zero horizontal direction. Differential test cases now include grid-aligned and upright inputs.

Rendering updates

Layer / File(s) Summary
Transform matrix updates
recomp/port/render.c
r_set_transform skips unsupported transform types and avoids copying a matrix that matches the stored value.
Draw-constant storage and addressing
recomp/port/render_gl.inc
Buffered draws allocate variable-size constant blocks, reuse a matching preceding block of the same size, and address constants by row and column. js_gl_run uploads constants in 2025-texel rows. Setup logging checks the most recently matched key first.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant BufferedDraw
  participant ConstantsBuffer
  participant js_gl_run
  participant WebGL2ConstantTexture
  participant ShaderBaseUniform
  BufferedDraw->>ConstantsBuffer: Reserve or reuse a variable-size block
  ConstantsBuffer->>js_gl_run: Pass populated constants on flush
  js_gl_run->>WebGL2ConstantTexture: Upload constants in 2025-texel rows
  BufferedDraw->>ShaderBaseUniform: Set the constants row and column
Loading

Possibly related PRs

Suggested reviewers: claude

Merge Risk: Minimal · up to 2f6f4

No merge-blocking issue was established. Normal checks should run before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main changes: cheaper height-ray processing and reduced per-draw work in NosVille.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@erwan-joly
erwan-joly merged commit 53d5359 into main Oct 31, 2026
1 check passed
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