GL: Remove redundant use() call.

This is already called in GlUtil.Program().

Tested by confirming that the demo-gl target still runs as expected.

Refactoring change only. No intended functional changes.

PiperOrigin-RevId: 412308564
This commit is contained in:
huangdarwin 2021-11-25 19:11:18 +00:00 committed by tonihei
parent a7d7c7b73a
commit f0fcad16a9
3 changed files with 12 additions and 8 deletions

View File

@ -42,7 +42,7 @@ import java.util.HashMap;
import java.util.Map;
import javax.microedition.khronos.egl.EGL10;
/** GL utilities. */
/** OpenGL ES 2.0 utilities. */
@UnstableApi
public final class GlUtil {
@ -86,7 +86,10 @@ public final class GlUtil {
}
/**
* Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code.
* Creates a GL shader program from vertex and fragment shader GLSL GLES20 code.
*
* <p>This involves slow steps, like compiling, linking, and switching the GL program, so do not
* call this in fast rendering loops.
*
* @param vertexShaderGlsl The vertex shader program.
* @param fragmentShaderGlsl The fragment shader program.
@ -129,8 +132,14 @@ public final class GlUtil {
checkGlError();
}
/** Uses the program. */
/**
* Uses the program.
*
* <p>Call this in the rendering loop to switch between different programs.
*/
public void use() {
// TODO(http://b/205002913): When multiple GL programs are supported by Transformer, make sure
// to call use() to switch between programs.
GLES20.glUseProgram(programId);
checkGlError();
}

View File

@ -168,7 +168,6 @@ public final class VideoDecoderGLSurfaceView extends GLSurfaceView
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
program = new GlUtil.Program(VERTEX_SHADER, FRAGMENT_SHADER);
program.use();
int posLocation = program.getAttributeArrayLocationAndEnable("in_pos");
GLES20.glVertexAttribPointer(
posLocation,

View File

@ -15,7 +15,6 @@
*/
package androidx.media3.exoplayer.video.spherical;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.GlUtil.checkGlError;
import android.opengl.GLES11Ext;
@ -139,9 +138,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
// Configure shader.
checkNotNull(program).use();
checkGlError();
float[] texMatrix;
if (stereoMode == C.STEREO_MODE_TOP_BOTTOM) {
texMatrix = rightEye ? TEX_MATRIX_BOTTOM : TEX_MATRIX_TOP;