-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add FramebufferManager
class
#9966
Conversation
Thanks for the pull request @ebogo1!
Reviewers, don't forget to make sure that:
|
@@ -2,14 +2,10 @@ import BoundingRectangle from "../Core/BoundingRectangle.js"; | |||
import Color from "../Core/Color.js"; |
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.
SceneFramebuffer
and PickDepth
can't be trimmed down much further but there's still a lot of room for improvement in GlobeDepth
. I'm mainly thinking about the render state and scissor code which is in four different files and somewhat complex and mistake prone. I don't have a clear idea of how this might be integrated in FramebufferManager
, if at all, but keep it in mind as you update the rest of the code.
While unfortunate I agree. Generally we want a |
Yes, the |
I don't have a concrete answer right now, but I think it will become clear as you start to update the other classes. General rule of thumb though is that any framebuffer that gets geometry rendered to it will need MSAA. This excludes framebuffers only used in full screen passes. |
@lilleyse ShadowMap is an interesting case, since the class doesn't own any of the Framebuffers or attachments it creates. This could change, but then ShadowMap would store more resources than it does now which is kind of the opposite of what I've been using cesium/Source/Scene/ShadowMap.js Lines 621 to 629 in 554baa1
|
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.
@lilleyse As of e42e8f8 this PR is almost ready to be undrafted.
Classes that are still constructing framebuffers manually (trimmed down after 7917da9) :
ComputeEngine
constructs a framebuffer for use in commands that are executed and then destroys the framebuffer right after. I'm not sure this is a good use case forFramebufferManager
.ShadowMap
constructs framebuffers with different sets of attachments based on variables that I believe can change at runtime (i.e.isPointLight
). Also, between the cubemap color textures and regular color texture, I think the value ofFramebufferManager._createColorAttachments
would also need to be changed at runtime. It is doable to change this code to useFramebufferManager
but I'm still not sure if it's a "good" use of the class unless the API is changed to give more runtime control over attachment management.TextureAtlas
is another case of creating a framebuffer and immediately destroying (and unbinding) it just to copy a texture over. This could probably useFramebufferManager
but after a first pass that doesn't seem like an improvement over the current code.
Still to-do:
- More docs where needed
-
FramebufferManager
specs - Validate edge cases in browser
} | ||
}); | ||
|
||
it("creates renderbuffer depth attachments if supportsDepthTexture is false", function () { |
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.
This behavior may cause errors to be avoided where previously they would be thrown. i.e., if a class used to always create depth textures without checking context.depthTexture
, an error would be thrown when the extension was unsupported. Instead, this now creates a renderbuffer if supportsDepthTexture
is disabled or if the extension is unsupported.
I noticed this in PickDepthFramebuffer
and PointCloudEyeDomeLighting
, but there might be a couple similar places.
FramebufferManager
class
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.
I still have a little ways to go but here's everything up to InvertClassification
@ebogo1 that should cover the rest of the files |
This is a pretty far reaching change so I went through a bunch of sandcastles to see if I could trigger any unexpected behavior. I also wanted to make sure that framebuffers were only recreated as needed, such as when the screen is resized or if HDR is toggled. I can't promise I've tested every corner case but things seem to be working well so far. Here's what I tested.
@ebogo1 as a final test could you go through all the sandcastles as if you were doing a release? I suggest doing something similar to what I did - print a message whenever a new framebuffer is created in FramebufferBuffer and make sure it gets printed only when it makes sense like when the screen is resized or HDR changes. Also check if there's any behavior I didn't test for. |
Going through all the Sandcastles, nothing looks out of place. Most framebuffers get created at runtime and when the canvas size changes. A couple other things I checked:
|
@ebogo1 cool, should be good to merge after the January 3rd release. |
@lilleyse I added a CHANGES.md entry for the 1.90 release - if the entry looks good this should be good to merge once CI passes. edit - do we want an entry for these changes? It's a big change but most of the new API is in a private class.. |
No need to add to CHANGES.md since it's all private and invisible to the user. I'll remove the commit and then merge. |
This reverts commit 77ae29b.
This PR adds the
FramebufferManager
class, which wraps Framebuffer resources (textures, depth stencil textures, renderbuffers, and the framebuffer itself) in a way that can be used by multiple classes that share similar code in constructing their own framebuffers. Inwrapper-msaa
,FramebufferManager
also supports the newMultisampleFramebuffer
class, which will eventually make it easier to add MSAA to framebuffers that need it. To make the changes easier to see, this also removes theprimitiveColorFramebuffer
from GlobeDepth.js.I think this should be opened as a draft PR first, because there are a few things I'm still unsure about:
Some framebuffers are constructed with multiple texture attachments, and(resolved by adding constructor options)FramebufferManager
currently expects a single attachment for color and depth stencil textures/renderbuffers. It feels clunky to have atextureOptions
argument to keep track of constructor options inFramebufferManager.update
, maybe if this is needed then it could go in the constructor instead?Some framebuffers depend on attachments that belong to another framebuffer. I think it's simplest to avoid the(resolved by allowing shared attachments to be added to aFramebufferManager
class for this case and to construct aFramebuffer
manually instead.FramebufferManager
manually)FramebufferManager
constructor instead of directly creatingFramebuffer
objects? If not, should theFramebufferManager
class be tailored to framebuffers that will need MSAA support?PickDepth
,PickDepthFramebuffer
,ShadowMap
,GlobeTranslucencyFramebuffer
,OIT
,PointCloudEyeDomeLighting
, andTranslucentTileClassification
.The MSAA issue is here - #9900
To-do: