From 4b75397f4e50470dbaa063c8e3dcabb65f175636 Mon Sep 17 00:00:00 2001 From: tofunmi Date: Fri, 28 Apr 2023 12:32:52 +0100 Subject: [PATCH] Rollback of https://github.com/androidx/media/commit/5c022103053cb3e127685f2177a456cffc68aecc *** Original commit *** Effect: glFlush instead of glFinish on tex output This is much faster (~2-3x) than glFlush. While there's a risk that GL commands queued to the GL server may not be complete by the time non-GL commands access the texture, this should be unlikely as we only access the texture from GL. If we see stability issues in the future, we can reconsider and move this back to glFinish (or GL synchronization mechanisms like fences, which are more complex) *** PiperOrigin-RevId: 527848094 --- .../androidx/media3/effect/FinalShaderProgramWrapper.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libraries/effect/src/main/java/androidx/media3/effect/FinalShaderProgramWrapper.java b/libraries/effect/src/main/java/androidx/media3/effect/FinalShaderProgramWrapper.java index 6185f37103..ef57aa623e 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/FinalShaderProgramWrapper.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/FinalShaderProgramWrapper.java @@ -360,13 +360,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; outputTexture.fboId, outputTexture.width, outputTexture.height); GlUtil.clearOutputFrame(); checkNotNull(defaultShaderProgram).drawFrame(inputTexture.texId, presentationTimeUs); - - // glFlush is used here instead of glFinish due to the performance regression that blocking this - // thread would do when calling glFinish. As glFlush is non-blocking, it's possible that non-GL - // access to the output texture may read stale data (ex. from the prior frame). If we see issues - // (ex. flakiness) from glFlush, consider requiring apps reading the texture to call glFinish, - // or reconsider using glFinish here. - GLES20.glFlush(); + GLES20.glFinish(); checkNotNull(textureOutputListener).onTextureRendered(outputTexture, presentationTimeUs); }