-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix render window attach camera and resize logic #17414
Conversation
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.
LGTM
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
Interface Check ReportThis pull request does not change any public interfaces ! |
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.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
export function dispatchResizeEvents (cameras: Camera[], builder: PipelineBuilder, ppl: BasicPipeline): void { | ||
if (!builder.windowResize) { | ||
// No game window resize handler defined. | ||
// Following old prodecure, do nothing | ||
return; | ||
} | ||
|
||
// Resize all windows. | ||
// Notice: A window might be resized multiple times with different cameras. | ||
// User should avoid resource collision between different cameras. |
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.
What will happen if two or more cameras have have the same size?
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.
The custom pipeline resize logic of the specific render window will be called multiple times with different cameras.
This is by design, in order to:
- Reduce memory usage by reusing resources of the render window.
- Share render targets between different cameras.
User can also use camera name/index, to avoid collision if they really want.
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.
The cameras' sizes are the same of the render window.
When a new camera is attached to the render window, the render window will be set resized. The custom pipeline will update all associated resources.
Fix window resize logic, it will be resized multiple times with different cameras. User should reuse render window's resource and avoid collision.
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request:
Greptile Summary
The pull request improves the handling of render window resizing and camera attachment logic to prevent multiple resize operations and resource collisions.
_isResized
flag incocos/render-scene/core/render-window.ts
to track window resize state._resizedWindows
array incocos/rendering/custom/framework.ts
to manage resized windows and reset flags post-processing.attachCamera
method incocos/render-scene/core/render-window.ts
to set_isResized
flag when a new camera is attached.dispatchResizeEvents
function incocos/rendering/custom/framework.ts
to handle multiple cameras and avoid redundant resizing.native/cocos/scene/RenderWindow.cpp
to align with the new resize and camera attachment logic.