2019-04-17 10:49:11 +08:00
|
|
|
//
|
2019-05-24 11:26:54 +08:00
|
|
|
// GLProgram.hpp
|
2019-04-17 10:49:11 +08:00
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2019/01/31.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef GLPROGRAM_H
|
|
|
|
#define GLPROGRAM_H
|
|
|
|
|
|
|
|
#include <string>
|
2019-12-27 22:16:57 +08:00
|
|
|
#include "backend/opengl/GLHead.hpp"
|
|
|
|
#include "backend/opengl/GLLock.hpp"
|
2019-04-17 10:49:11 +08:00
|
|
|
namespace MNN {
|
2019-05-24 11:26:54 +08:00
|
|
|
namespace OpenGL {
|
2019-04-17 10:49:11 +08:00
|
|
|
class GLProgram {
|
|
|
|
public:
|
|
|
|
GLProgram(const std::string& computeShader);
|
|
|
|
virtual ~GLProgram();
|
|
|
|
|
2019-05-24 11:26:54 +08:00
|
|
|
inline unsigned int getProgramId() const {
|
|
|
|
return mProgramId;
|
2019-04-17 10:49:11 +08:00
|
|
|
}
|
|
|
|
|
2019-07-25 13:36:35 +08:00
|
|
|
static std::string getHead(std::string imageFormat);
|
2019-04-17 10:49:11 +08:00
|
|
|
|
|
|
|
/*These API must be called in openGL context Thread*/
|
2019-05-24 11:26:54 +08:00
|
|
|
void useProgram();
|
|
|
|
int getAttribLocation(const char* name) const;
|
|
|
|
int getUniformLocation(const char* name) const;
|
2019-04-17 10:49:11 +08:00
|
|
|
|
|
|
|
private:
|
2019-05-24 11:26:54 +08:00
|
|
|
bool compileShader(GLuint s);
|
|
|
|
unsigned int mShaderId = 0;
|
|
|
|
unsigned int mProgramId = 0;
|
2019-04-17 10:49:11 +08:00
|
|
|
};
|
2019-05-24 11:26:54 +08:00
|
|
|
} // namespace OpenGL
|
2019-04-17 10:49:11 +08:00
|
|
|
} // namespace MNN
|
|
|
|
|
|
|
|
#endif
|