Add some helpful error messages in case GL texture creation fails.

PiperOrigin-RevId: 534029187
This commit is contained in:
MediaPipe Team 2023-05-22 05:01:36 -07:00 committed by Copybara-Service
parent 7c28c5d58f
commit 102cffdf4c
3 changed files with 11 additions and 3 deletions

View File

@ -295,6 +295,7 @@ cc_library(
"//mediapipe/framework/formats:image_frame",
"//mediapipe/framework/port:logging",
"@com_google_absl//absl/functional:bind_front",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
] + select({

View File

@ -47,6 +47,7 @@ std::unique_ptr<GlTextureBuffer> GlTextureBuffer::Create(int width, int height,
auto buf = absl::make_unique<GlTextureBuffer>(GL_TEXTURE_2D, 0, width, height,
format, nullptr);
if (!buf->CreateInternal(data, alignment)) {
LOG(WARNING) << "Failed to create a GL texture";
return nullptr;
}
return buf;
@ -106,7 +107,10 @@ GlTextureBuffer::GlTextureBuffer(GLenum target, GLuint name, int width,
bool GlTextureBuffer::CreateInternal(const void* data, int alignment) {
auto context = GlContext::GetCurrent();
if (!context) return false;
if (!context) {
LOG(WARNING) << "Cannot create a GL texture without a valid context";
return false;
}
producer_context_ = context; // Save creation GL context.

View File

@ -20,6 +20,7 @@
#include <memory>
#include <utility>
#include "absl/log/check.h"
#include "absl/synchronization/mutex.h"
#include "mediapipe/framework/formats/image_frame.h"
#include "mediapipe/gpu/gpu_buffer_format.h"
@ -72,8 +73,10 @@ class GpuBuffer {
// are not portable. Applications and calculators should normally obtain
// GpuBuffers in a portable way from the framework, e.g. using
// GpuBufferMultiPool.
explicit GpuBuffer(std::shared_ptr<internal::GpuBufferStorage> storage)
: holder_(std::make_shared<StorageHolder>(std::move(storage))) {}
explicit GpuBuffer(std::shared_ptr<internal::GpuBufferStorage> storage) {
CHECK(storage) << "Cannot construct GpuBuffer with null storage";
holder_ = std::make_shared<StorageHolder>(std::move(storage));
}
#if !MEDIAPIPE_DISABLE_GPU && MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER
// This is used to support backward-compatible construction of GpuBuffer from