Do not store RGB textures with RGBA internal format.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Mar 2014 21:05:33 +0000 (22:05 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Mar 2014 21:05:33 +0000 (22:05 +0100)
Once again, GLES doesn't like this, even though the GPU probably does it
internally nevertheless.

flat_input.cpp
resource_pool.cpp

index 5978ca3..24b5709 100644 (file)
@@ -50,6 +50,8 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
                                internal_format = GL_R32F;
                        } else if (pixel_format == FORMAT_RG) {
                                internal_format = GL_RG32F;
+                       } else if (pixel_format == FORMAT_RGB) {
+                               internal_format = GL_RGB32F;
                        } else {
                                internal_format = GL_RGBA32F;
                        }
@@ -58,6 +60,8 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
                                internal_format = GL_R16F;
                        } else if (pixel_format == FORMAT_RG) {
                                internal_format = GL_RG16F;
+                       } else if (pixel_format == FORMAT_RGB) {
+                               internal_format = GL_RGB16F;
                        } else {
                                internal_format = GL_RGBA16F;
                        }
@@ -66,6 +70,8 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
                                internal_format = GL_R16;
                        } else if (pixel_format == FORMAT_RG) {
                                internal_format = GL_RG16;
+                       } else if (pixel_format == FORMAT_RGB) {
+                               internal_format = GL_RGB16;
                        } else {
                                internal_format = GL_RGBA16;
                        }
@@ -78,6 +84,8 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
                                internal_format = GL_R8;
                        } else if (pixel_format == FORMAT_RG) {
                                internal_format = GL_RG8;
+                       } else if (pixel_format == FORMAT_RGB) {
+                               internal_format = GL_RGB8;
                        } else {
                                internal_format = GL_RGBA8;
                        }
index 0557751..9beae1b 100644 (file)
@@ -186,8 +186,14 @@ GLuint ResourcePool::create_2d_texture(GLint internal_format, GLsizei width, GLs
        case GL_SRGB8_ALPHA8:
                format = GL_RGBA;
                break;
+       case GL_RGB32F:
+       case GL_RGB16F:
+       case GL_RGB8:
+               format = GL_RGB;
+               break;
        case GL_RG32F:
        case GL_RG16F:
+       case GL_RG8:
                format = GL_RG;
                break;
        case GL_R32F:
@@ -205,14 +211,18 @@ GLuint ResourcePool::create_2d_texture(GLint internal_format, GLsizei width, GLs
        switch (internal_format) {
        case GL_RGBA32F_ARB:
        case GL_RGBA16F_ARB:
+       case GL_RGB32F:
+       case GL_RGB16F:
        case GL_RG32F:
        case GL_RG16F:
        case GL_R32F:
        case GL_R16F:
                type = GL_FLOAT;
                break;
-       case GL_RGBA8:
        case GL_SRGB8_ALPHA8:
+       case GL_RGBA8:
+       case GL_RGB8:
+       case GL_RG8:
        case GL_R8:
                type = GL_UNSIGNED_BYTE;
                break;
@@ -273,10 +283,20 @@ size_t ResourcePool::estimate_texture_size(const Texture2D &texture_format)
        case GL_RGBA16F_ARB:
                bytes_per_pixel = 8;
                break;
+       case GL_RGB32F_ARB:
+               bytes_per_pixel = 12;
+               break;
+       case GL_RGB16F_ARB:
+               bytes_per_pixel = 6;
+               break;
        case GL_RGBA8:
        case GL_SRGB8_ALPHA8:
                bytes_per_pixel = 4;
                break;
+       case GL_RGB8:
+       case GL_SRGB8:
+               bytes_per_pixel = 3;
+               break;
        case GL_RG32F:
                bytes_per_pixel = 8;
                break;