From 0bdb48ceb18a772158b92793daf6ac4bf8ce6f76 Mon Sep 17 00:00:00 2001 From: Camillo Lugaresi Date: Wed, 23 Nov 2022 16:17:02 -0800 Subject: [PATCH] Use kUtilityFramebuffer in GlCalculatorHelper All calculators using the same context can share a single framebuffer object. PiperOrigin-RevId: 490605074 --- mediapipe/gpu/gl_calculator_helper.cc | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/mediapipe/gpu/gl_calculator_helper.cc b/mediapipe/gpu/gl_calculator_helper.cc index 7d317e0f..9b217ddf 100644 --- a/mediapipe/gpu/gl_calculator_helper.cc +++ b/mediapipe/gpu/gl_calculator_helper.cc @@ -27,19 +27,7 @@ namespace mediapipe { GlCalculatorHelper::GlCalculatorHelper() {} -GlCalculatorHelper::~GlCalculatorHelper() { - if (!Initialized()) return; - RunInGlContext( - [this] { - if (framebuffer_) { - glDeleteFramebuffers(1, &framebuffer_); - framebuffer_ = 0; - } - return absl::OkStatus(); - }, - /*calculator_context=*/nullptr) - .IgnoreError(); -} +GlCalculatorHelper::~GlCalculatorHelper() {} void GlCalculatorHelper::InitializeInternal(CalculatorContext* cc, GpuResources* gpu_resources) { @@ -125,9 +113,9 @@ void GlCalculatorHelper::CreateFramebuffer() { // Our framebuffer will have a color attachment but no depth attachment, // so it's important that the depth test be off. It is disabled by default, // but we wanted to be explicit. - // TODO: move this to glBindFramebuffer? + // TODO: move this to glBindFramebuffer? Or just remove. glDisable(GL_DEPTH_TEST); - glGenFramebuffers(1, &framebuffer_); + framebuffer_ = kUtilityFramebuffer.Get(*gl_context_); } void GlCalculatorHelper::BindFramebuffer(const GlTexture& dst) {