OpenGL Debug Context performance warning
Asked Answered
B

2

14

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.

Baro answered 17/8, 2012 at 10:52 Comment(6)
I always get this warning on NVIDIA cards. I have no idea what it means, nor do I have any idea how to correct it. And thus far, NVIDIA doesn't seem to keen on explaining what the problem is.Legate
I have the same impression from reading about it in forums. People talk about driver bugs, etc.Baro
It's not a bug; it's just a performance warning about shader recompilation.Legate
Well Nicol, that's obvious. But NVidia still doesn't seem to want to give more information on the matter. I saw one thread where they mentioned driver issues, as if they were the actual driver developers. When I said "driver bugs" I meant the fact that the message is popping up, not that the message in itself is a bug.Baro
Do you get the warning for a specific shader? Can you post it? If not, and it is for a context, are your contexts different in any way?Lynx
It seems to be once for each context, and it applies to all our contexts. But your question if it's for a specific shader is very interesting! I have to check it out.Baro
A
5

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
}
Arias answered 2/11, 2012 at 18:27 Comment(1)
Thanks! I hadn't seen the final part of that thread. Will be interesting to see if Nvidia provides some feedback on this as well.Baro
S
13

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.

Shooter answered 26/2, 2013 at 0:51 Comment(1)
This worked for me when I finally tried it! I could trace the source of the warning via the backtrace, add a couple of glUseProgram(0), and all the warnings disappeared.Baro
A
5

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
}
Arias answered 2/11, 2012 at 18:27 Comment(1)
Thanks! I hadn't seen the final part of that thread. Will be interesting to see if Nvidia provides some feedback on this as well.Baro

© 2022 - 2024 — McMap. All rights reserved.