Why is glDrawArrays failing on Intel Mesa 10.3, while working with nVidia using OpenGL 3.3

412 views Asked by At

I am trying to run Piccante image processing library on Intel GPU. The library is using OpenGL shaders to apply filters on images. The library is using OpenGL 4.0 according to its documentation, so I had to make a small modifications in order to get it to run in OpenGL 3.3 context, which is supported by Intel Mesa 10.3 driver.

I changed the following line (in buffer_op.hpp) when the shader is created:

prefix += glw::version("330");  // before glw::version("400")

After this modification the my program still works perfectly fine on nVidia GPU, even while initializing the OpenGL context as OpenGL 3.3 (Core Profile).

On the Intel GPU the program works partly. It seems to work fine as long as the images are single channel. When the images are RGB the drawing now longer works, and my images ends up black.

I have traced down the error to the following line in (quad.hpp):

void Render()
{
    glBindVertexArray(vao); // (I checked that vao is not 0 here)
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // glGetError() = 1286 (GL_INVALID_OPERATION)
    glBindVertexArray(0);
}

This is the initiations of the Vertex Array Object and the Vertex Buffer Object:

float *data = new float[8];

data[0] = -halfSizeX;
data[1] =  halfSizeY;

data[2] = -halfSizeX;
data[3] = -halfSizeY;

data[4] =  halfSizeX;
data[5] =  halfSizeY;

data[6] =  halfSizeX;
data[7] = -halfSizeY;

//Init VBO
glGenBuffers(1, &vbo[0]);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

//Init VAO
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);

glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);

glEnableVertexAttribArray(0);
glBindVertexArray(0);
glDisableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); 

This is the generated fragment shader I am trying to run:

 #version 330
 uniform sampler2D u_tex_1; 
 uniform vec4 u_val_0; 
 uniform vec4 u_val_1; 
 in vec2 v_tex_coord; 
 out vec4 f_color; 

 void main(void) { 
 ivec2 coords = ivec2(gl_FragCoord.xy);

 vec4 ret = u_val_0;

 f_color = ret; 
 }

I checked that the vertex shader and fragment shader compiles and links successfully. Does this mean that the shader should be GLSL 3.3 compatible and the problem is not within the shader but somewhere else?

What could be causing the program to fail on RGB images while it works fine on single channel images?

What could cause the program to fail with Intel Mesa 10.3 driver while working fine with nVidia driver when the context is initialized on both as OpenGL 3.3?

There seems to be a lot of reasons that could cause GL_INVALID_OPERATION when rendering. What other things could I check in order to trace down the error?

Thanks a lot for any help!

1

There are 1 answers

0
maitek On BEST ANSWER

I've been talking with Francesco Banterle, the author of Piccante library and he pointed out the following:

Regarding Intel Drivers, the issue is due to the fact these drivers do not automatically align buffers, so I may have to force three colors channel to be RGBA instead of RGB.

I changed the internal format from GL_RGB32F to GL_RGBA32F when loading the RGB textures:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0,
                 GL_RGB, GL_FLOAT, data); // before GL_RGB32F

This seemed to fix the problems on the Intel drivers.