-
-
Notifications
You must be signed in to change notification settings - Fork 170
gl: Enables direct rendering to the back buffer #3997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
64c4503 to
bb77a02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enables direct rendering to the back buffer in the OpenGL engine, bypassing intermediate framebuffers when the target is the default framebuffer (FBO ID 0). The implementation includes capability checks for stencil/depth buffers and MSAA support, falling back to offscreen rendering when requirements aren't met.
Key Changes:
- Adds
mDirectTargetflag to track whether rendering directly to the back buffer - Implements validation checks for framebuffer capabilities (stencil, depth, MSAA)
- Switches from blit task to compose task when direct rendering is active
- Updates WebAssembly and SDL example configurations to enable required depth, stencil, and MSAA attributes
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/renderer/gl_engine/tvgGlRenderer.h | Adds mDirectTarget flag to track direct rendering state |
| src/renderer/gl_engine/tvgGlRenderer.cpp | Implements direct rendering logic with capability validation and task selection |
| src/renderer/gl_engine/tvgGlRenderTask.cpp | Conditionally calls onResolve() only for internal framebuffers |
| src/renderer/gl_engine/tvgGlRenderTarget.h | Updates initialization signature and validity tracking to support external framebuffers |
| src/renderer/gl_engine/tvgGlRenderTarget.cpp | Implements external framebuffer handling and improved cleanup logic |
| src/renderer/gl_engine/tvgGlCommon.h | Defines minimum MSAA samples constant |
| src/renderer/gl_engine/tvgGl.h | Uncomments typedef for framebuffer attachment parameter query function |
| src/renderer/gl_engine/tvgGl.cpp | Enables GL function for querying framebuffer attachment parameters |
| src/bindings/wasm/tvgWasmLottieAnimation.cpp | Enables depth, stencil, and antialiasing in WebGL context attributes |
| examples/MultiCanvas.cpp | Configures SDL GL attributes for stencil and MSAA support |
| examples/Example.h | Configures SDL GL attributes for stencil and MSAA support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bb77a02 to
9a5cfb1
Compare
6069564 to
7b2c629
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7b2c629 to
a8d392f
Compare
a8d392f to
093b875
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
093b875 to
bcafa5c
Compare
When we render to an FBO, we are completely bypassed the macOS Window System until the final display. Removing FBO is a macOS pessimization. The FBO must be restored for macOS to decouple the render thread from the WindowServer. Footnotes |
|
@wenjieshen Hello, Mac is not our primary target for OpenGL. It's deprecated. Rather windows or linux system is more practical test for us. |
3d21d53 to
9f4632d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9f4632d to
bd6284e
Compare
bd6284e to
63001ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
63001ee to
0084897
Compare
0084897 to
2233f7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Allows the engine to render directly to the screen's back buffer, bypassing intermediate framebuffers when possible. This change introduces a new `mDirectTarget` flag to indicate whether the rendering target is the back buffer. When rendering directly, it uses a compose task instead of a blit task, and avoids unnecessary framebuffer operations. This improves rendering performance and reduces memory consumption in scenarios where direct rendering is feasible. Related issues: #3951
2233f7c to
b5fb343
Compare
|
@SergeyLebedkin Hello, please confirm the performance beneficial on your side. Thanks. |
|
Large animation: Lottie: As I can see we have performance degradation |
|
@SergeyLebedkin Thanks for reviewing. Could you please share your device and OS information with me? It would also be great if you could share the log as well. |
|
|
@SergeyLebedkin Could you please test on windows machine? Thanks. |
|
@wenjieshen please rebase & update the |
Allows the engine to render directly to the screen's back buffer, bypassing intermediate framebuffers when possible.
This change introduces a new
mDirectTargetflag to indicate whether the rendering target is the back buffer. When rendering directly, it uses a compose task instead of a blit task and avoids unnecessary framebuffer operations.This improves rendering performance and reduces memory consumption in scenarios where direct rendering is feasible.
The WASM binding requires modification to enable this feature.
Related issues: #3951
Evaluation
Summary
Overall, the feature branch is performance-safe and shows significant improvements at high resolutions, especially in 4K scenarios.
1. Large Animation
Overall FPS
Steady-State FPS (last 20 intervals)
Jitter (stddev/mean)
Conclusion: Tiny gain, effectively identical to origin. No regression.
2. Lottie Animation
Overall FPS
Steady-State FPS
Jitter
Conclusion: Clear 3–5% FPS gain with higher variability. Still stable.
3. Small Animation (Normal Resolution)
Overall FPS
Steady-State FPS
Jitter
Conclusion: +3% overall from faster warm-up; steady-state identical.
4. Small Animation (4K Resolution)
Overall FPS
Steady-State FPS
Jitter
Conclusion: Major performance uplift at 4K — both average and steady-state FPS improve significantly.
5. Resolution Scaling (Normal → 4K)
Origin Branch
Feature Branch
Conclusion: The feature branch is far more resolution-robust.
Origin loses half its steady-state FPS, while the feature retains much more performance.
6. WebGL Multi-Animation Test (Qualitative)
Tested using the WebGL/DevTools HUD for 1 minute.
Feature Build
Origin Build
Conclusion:
Notes