Skip to main content
GameDev.net gamedev.net
🔒 Locked

glValidateProgram causing GL_OUT_OF_MEMORY error?

Started by d0nuts Mar 7, 2017 at 4:14 AM 1 replies 2.3k views
Original Post
d0nuts
d0nuts

Hi opengl experts,

I am trying out a compute shader for the first time to generate some terrain but I am getting GL_OUT_OF_MEMORY (error 1285) when trying to validate the shader.


std::string compute_source = R"(
        #version 430 core


        layout(local_size_x = 64, local_size_y = 64) in;


        struct TerrainPatch {
            vec2 pos;
            vec2 dim;
        };


        layout (std430, binding = 0) buffer InputBuffer {
            TerrainPatch patches[];
        };


        struct TerrainVertex {
            vec4 pos;
            vec4 nor;
        };


        layout (std430, binding = 1) buffer OutputBuffer {
            TerrainVertex vertexes[];
        };


        void main() {
            vertexes[0].pos = vec4(patches[0].pos, 0.0f, 0.0f);
        }
    )";


    const char* compute_source_chars = compute_source.c_str();


    GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
    glShaderSource(shader, 1, &compute_source_chars, NULL);
    glCompileShader(shader);


    GLint shader_status = GL_FALSE;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_status);
    assert(shader_status != GL_FALSE);


    GLuint program = glCreateProgram();
    glAttachShader(program, shader);
    glLinkProgram(program);


    GLint link_status = GL_FALSE;
    glGetProgramiv(program, GL_LINK_STATUS, &link_status);
    assert(link_status != GL_FALSE);


    {
        GLenum error = GL_NO_ERROR;
        while ((error = glGetError()) != GL_NO_ERROR) { // <-- this doesn't have an error
            printf("OpenGL ERROR: %s\n", gluErrorString(error));
            assert(false);
        }
    }


    glValidateProgram(program);


    {
        GLenum error = GL_NO_ERROR;
        while ((error = glGetError()) != GL_NO_ERROR) { // <-- this is giving error 1285
            printf("OpenGL ERROR: %s\n", gluErrorString(error));
            assert(false);
        }
    }

Am I missing something obvious?

d0nuts
d0nuts

I was able to re-run this on a different computer which gave me an error during linking:

error: Total number of invocations specified by GROUP_SIZE exceeds implementation limit
So the problem was that my work group size of 64x64x1 was larger than the value of GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS which was 1536.
Still strange that it links successfully on the first computer with a GL_OUT_OF_MEMORY error during validation...
21st Century Moose
21st Century Moose

Still strange that it links successfully on the first computer with a GL_OUT_OF_MEMORY error during validation...


Welcome to the world of bad GL drivers and inconsistent behaviour across different hardware, I'm afraid.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.