2 #include "GLPlainTexture.h" 5 #include "caffe2/core/logging.h" 6 #include "caffe2/core/timer.h" 8 #define half_float_supported (GLContext::getGLContext()->halfFloatTextureSupported()) 10 #define FIXED_TYPE(_t) (((_t).type != GL_HALF_FLOAT || half_float_supported) ? (_t) : GLTexture::FP16_COMPAT) 12 GLPlainTexture::GLPlainTexture(
13 const Type& type,
const void* input, GLsizei width, GLsizei height,
bool use_padding, GLint filter, GLint wrap)
14 :
GLTexture(FIXED_TYPE(type), width, height, use_padding, filter, wrap) {
17 glGenTextures(1, &_textureId);
18 glBindTexture(GL_TEXTURE_2D, _textureId);
19 glTexImage2D(GL_TEXTURE_2D, 0, _type.internalFormat, _stride, _height, 0, _type.format, _type.type, input);
23 "GLPlainTexture() - allocated textureId %d, internalFormat: 0x%X, format: 0x%X, type: 0x%X\n",
29 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _filter);
30 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _filter);
32 #if GL_EXT_texture_border_clamp 33 GLfloat borderColor[] = {0.0f, 0.0f, 0.0f, 0.0f};
34 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR_EXT, borderColor);
36 _wrap = GL_CLAMP_TO_BORDER_EXT;
39 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _wrap);
40 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _wrap);
42 glBindTexture(GL_TEXTURE_2D, 0);
46 GLPlainTexture::GLPlainTexture(
47 const Type& type,
const GLuint textureID, GLsizei width, GLsizei height,
bool use_padding, GLint filter, GLint wrap)
48 :
GLTexture(FIXED_TYPE(type), width, height, use_padding, filter, wrap) {
49 _textureId = textureID;
53 "GLPlainTexture() - wrapped textureId %d, internalFormat: 0x%X, format: 0x%X, type: 0x%X\n",