mirror of
https://github.com/androidx/media.git
synced 2025-05-09 00:20:45 +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.
|
* 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 {
|
public static long createGlSyncFence() throws GlException {
|
||||||
int[] currentEglContextVersion = new int[1];
|
int[] currentEglContextVersion = new int[1];
|
||||||
@ -404,14 +405,19 @@ public final class GlUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the following commands on the current OpenGL context will not be executed until
|
* Ensures that following commands on the current OpenGL context will not be executed until the
|
||||||
* the sync point has been reached. This does not block the CPU, and only affects the current
|
* sync point has been reached. If {@code syncObject} equals {@code 0}, this does not block the
|
||||||
* OpenGL context.
|
* CPU, and only affects the current OpenGL context. Otherwise, this will block the CPU.
|
||||||
*/
|
*/
|
||||||
public static void waitOnGpu(long syncObject) throws GlException {
|
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);
|
GLES30.glWaitSync(syncObject, /* flags= */ 0, GLES30.GL_TIMEOUT_IGNORED);
|
||||||
checkGlError();
|
checkGlError();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets the current {@link EGLContext context}. */
|
/** Gets the current {@link EGLContext context}. */
|
||||||
public static EGLContext getCurrentContext() {
|
public static EGLContext getCurrentContext() {
|
||||||
|
@ -32,7 +32,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.opengl.GLES20;
|
|
||||||
import androidx.media3.common.ColorInfo;
|
import androidx.media3.common.ColorInfo;
|
||||||
import androidx.media3.common.Effect;
|
import androidx.media3.common.Effect;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
@ -554,12 +553,7 @@ public final class DefaultVideoFrameProcessorTextureOutputPixelTest {
|
|||||||
.setInputType(VideoFrameProcessor.INPUT_TYPE_TEXTURE_ID)
|
.setInputType(VideoFrameProcessor.INPUT_TYPE_TEXTURE_ID)
|
||||||
.setEffects(effects)
|
.setEffects(effects)
|
||||||
.build();
|
.build();
|
||||||
if (syncObject == GL_FENCE_SYNC_FAILED) {
|
GlUtil.awaitSyncObject(syncObject);
|
||||||
// Fallback to using glFinish for synchronization when fence creation failed.
|
|
||||||
GLES20.glFinish();
|
|
||||||
} else {
|
|
||||||
GlUtil.waitOnGpu(syncObject);
|
|
||||||
}
|
|
||||||
videoFrameProcessorTestRunner.queueInputTexture(texture, presentationTimeUs);
|
videoFrameProcessorTestRunner.queueInputTexture(texture, presentationTimeUs);
|
||||||
try {
|
try {
|
||||||
videoFrameProcessorTestRunner.endFrameProcessing(VIDEO_FRAME_PROCESSING_WAIT_MS / 2);
|
videoFrameProcessorTestRunner.endFrameProcessing(VIDEO_FRAME_PROCESSING_WAIT_MS / 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user