Caffe2 - C++ API
A deep learning, cross platform ML framework
GLContext.h
1 
2 #pragma once
3 #include "GLTexture.h"
4 #include "caffe2/core/common.h"
5 #include <functional>
6 
7 class GLContext {
8  private:
9  static std::unique_ptr<GLContext> _glcontext;
10  std::function<const GLTexture*(const int width, const int height)> foreignTextureAllocator =
11  nullptr;
12 
13  protected:
14  bool half_float_supported = true;
15 
16  public:
17  virtual void set_context() = 0;
18  virtual void reset_context() = 0;
19  virtual void flush_context() = 0;
20  virtual ~GLContext(){};
21 
22  static void initGLContext();
23  static GLContext* getGLContext();
24  static void deleteGLContext();
25 
26  static bool GL_EXT_texture_border_clamp_defined();
27 
28  inline bool halfFloatTextureSupported() { return half_float_supported; }
29 
30  void setTextureAllocator(
31  std::function<const GLTexture*(const int width, const int height)> textureAllocator) {
32  foreignTextureAllocator = textureAllocator;
33  }
34 
35  std::function<const GLTexture*(const int width, const int height)> getTextureAllocator() {
36  return foreignTextureAllocator;
37  }
38 };
39 
40 bool supportOpenGLES3(bool* hfs = nullptr);
41 
42 bool isSupportedDevice();
43 
44 #if CAFFE2_IOS
45 int iPhoneVersion();
46 #endif