PDA

View Full Version : GL_KHR_debug callback in linux mesa but not with windows blob driver (AMD 7870)



Osbios
11-21-2014, 06:33 PM
I use GL_KHR_debug to get callbacks for gl errors. It works fine in linux with the radeon/mesa drivers.
But in windows with the blob driver I don't get any callbacks at all.

I checked and I get a valid 3.3 core debug context. Also tried non core and different GL versions. But no difference there.

I use SDL2. This is basically what I do to enable GL_KHR_debug.

SDL_GLContext glRenderContext;
SDL_Window *mainWindow;

void printOutKhrDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
{
cout << "printOutKhrDebugMessage callback!" << endl;
}

int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
{
cout << "Unable to initialize SDL: " << SDL_GetError() << endl;
return -1;
}
else
cout << "sdl init ok" << endl;

mainWindow = SDL_CreateWindow(
"SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE// flags - see below
);

if (mainWindow == NULL){
cout << "Could not create window: " << SDL_GetError() << endl;
return -1;
}

//asking for OpenGL 3.3 Core Profile with debug context
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
//this sets WGL_CONTEXT_DEBUG_BIT_ARB (WGL_ARB_create_context) on windows
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, GL_CONTEXT_FLAG_DEBUG_BIT);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

glRenderContext = SDL_GL_CreateContext(mainWindow);
if (!glRenderContext)
{
cout << "SDL_GL_CreateContext: " << SDL_GetError() << endl;
return -1;
}

glDebugMessageCallback(&printOutKhrDebugMessage, NULL);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); //supposedly ruins performance, but gives callback in same thread as context after API call. So we are able to get a nice backtrace from where the call came from.
glEnable(GL_DEBUG_OUTPUT);

//the number of the lord should cause a gl error callback
glEnable(666666666);
}

Osbios
11-22-2014, 08:28 AM
Solved:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);