Just reset the fb binding to 0 in ReadTexture

This saves a get operation. We already have precedent in lots of other MediaPipe code where we just reset bindings to 0.

PiperOrigin-RevId: 490170691
This commit is contained in:
Camillo Lugaresi 2022-11-22 00:35:27 -08:00 committed by Copybara-Service
parent bacbac8d92
commit d648926155

View File

@ -345,9 +345,6 @@ static void ReadTexture(GlContext& ctx, const GlTextureView& view,
GlTextureInfo info = GlTextureInfoForGpuBufferFormat( GlTextureInfo info = GlTextureInfoForGpuBufferFormat(
format, view.plane(), view.gl_context()->GetGlVersion()); format, view.plane(), view.gl_context()->GetGlVersion());
GLint previous_fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previous_fbo);
GLuint fbo = kUtilityFramebuffer.Get(ctx); GLuint fbo = kUtilityFramebuffer.Get(ctx);
glBindFramebuffer(GL_FRAMEBUFFER, fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, view.target(), glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, view.target(),
@ -356,8 +353,7 @@ static void ReadTexture(GlContext& ctx, const GlTextureView& view,
output); output);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0,
0); 0);
// TODO: just set the binding to 0 to avoid the get call? glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, previous_fbo);
} }
static std::shared_ptr<GpuBufferStorageImageFrame> ConvertToImageFrame( static std::shared_ptr<GpuBufferStorageImageFrame> ConvertToImageFrame(