mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
GL: Delete frame buffers after use.
Before, we used to never call glDeleteFramebuffers, which could in theory lead to leaks in the number of frame buffers available and make releasing the GL context more expensive. PiperOrigin-RevId: 514387847
This commit is contained in:
parent
a81a5f2699
commit
729066fbd6
3 changed files with 11 additions and 0 deletions
|
|
@ -645,6 +645,14 @@ public final class GlUtil {
|
|||
return fboId[0];
|
||||
}
|
||||
|
||||
/** Deletes a framebuffer. */
|
||||
public static void deleteFbo(int fboId) throws GlException {
|
||||
int[] fboIdArray = new int[1];
|
||||
fboIdArray[0] = fboId;
|
||||
GLES20.glDeleteFramebuffers(/* n= */ 1, fboIdArray, /* offset= */ 0);
|
||||
checkGlError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws a {@link GlException} with the given message if {@code expression} evaluates to {@code
|
||||
* false}.
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ import java.util.concurrent.Executor;
|
|||
while (allTextures.hasNext()) {
|
||||
TextureInfo textureInfo = allTextures.next();
|
||||
GlUtil.deleteTexture(textureInfo.texId);
|
||||
GlUtil.deleteFbo(textureInfo.fboId);
|
||||
}
|
||||
freeOutputTextures.clear();
|
||||
inUseOutputTextures.clear();
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ public abstract class SingleFrameGlShaderProgram implements GlShaderProgram {
|
|||
|| outputSize.getHeight() != outputTexture.height) {
|
||||
if (outputTexture != null) {
|
||||
GlUtil.deleteTexture(outputTexture.texId);
|
||||
GlUtil.deleteFbo(outputTexture.fboId);
|
||||
}
|
||||
int outputTexId = GlUtil.createTexture(outputSize.getWidth(), outputSize.getHeight(), useHdr);
|
||||
int outputFboId = GlUtil.createFboForTexture(outputTexId);
|
||||
|
|
@ -189,6 +190,7 @@ public abstract class SingleFrameGlShaderProgram implements GlShaderProgram {
|
|||
if (outputTexture != null) {
|
||||
try {
|
||||
GlUtil.deleteTexture(outputTexture.texId);
|
||||
GlUtil.deleteFbo(outputTexture.fboId);
|
||||
} catch (GlUtil.GlException e) {
|
||||
throw new VideoFrameProcessingException(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue