mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
GL: Move fallback to glFinish to GlUtil.
This may happen, for example, on older OpenGL versions. This may be used in the compositor too. PiperOrigin-RevId: 544613566
This commit is contained in:
parent
9513f2c551
commit
a875fa72a8
@ -374,7 +374,8 @@ public final class GlUtil {
|
||||
/**
|
||||
* Returns a newly created sync object and inserts it into the GL command stream.
|
||||
*
|
||||
* <p>Returns 0 if the operation failed or the {@link EGLContext} version is less than 3.0.
|
||||
* <p>Returns {@code 0} if the operation failed or the {@link EGLContext} version is less than
|
||||
* 3.0.
|
||||
*/
|
||||
public static long createGlSyncFence() throws GlException {
|
||||
int[] currentEglContextVersion = new int[1];
|
||||
@ -404,13 +405,18 @@ public final class GlUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the following commands on the current OpenGL context will not be executed until
|
||||
* the sync point has been reached. This does not block the CPU, and only affects the current
|
||||
* OpenGL context.
|
||||
* Ensures that following commands on the current OpenGL context will not be executed until the
|
||||
* sync point has been reached. If {@code syncObject} equals {@code 0}, this does not block the
|
||||
* CPU, and only affects the current OpenGL context. Otherwise, this will block the CPU.
|
||||
*/
|
||||
public static void waitOnGpu(long syncObject) throws GlException {
|
||||
GLES30.glWaitSync(syncObject, /* flags= */ 0, GLES30.GL_TIMEOUT_IGNORED);
|
||||
checkGlError();
|
||||
public static void awaitSyncObject(long syncObject) throws GlException {
|
||||
if (syncObject == 0) {
|
||||
// Fallback to using glFinish for synchronization when fence creation failed.
|
||||
GLES20.glFinish();
|
||||
} else {
|
||||
GLES30.glWaitSync(syncObject, /* flags= */ 0, GLES30.GL_TIMEOUT_IGNORED);
|
||||
checkGlError();
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets the current {@link EGLContext context}. */
|
||||
|
@ -32,7 +32,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.opengl.GLES20;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.Effect;
|
||||
import androidx.media3.common.Format;
|
||||
@ -554,12 +553,7 @@ public final class DefaultVideoFrameProcessorTextureOutputPixelTest {
|
||||
.setInputType(VideoFrameProcessor.INPUT_TYPE_TEXTURE_ID)
|
||||
.setEffects(effects)
|
||||
.build();
|
||||
if (syncObject == GL_FENCE_SYNC_FAILED) {
|
||||
// Fallback to using glFinish for synchronization when fence creation failed.
|
||||
GLES20.glFinish();
|
||||
} else {
|
||||
GlUtil.waitOnGpu(syncObject);
|
||||
}
|
||||
GlUtil.awaitSyncObject(syncObject);
|
||||
videoFrameProcessorTestRunner.queueInputTexture(texture, presentationTimeUs);
|
||||
try {
|
||||
videoFrameProcessorTestRunner.endFrameProcessing(VIDEO_FRAME_PROCESSING_WAIT_MS / 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user