Use kUtilityFramebuffer in GlCalculatorHelper

All calculators using the same context can share a single framebuffer object.

PiperOrigin-RevId: 490605074
This commit is contained in:
Camillo Lugaresi 2022-11-23 16:17:02 -08:00 committed by Copybara-Service
parent 41a7f9d7d6
commit 0bdb48ceb1

View File

@ -27,19 +27,7 @@ namespace mediapipe {
GlCalculatorHelper::GlCalculatorHelper() {} GlCalculatorHelper::GlCalculatorHelper() {}
GlCalculatorHelper::~GlCalculatorHelper() { GlCalculatorHelper::~GlCalculatorHelper() {}
if (!Initialized()) return;
RunInGlContext(
[this] {
if (framebuffer_) {
glDeleteFramebuffers(1, &framebuffer_);
framebuffer_ = 0;
}
return absl::OkStatus();
},
/*calculator_context=*/nullptr)
.IgnoreError();
}
void GlCalculatorHelper::InitializeInternal(CalculatorContext* cc, void GlCalculatorHelper::InitializeInternal(CalculatorContext* cc,
GpuResources* gpu_resources) { GpuResources* gpu_resources) {
@ -125,9 +113,9 @@ void GlCalculatorHelper::CreateFramebuffer() {
// Our framebuffer will have a color attachment but no depth attachment, // 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, // so it's important that the depth test be off. It is disabled by default,
// but we wanted to be explicit. // but we wanted to be explicit.
// TODO: move this to glBindFramebuffer? // TODO: move this to glBindFramebuffer? Or just remove.
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glGenFramebuffers(1, &framebuffer_); framebuffer_ = kUtilityFramebuffer.Get(*gl_context_);
} }
void GlCalculatorHelper::BindFramebuffer(const GlTexture& dst) { void GlCalculatorHelper::BindFramebuffer(const GlTexture& dst) {