Skip to content
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

RenderTexture#destroy destroys the depth texture as well. #6561

Merged
merged 5 commits into from
Apr 15, 2020
Merged

Conversation

ShukantPal
Copy link
Member

@ivanpopelyshev
Copy link
Collaborator

Maybe it would be better to move it to dispose(). Technically its the same thing for Framebuffer, because its never recovering.. hm...

Copy link
Collaborator

@ivanpopelyshev ivanpopelyshev left a comment

Choose a reason for hiding this comment

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

OK, good enough for a fix. we can refactor it later if someone gets idea how

@ShukantPal
Copy link
Member Author

@ivanpopelyshev Dispose just removes the framebuffer from the GPU. Destroy will destroy the data itself.

We shouldn't move this to dispose. Framebuffer#dispose disposes the depth texture already by disposing the framebuffer-object, which holds the depth texture on the GPU.

@ivanpopelyshev
Copy link
Collaborator

We shouldn't move this to dispose. Framebuffer#dispose disposes the depth texture already by disposing the framebuffer-object, which holds the depth texture on the GPU.

Nope, that's the point - depthTexture is not disposed on the GPU automatically. Framebuffer disposes itself and renderbuffer if mounted, but not depthTexture.

            gl.deleteFramebuffer(fbo.framebuffer);
            if (fbo.stencil)
            {
                gl.deleteRenderbuffer(fbo.stencil);
            }

Oh, I feel that we are missing MSAA case here: fboFramebuffer should be also disposed automatically :(

@ShukantPal
Copy link
Member Author

@ivanpopelyshev Correct, because the depth texture was not added internally by the framebuffer system. This is way you cannot run gl.deleteTexture on the depth-texture - this is equivalent of destroying (not disposing) the depth texture: https://github.com/pixijs/pixi.js/blob/9cdb526a9bfbc4643d36a106be3f2b16981e516d/packages/core/src/textures/TextureSystem.ts#L353

@ShukantPal
Copy link
Member Author

ShukantPal commented Apr 15, 2020

The user might not want to destroy the depth texture and may reuse it after disposing the framebuffer. That is not the case for the stencil renderbuffer, because it is never manually added to the framebuffer.

@ivanpopelyshev
Copy link
Collaborator

Agree. But then it might be user problem to destroy the depth texture when he destroys renderTexture and we dont need this PR.

I don't think it matters, we can change it later, lets merge this one.

@ShukantPal
Copy link
Member Author

ShukantPal commented Apr 15, 2020

@ivanpopelyshev Agreed, it is all semantics. Putting it in render-texture makes more sense for now, as it is a higher-level API and users might face problems like with 6556.

The user can still "snatch" the depth texture before it gets destroyed by listening to "dispose" on the base render-texture.

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

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

Looks good. One small request: could you add a simple unit-test check for this? Want to make sure we capture the behavior that destroying a BaseRenderTexture also destroys the depthTexture.

@ShukantPal
Copy link
Member Author

@bigtimebuddy Done!

@bigtimebuddy
Copy link
Member

Did you forget to commit RenderTexture? Error: Cannot find module './RenderTexture'

@ShukantPal
Copy link
Member Author

@bigtimebuddy Yup, I forgot a git add .

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

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

Good work @SukantPal!

@bigtimebuddy bigtimebuddy added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Apr 15, 2020
@bigtimebuddy bigtimebuddy merged commit 86b88fe into dev Apr 15, 2020
@bigtimebuddy bigtimebuddy deleted the fix-6556 branch April 15, 2020 17:42
@bigtimebuddy bigtimebuddy mentioned this pull request Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Framebuffer does not release depth buffer when destroyed, causing GPU memory leak
3 participants