No public description

PiperOrigin-RevId: 592683556
This commit is contained in:
MediaPipe Team 2023-12-20 16:13:48 -08:00 committed by Copybara-Service
parent 52c1d44561
commit 835ee5e354
3 changed files with 42 additions and 7 deletions

View File

@ -196,6 +196,7 @@ cc_library(
":gpu_buffer_format", ":gpu_buffer_format",
"//mediapipe/framework:executor", "//mediapipe/framework:executor",
"//mediapipe/framework:mediapipe_profiling", "//mediapipe/framework:mediapipe_profiling",
"//mediapipe/framework:port",
"//mediapipe/framework:timestamp", "//mediapipe/framework:timestamp",
"//mediapipe/framework/port:logging", "//mediapipe/framework/port:logging",
"//mediapipe/framework/port:ret_check", "//mediapipe/framework/port:ret_check",

View File

@ -27,6 +27,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
#include "mediapipe/framework/port.h" // IWYU pragma: keep
#include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/ret_check.h"
#include "mediapipe/framework/port/status.h" #include "mediapipe/framework/port/status.h"
#include "mediapipe/framework/port/status_builder.h" #include "mediapipe/framework/port/status_builder.h"
@ -48,6 +49,17 @@
namespace mediapipe { namespace mediapipe {
namespace internal_gl_context {
bool IsOpenGlVersionSameOrAbove(const OpenGlVersion& version,
const OpenGlVersion& expected_version) {
return (version.major == expected_version.major &&
version.minor >= expected_version.minor) ||
version.major > expected_version.major;
}
} // namespace internal_gl_context
static void SetThreadName(const char* name) { static void SetThreadName(const char* name) {
#if defined(__GLIBC_PREREQ) #if defined(__GLIBC_PREREQ)
#define LINUX_STYLE_SETNAME_NP __GLIBC_PREREQ(2, 12) #define LINUX_STYLE_SETNAME_NP __GLIBC_PREREQ(2, 12)
@ -815,15 +827,25 @@ class GlNopSyncPoint : public GlSyncPoint {
#endif #endif
bool GlContext::ShouldUseFenceSync() const { bool GlContext::ShouldUseFenceSync() const {
#ifdef __EMSCRIPTEN__ using internal_gl_context::OpenGlVersion;
#if defined(__EMSCRIPTEN__)
// In Emscripten the glWaitSync function is non-null depending on linkopts, // In Emscripten the glWaitSync function is non-null depending on linkopts,
// but only works in a WebGL2 context, so fall back to use Finish if it is a // but only works in a WebGL2 context.
// WebGL1/ES2 context. constexpr OpenGlVersion kMinVersionSyncAvaiable = {.major = 3, .minor = 0};
// TODO: apply this more generally once b/152794517 is fixed. #elif defined(MEDIAPIPE_MOBILE)
return gl_major_version() > 2; // OpenGL ES, glWaitSync is available since 3.0
constexpr OpenGlVersion kMinVersionSyncAvaiable = {.major = 3, .minor = 0};
#else #else
return SymbolAvailable(&glWaitSync); // TODO: specify major/minor version per remaining platforms.
#endif // __EMSCRIPTEN__ // By default, ignoring major/minor version requirement for backward
// compatibility.
constexpr OpenGlVersion kMinVersionSyncAvaiable = {.major = 0, .minor = 0};
#endif
return SymbolAvailable(&glWaitSync) &&
internal_gl_context::IsOpenGlVersionSameOrAbove(
{.major = gl_major_version(), .minor = gl_minor_version()},
kMinVersionSyncAvaiable);
} }
std::shared_ptr<GlSyncPoint> GlContext::CreateSyncToken() { std::shared_ptr<GlSyncPoint> GlContext::CreateSyncToken() {

View File

@ -487,6 +487,18 @@ ABSL_DEPRECATED(
const GlTextureInfo& GlTextureInfoForGpuBufferFormat(GpuBufferFormat format, const GlTextureInfo& GlTextureInfoForGpuBufferFormat(GpuBufferFormat format,
int plane); int plane);
namespace internal_gl_context {
struct OpenGlVersion {
int major;
int minor;
};
bool IsOpenGlVersionSameOrAbove(const OpenGlVersion& version,
const OpenGlVersion& expected_version);
} // namespace internal_gl_context
} // namespace mediapipe } // namespace mediapipe
#endif // MEDIAPIPE_GPU_GL_CONTEXT_H_ #endif // MEDIAPIPE_GPU_GL_CONTEXT_H_