-
Notifications
You must be signed in to change notification settings - Fork 211
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(webgl) texture to texture copy; framebuffer state leak #2042
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.
Thanks, apologize for removing that rebind. It is quite a hack, changing the underlying webgl function, but seems we do need it.
I hope the debugging required to nail this wasn't too painful.
@@ -181,7 +183,9 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO | |||
); | |||
} finally { | |||
device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, null); | |||
device.gl.bindFramebuffer(GL.FRAMEBUFFER, null); | |||
if (prevHandle !== undefined) { |
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.
Hmm - When do we get undefined? When not instrumented?
Can we add a comment explaining why we do not reset in this case.
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 assignment of prevHandle
is in a try/catch so the code may not get executed.
// destinationZ = destinationZ || 0; | ||
device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle); | ||
// @ts-expect-error native bindFramebuffer is overridden by our state tracker | ||
const prevHandle: WebGLFramebuffer | null = device.gl.bindFramebuffer( |
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.
No undefined here.
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.
Not in a try/catch.
switch (textureTarget) { | ||
case GL.TEXTURE_2D: | ||
case GL.TEXTURE_CUBE_MAP: | ||
device.gl.copyTexSubImage2D( |
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.
There are new helper functions for 9.1 in webgl-texture-helpers that take care of calling the right webgl function and handle more cases, but if this is meant for cherry-pick to 9.0 the maybe aligning with those can be a separate step.
Change List
WEBGLFramebuffer
constructor resets framebuffer binding to previous handle instead of nullWEBGLCommandBuffer
copy-texture-to-buffer resets framebuffer binding to previous handle instead of nullWEBGLCommandBuffer
copy-texture-to-texture