cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

nilsk
Journeyman III

glTexSubImage2D problem with catalyst version 12.10

After upgrading to catalyst version 12.10 I encountered a new problem. This time it is related to using glTexSubImage2D while a pixel unpack buffer is bound. The code in init_resources below used to work with Version 12.8 and works with GL implementations of other vendors. With catalyst version 12.10 glTexSubImage2D will generate an INVALID_OPERATION error unless the minification filter is set before the call to glTexSubImage2D. I looked at the OpenGL sdk documentation and skimmed the spec but couldn't find any case in which glTexSubImage2D is supposed to produce that error for this situation. If no pixel unpack buffer is bound it works as expected.

test case

#include "stdafx.h"

#include "GL/glew.h"

#include "GL/glut.h"

#include <vector>

void check_gl_errors(){

    GLenum err=glGetError();

    if (err!=GL_NO_ERROR){

        const GLubyte* error_string = gluErrorString(err);

        __debugbreak();

    }

}

int init_resources(){

    const int width = 256;

    const int height = 128;

    const int bytes_per_pixel = 4;

    const int tex_size = width*height* sizeof(GLubyte)*bytes_per_pixel;

    GLubyte tex_data[tex_size];

    GLuint tex_id;

    GLuint buffer;

    glEnable(GL_TEXTURE_2D);

    glGenTextures(1, &tex_id);

    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

    glBindTexture(GL_TEXTURE_2D, tex_id);

    glActiveTexture(GL_TEXTURE0);

    glBindTexture(GL_TEXTURE_2D,tex_id);

//if glTexParameteri isn't called before glTexSubImage2D, glTexSubImage2D will generate an INVALID_OPERATION error

//    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA , GL_UNSIGNED_BYTE, tex_data);

    glGenBuffers(1, &buffer);

    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);

    glBufferData(GL_PIXEL_UNPACK_BUFFER, tex_size, NULL, GL_STATIC_DRAW);

    void * pbo_memory = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);

    ZeroMemory(pbo_memory, tex_size);

    glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);

    glPixelStorei(GL_UNPACK_ALIGNMENT , 4);

    glPixelStorei(GL_UNPACK_ROW_LENGTH , width);

    glPixelStorei(GL_UNPACK_SKIP_PIXELS , 0);

    glPixelStorei(GL_UNPACK_SKIP_ROWS , 0);

    glBindTexture( GL_TEXTURE_2D, tex_id);

    check_gl_errors();

    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA , GL_UNSIGNED_BYTE, 0);

    check_gl_errors();

    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

    glBindTexture( GL_TEXTURE_2D, 0);

    return true;

}

void onDisplay()

{

    glClear(GL_COLOR_BUFFER_BIT);

    glClearColor(0.0, 0.0, 0.0, 1.0);

    glutSolidOctahedron();

    glutReportErrors();

    glutSwapBuffers();

}

int main(int argc, char** argv)

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);

    glutInitWindowSize(640, 480);

    glutCreateWindow("gltestcase");

    GLenum glew_status = glewInit();

    if (glew_status != GLEW_OK)

    {

        fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));

        return EXIT_FAILURE;

    }

    if (1 == init_resources())    {

        glutDisplayFunc(onDisplay);

        glutMainLoop();

    }

    return 0;

}

Windows 7 , 64bit

Driver Packaging Version    9.002-120928m-148276C-ATI

Catalyst Version    12.10

Provider    Advanced Micro Devices, Inc.

2D Driver Version    8.01.01.1266

Direct3D Version    9.14.10.0926

OpenGL Version    6.14.10.11931

Catalyst Control Center Version    2012.0928.1532.26058

0 Likes
1 Reply
zoomzoom
Adept I

I have run into the same problem myself.

I am also using glTexSubImage2D with a pixel unpack buffer, followed by glTexParameteri. The same error, GL_INVALID_OPERATION, is returned by glGetError.

Fortunately, glTexParameteri can easily be called before glTexSubImage2D in my program, so thanks for the suggested workaround.

On the other hand, I found nothing mentioned about such a restriction in the OpenGL documentation. And, as usual, I have seen no such error on NVidia GPUs so far.

Here are the details of my configuration:

Windows 7, 64bit

AMD Radeon HD 7800

Driver Version: 12.104.0.0 - Catalyst 13.4 (3-28-2013)

OpenGL 4.2

0 Likes