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",
"//mediapipe/framework:executor",
"//mediapipe/framework:mediapipe_profiling",
"//mediapipe/framework:port",
"//mediapipe/framework:timestamp",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:ret_check",

View File

@ -27,6 +27,7 @@
#include "absl/memory/memory.h"
#include "absl/status/status.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/status.h"
#include "mediapipe/framework/port/status_builder.h"
@ -48,6 +49,17 @@
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) {
#if defined(__GLIBC_PREREQ)
#define LINUX_STYLE_SETNAME_NP __GLIBC_PREREQ(2, 12)
@ -815,15 +827,25 @@ class GlNopSyncPoint : public GlSyncPoint {
#endif
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,
// but only works in a WebGL2 context, so fall back to use Finish if it is a
// WebGL1/ES2 context.
// TODO: apply this more generally once b/152794517 is fixed.
return gl_major_version() > 2;
// but only works in a WebGL2 context.
constexpr OpenGlVersion kMinVersionSyncAvaiable = {.major = 3, .minor = 0};
#elif defined(MEDIAPIPE_MOBILE)
// OpenGL ES, glWaitSync is available since 3.0
constexpr OpenGlVersion kMinVersionSyncAvaiable = {.major = 3, .minor = 0};
#else
return SymbolAvailable(&glWaitSync);
#endif // __EMSCRIPTEN__
// TODO: specify major/minor version per remaining platforms.
// 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() {

View File

@ -487,6 +487,18 @@ ABSL_DEPRECATED(
const GlTextureInfo& GlTextureInfoForGpuBufferFormat(GpuBufferFormat format,
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
#endif // MEDIAPIPE_GPU_GL_CONTEXT_H_