Skip to content

This is just for caching and reducing look ups. Minor performance boost. #1273

Open
mcdubhghlas wants to merge 4 commits into
Redot-Engine:masterfrom
mcdubhghlas:master
Open

This is just for caching and reducing look ups. Minor performance boost. #1273
mcdubhghlas wants to merge 4 commits into
Redot-Engine:masterfrom
mcdubhghlas:master

Conversation

@mcdubhghlas
Copy link
Copy Markdown
Member

@mcdubhghlas mcdubhghlas commented Jun 3, 2026

If anything, it's just a little cleaner.

Summary by CodeRabbit

  • Performance Improvements
    • Optimized rendering pipeline efficiency through improved buffer management and parameter handling.
    • Enhanced clustered renderer performance with advanced caching and memory optimization strategies.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a113442d-ad74-4d2c-8fb0-6865c64406b4

📥 Commits

Reviewing files that changed from the base of the PR and between a8f52d2 and 32d6f94.

📒 Files selected for processing (3)
  • servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
  • servers/rendering/renderer_scene_render.cpp
  • servers/rendering/renderer_scene_render.h

Walkthrough

The PR refactors the clustered forward renderer to optimize parameter passing and reduce repeated scene state lookups. Camera data is now passed by const reference, instance buffers are simplified with early returns, shadow loops iterate by precomputed counts, and the main render function caches scene data and debug mode to populate render passes efficiently.

Changes

Rendering Pipeline Optimization

Layer / File(s) Summary
Camera parameter passing optimization
servers/rendering/renderer_scene_render.h, servers/rendering/renderer_scene_render.cpp
RendererSceneRender::CameraData::set_camera now accepts Transform3D and Projection by const reference instead of by value, reducing copy overhead.
Instance buffer and shadow loop optimization
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
_update_instance_data_buffer() uses a direct reference to instance data and early-returns for empty data; shadow rendering loops compute pass counts upfront and iterate by index rather than calling size() repeatedly.
Scene render refactoring with local caching
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
_render_scene() introduces a local scene_data pointer with null-check and caches debug draw mode into booleans (using_debug_mvs, using_debug_wireframe), computing motion_vectors_required and storing it in scene_data->calculate_motion_vectors.
Render passes using cached scene data
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
Opaque, motion, alpha, and depth-prepass paths are updated to use cached scene_data fields and debug flags; sky radiance, debug probe rendering, and temporal reprojection (FSR2/TAA/MetalFX) parameter sources switch to use cached camera transform, projection, and jitter values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately describes the primary objective of the changeset: introducing caching and reducing repeated lookups for performance improvements, which is confirmed by the actual changes that cache scene_data pointers and debug state, avoiding repeated member accesses.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
servers/rendering/renderer_scene_render.cpp

In file included from servers/rendering/renderer_scene_render.cpp:39:
servers/rendering/renderer_scene_render.h:41:10: fatal error: 'core/math/projection.h' file not found
41 | #include "core/math/projection.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/32d6f9474e7aea4103655ca9e7a489fbc3f772a9-e3eab0084e6f2178/tmp/clang_command_.tmp.48a9e1.txt
++Contents of '/tmp/coderabbit-infer/32d6f9474e7aea4103655ca9e7a489fbc3f772a9-e3eab0084e6f2178/tmp/clang_command_.tmp.48a9e1.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter"

... [truncated 1212 characters] ...

/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/e3eab0084e6f2178/file.o" "-x" "c++"
"servers/rendering/renderer_scene_render.cpp" "-O0" "-fno-builtin"
"-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp

In file included from servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp:39:
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h:41:10: fatal error: 'core/templates/paged_allocator.h' file not found
41 | #include "core/templates/paged_allocator.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/32d6f9474e7aea4103655ca9e7a489fbc3f772a9-f4e00c86801fc9d6/tmp/clang_command_.tmp.7b2f3d.txt
++Contents of '/tmp/coderabbit-infer/32d6f9474e7aea4103655ca9e7a489fbc3f772a9-f4e00c86801fc9d6/tmp/clang_command_.tmp.7b2f3d.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"

... [truncated 1344 characters] ...

"/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/f4e00c86801fc9d6/file.o" "-x" "c++"
"servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp"
"-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant