Skip to content

Comments

refactor: clean up render pass code#1288

Merged
yiiqii merged 2 commits intofeat/2.8from
refactor/render-pass
Nov 27, 2025
Merged

refactor: clean up render pass code#1288
yiiqii merged 2 commits intofeat/2.8from
refactor/render-pass

Conversation

@wumaolinmaoan
Copy link
Contributor

@wumaolinmaoan wumaolinmaoan commented Nov 26, 2025

Summary by CodeRabbit

  • Refactor

    • Simplified rendering system by streamlining viewport and resource management
    • Enhanced render pass initialization for improved startup consistency
    • Removed deprecated texture copying functionality
    • Cleaned up internal rendering pipeline to reduce API surface
  • Tests

    • Updated unit tests to align with rendering API changes

✏️ Tip: You can customize this high-level summary in your review settings.

@wumaolinmaoan wumaolinmaoan requested a review from yiiqii November 26, 2025 11:26
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Walkthrough

This PR removes multiple public API surfaces across the rendering pipeline, including custom viewport handling (isCustomViewport), render frame resource management (createResource, createCopyMesh, getRPAttachments), attachment reset methods (resetColorAttachments, resetAttachments), texture copy infrastructure (ExtWrap, CopyTexturePass), and FBOOptions parameters. Corresponding test coverage for these features is also removed or simplified.

Changes

Cohort / File(s) Change Summary
Viewport Customization Removal
packages/effects-core/src/render/framebuffer.ts, packages/effects-core/src/render/render-pass.ts, packages/effects-webgl/src/gl-framebuffer.ts
Removed isCustomViewport property and viewport option handling; viewport now computed as fixed [0, 0, width, height] in framebuffer creation
Render Frame Resource Management Removal
packages/effects-core/src/render/render-frame.ts
Deleted public resource field and resource management methods: createResource(), createCopyMesh(), getRPAttachments(), resetRenderPassDefaultAttachment(), and nested FinalCopyRP class; simplified attachment handling
Post-Process Pass Initialization
packages/effects-core/src/render/post-process-pass.ts
Added override initialize() method to HQGaussianDownSamplePass and HQGaussianUpSamplePass to trigger resize handling during initialization
Texture Copy Infrastructure Removal
packages/effects-webgl/src/ext-wrap.ts, packages/effects-webgl/src/gl-renderer.ts
Deleted entire ext-wrap.ts file containing ExtWrap class and deprecated CopyTexturePass; removed extension field and related lifecycle management from GLRenderer
Attachment Reset API Removal
packages/effects-threejs/src/three-render-pass.ts
Removed override methods resetColorAttachments() and resetAttachments(); cleaned up related imports
Plugin Package FBOOptions Removal
plugin-packages/model/src/runtime/cache.ts, plugin-packages/model/src/utility/plugin-helper.ts
Removed getShadowBasePass(), getShadowFilterPass(), getRenderPass() methods with FBOOptions parameters and createRenderPass() helper; cleaned up FBOOptions imports
Test Updates
web-packages/test/unit/src/effects-webgl/gl-dispose.spec.ts, web-packages/test/unit/src/effects-webgl/gl-frame-buffer.spec.ts, web-packages/test/unit/src/effects-webgl/gl-render-pass.spec.ts, web-packages/test/unit/src/effects-webgl/renderer.spec.ts
Removed viewport properties, isCustomViewport flags, and extensive test coverage for texture copying, reset attachment scenarios, and framebuffer viewport assertions

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • render-pass.ts viewport calculation change: Verify the fixed [0, 0, width, height] viewport logic and removal of conditional custom viewport paths work correctly across all render pass types
  • render-frame.ts resource removal: Audit all internal and external callers of removed methods (createResource, createCopyMesh, getRPAttachments, resetRenderPassDefaultAttachment) to ensure no orphaned references
  • ext-wrap.ts deletion: Confirm texture copy functionality is not required elsewhere or has been replaced; verify copy operations handled through alternative paths
  • Framebuffer creation: Review _resetAttachments implementation to ensure framebuffer binding behavior is correct without isCustomViewport flag
  • Post-process initialization: Validate that the new initialize() override in Gaussian passes correctly triggers onResize() and integrates with render pipeline
  • Test coverage removal: Large blocks of viewport and copy-related tests removed; assess whether these scenarios are covered by integration tests elsewhere

Suggested reviewers

  • yiiqii

Poem

🐰 Hop away, old viewport ghosts,
No custom framebuffers needed most!
Resources trimmed, attachments clean,
The rendering path grows lean and keen.
Copy and reset fade to night—
Fixed viewports keep the pipeline bright! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: clean up render pass code' accurately describes the main objective: removing unused viewport-related APIs and simplifying render pass infrastructure across multiple files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/render-pass

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/effects-core/src/render/render-frame.ts (1)

266-339: Viewport manipulation is confirmed to be dead code and should be removed.

The verification confirms your review comment is correct. The viewport variable is created and modified throughout the gaussian pass setup loops (lines 267, 316–317, 320–321, 337–338), but it is never passed to any pass constructor or assigned as a property. Each gaussian pass independently calculates its render size via the onResize() method:

  • HQGaussianDownSamplePass.onResize() computes size as Math.floor(getWidth() / Math.pow(2, level + 1))
  • HQGaussianUpSamplePass.onResize() computes size as Math.floor(getWidth() / Math.pow(2, level - 1))

These methods are called at pass initialization (lines 152 and 236) and bound to the resize event, making the viewport manipulations entirely redundant.

-      const viewport: vec4 = [0, 0, this.renderer.getWidth() / 2, this.renderer.getHeight() / 2];
       const gaussianDownResults = new Array<RenderTargetHandle>(gaussianStep);
       ...
       for (let i = 0; i < gaussianStep; i++) {
         ...
-        viewport[2] /= 2;
-        viewport[3] /= 2;
       }
-      viewport[2] *= 4;
-      viewport[3] *= 4;
       for (let i = 0; i < gaussianStep - 1; i++) {
         ...
-        viewport[2] *= 2;
-        viewport[3] *= 2;
       }
packages/effects-core/src/render/render-pass.ts (1)

331-332: Dead code - isCustomViewport and customViewport are genuinely unused.

Verification confirms these private fields are never assigned or meaningfully used:

  • isCustomViewport is never read or written anywhere in the codebase
  • customViewport is referenced only in getViewport() (line 478) but never assigned, making it permanently undefined

Remove both fields and simplify getViewport():

-  private isCustomViewport: boolean;
-  private customViewport?: [x: number, y: number, width: number, height: number];
   getViewport (): vec4 {
-    const ret = this.framebuffer?.viewport || this.customViewport;
+    const ret = this.framebuffer?.viewport;

     if (ret) {
       return ret;
     }
🧹 Nitpick comments (2)
packages/effects-threejs/src/three-render-pass.ts (1)

45-51: Empty dispose override - verify intentional.

The dispose method is empty, which may be intentional for this THREE.js adapter if cleanup is handled elsewhere. Consider adding a comment explaining why no cleanup is needed, or call super.dispose(options) if the base class disposal logic should apply.

   override dispose (options?: RenderPassDestroyOptions) {
-
+    // THREE.js resources are managed externally; no disposal needed here.
   }
packages/effects-core/src/render/render-pass.ts (1)

439-439: Naming inconsistency in viewport tuple type.

The tuple uses z: number, w: number but viewport dimensions are typically named width and height, not z and w. Consider using consistent naming:

-    const viewport: [x: number, y: number, z:number, w:number] = [0, 0, renderer.getWidth(), renderer.getHeight()];
+    const viewport: [x: number, y: number, width: number, height: number] = [0, 0, renderer.getWidth(), renderer.getHeight()];
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1069e84 and 8784499.

📒 Files selected for processing (14)
  • packages/effects-core/src/render/framebuffer.ts (0 hunks)
  • packages/effects-core/src/render/post-process-pass.ts (2 hunks)
  • packages/effects-core/src/render/render-frame.ts (1 hunks)
  • packages/effects-core/src/render/render-pass.ts (1 hunks)
  • packages/effects-threejs/src/three-render-pass.ts (1 hunks)
  • packages/effects-webgl/src/ext-wrap.ts (0 hunks)
  • packages/effects-webgl/src/gl-framebuffer.ts (1 hunks)
  • packages/effects-webgl/src/gl-renderer.ts (0 hunks)
  • plugin-packages/model/src/runtime/cache.ts (0 hunks)
  • plugin-packages/model/src/utility/plugin-helper.ts (1 hunks)
  • web-packages/test/unit/src/effects-webgl/gl-dispose.spec.ts (0 hunks)
  • web-packages/test/unit/src/effects-webgl/gl-frame-buffer.spec.ts (0 hunks)
  • web-packages/test/unit/src/effects-webgl/gl-render-pass.spec.ts (0 hunks)
  • web-packages/test/unit/src/effects-webgl/renderer.spec.ts (2 hunks)
💤 Files with no reviewable changes (7)
  • packages/effects-core/src/render/framebuffer.ts
  • plugin-packages/model/src/runtime/cache.ts
  • web-packages/test/unit/src/effects-webgl/gl-dispose.spec.ts
  • web-packages/test/unit/src/effects-webgl/gl-render-pass.spec.ts
  • packages/effects-webgl/src/ext-wrap.ts
  • web-packages/test/unit/src/effects-webgl/gl-frame-buffer.spec.ts
  • packages/effects-webgl/src/gl-renderer.ts
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-10-18T09:15:08.038Z
Learnt from: wumaolinmaoan
Repo: galacean/effects-runtime PR: 691
File: packages/effects-core/src/plugins/timeline/playables/color-property-mixer-playable.ts:39-42
Timestamp: 2024-10-18T09:15:08.038Z
Learning: In `packages/effects-core/src/plugins/timeline/playables/color-property-mixer-playable.ts`, when accumulating color components, avoid using `clone()` methods because it can cause additional garbage collection overhead.

Applied to files:

  • web-packages/test/unit/src/effects-webgl/renderer.spec.ts
  • packages/effects-threejs/src/three-render-pass.ts
  • packages/effects-core/src/render/render-frame.ts
📚 Learning: 2025-08-05T07:50:26.317Z
Learnt from: ChengYi996
Repo: galacean/effects-runtime PR: 1118
File: packages/effects-core/src/components/ffd-component.ts:135-219
Timestamp: 2025-08-05T07:50:26.317Z
Learning: In packages/effects-core/src/components/ffd-component.ts, the mesh subdivision logic (lines 147-219) within the collectSpriteComponents method is temporary debug code that will be properly implemented later, as confirmed by ChengYi996.

Applied to files:

  • packages/effects-core/src/render/render-frame.ts
📚 Learning: 2024-10-17T07:15:16.523Z
Learnt from: liuxi150
Repo: galacean/effects-runtime PR: 0
File: :0-0
Timestamp: 2024-10-17T07:15:16.523Z
Learning: Imports in `plugin-packages/model/src/utility/plugin-helper.ts` do not need to be merged as per project preference or coding standards.

Applied to files:

  • plugin-packages/model/src/utility/plugin-helper.ts
🧬 Code graph analysis (2)
web-packages/test/unit/src/effects-webgl/renderer.spec.ts (1)
packages/effects-webgl/src/gl-renderer.ts (1)
  • gl (36-38)
packages/effects-core/src/render/render-pass.ts (3)
packages/effects-webgl/src/gl-engine.ts (1)
  • viewport (509-511)
packages/effects/src/player.ts (1)
  • renderer (66-68)
packages/effects-threejs/src/three-display-object.ts (1)
  • renderer (39-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
plugin-packages/model/src/utility/plugin-helper.ts (1)

1-10: Inconsistency: RenderPass import retained despite summary claiming removal.

The AI summary states that RenderPass was removed from the @galacean/effects import group (Line 5), but the import still appears in the final code. Furthermore, RenderPass remains actively used on Line 335 in the deleteRenderPass() method signature and Line 340-341 in RenderPassDestroyAttachmentType references.

Either this represents an incomplete refactor (the import should have been removed but wasn't), or the summary is inaccurate (the import should remain). Please clarify the intended state and ensure consistency between the imports and their actual usage.

packages/effects-core/src/render/post-process-pass.ts (1)

150-155: LGTM - Initialize overrides ensure proper initial sizing.

The initialize methods correctly call super.initialize(renderer) followed by this.onResize() to set framebuffer dimensions based on the level during initialization.

One observation: BloomThresholdPass has a similar onResize handler bound in its constructor (line 57-58) but lacks an initialize override. If the framebuffer needs to be sized correctly before the first frame, consider adding a similar override there for consistency. However, since it uses the full renderer dimensions (not level-based), it may rely on the base class initialization being sufficient.

Also applies to: 234-239

packages/effects-webgl/src/gl-framebuffer.ts (1)

34-36: LGTM - Clean removal of isCustomViewport flag.

The removal of isCustomViewport from the constructor destructuring aligns with the broader API simplification. Viewport handling continues to work through the remaining viewport property.

web-packages/test/unit/src/effects-webgl/renderer.spec.ts (2)

1-1: LGTM - Import cleanup aligns with API simplification.

The simplified imports reflect the removal of texture copy and custom viewport test coverage, keeping only what's needed for the remaining test cases.


34-34: Good - const is appropriate here.

The change from let to const is correct since tex is not reassigned.

packages/effects-threejs/src/three-render-pass.ts (1)

1-6: LGTM - Import cleanup consistent with API removal.

The removal of Texture and RenderPassAttachmentOptions imports aligns with the removal of resetColorAttachments and resetAttachments methods from the base class.

packages/effects-core/src/render/render-frame.ts (2)

3-23: LGTM - Import reorganization is clean.

The imports are properly organized with type-only imports where appropriate, aligning with the API simplification across the render pipeline.


76-97: I'll help you verify whether the RenderFrameResource interface is still used in the codebase. Let me search for all occurrences of this interface.
<function_calls>

#!/bin/bash

Search for all occurrences of RenderFrameResource in the codebase

echo "=== Searching for RenderFrameResource usage ==="
rg -n 'RenderFrameResource' --type=ts


</function_calls>
<function_calls>

#!/bin/bash

Get more context around usages - check imports and exports

echo "=== Checking for imports and exports ==="
rg -n 'RenderFrameResource' --type=ts -B2 -A2


</function_calls>
<function_calls>

#!/bin/bash

Check if it's exported from index files or barrel exports

echo "=== Checking for exports in barrel/index files ==="
fd -e ts -e js | xargs grep -l 'export.*RenderFrameResource' 2>/dev/null || echo "No explicit exports found in index files"

Check the render-frame.ts file itself for exports

echo ""
echo "=== Checking render-frame.ts exports ==="
grep -n 'export' packages/effects-core/src/render/render-frame.ts | head -20


</function_calls>

@yiiqii yiiqii merged commit 29d12e1 into feat/2.8 Nov 27, 2025
2 checks passed
@yiiqii yiiqii deleted the refactor/render-pass branch November 27, 2025 03:41
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