AzP
AzP

Reputation: 1101

OpenGL Debug Context performance warning

I've managed to implement OpenGL Debug Contexts (awesome, finally!) and most things seem all good and well, but I'm seeing a performance warning that I'm unable to find good information on.

[   0.0330 - 388.6340] OpenGL Version: 4.2.0 Quadro 600/PCIe/SSE2 NVIDIA Corporation
[   0.0000 - 549.1920] OpenGL: Program/shader state performance warning: Fragment Shader is going to be recompiled because the shader key based on GL state mismatches. [source=API type=PERFORMANCE severity=MEDIUM id=131218]

I do understand that it has got something to do with the OpenGL state being change since the last time I compiled the shader(s).

What we have is four shaders that are running on a texture that is shared between the contexts, and the error information only shows up after a new context has been created. So perhaps the context creation alters the state of the OpenGL state machine. Is it possible that it's even impossible to work around it, because each context starts with its own "clean" state machine?

It's probably not a big deal since it only occurs at context creation, but we're running many contexts (at least up to 15 of them at the same time) so it would be interesting to see if I'm able to fix the warning and get rid of it once and for all.

Upvotes: 14

Views: 6849

Answers (2)

MyNameIsYourName
MyNameIsYourName

Reputation: 131

I got rid of that message by calling glUseProgram(0) after finishing drawing some geometry, otherwise the next glUseProgram() with a programId would have triggered that message.

Upvotes: 13

user1628856
user1628856

Reputation:

From what little info I've been able to find, NVIDIA wants some piece of your OpenGL state at shader-compilation time to match the state when the shader is bound & used for rendering.

Personally, until we get more information, I just filter this particular message out in my debug callback function:

static void CALLBACK DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam)
{
    // Suppress some useless warnings
    switch(id)
    {
    case 131218: // NVIDIA: "shader will be recompiled due to GL state mismatches"
        return;
    default:
        break;
    }

    // Print/handle message as usual
}

Upvotes: 5

Related Questions