From d288891c77d26c4195359a280b1ec4de42979b91 Mon Sep 17 00:00:00 2001 From: tofunmi Date: Wed, 15 Mar 2023 18:21:18 +0000 Subject: [PATCH] Clear depth buffers in glUtil.clearOutputFrame. [GL documentation for glClear](https://registry.khronos.org/OpenGL-Refpages/gl4/html/glClear.xhtml) says "If a buffer is not present, then a glClear directed at that buffer has no effect." so it's okay to clear the depth buffer even if there isn't one set. Also manually tested to have no impact when contrast effect and dizzy crop effect form transformer demo was added to image/video input. PiperOrigin-RevId: 516879598 --- .../src/main/java/androidx/media3/common/util/GlUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java b/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java index ac349145e2..ee460831b8 100644 --- a/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java +++ b/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java @@ -434,7 +434,8 @@ public final class GlUtil { /** Fills the pixels in the current output render target with (r=0, g=0, b=0, a=0). */ public static void clearOutputFrame() throws GlException { GLES20.glClearColor(/* red= */ 0, /* green= */ 0, /* blue= */ 0, /* alpha= */ 0); - GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); + GLES20.glClearDepthf(1.0f); + GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); GlUtil.checkGlError(); }