Add a vendor check to detect if FBOs or VAOs are actually shared

* This lets us detect if the FBO/VAO behaviour is different from the main
  spec, and so we won't miss deletes or other events if the context is
  different since we'll treat them as shared like any other object.
This commit is contained in:
baldurk
2014-12-11 20:30:34 +00:00
parent a777a13021
commit 9be802082f
9 changed files with 153 additions and 37 deletions
+50
View File
@@ -298,6 +298,46 @@ class OpenGLHook : LibraryHook
if(glXMakeCurrent_real)
glXMakeCurrent_real(data.dpy, data.wnd, data.ctx);
}
GLWindowingData MakeContext(GLWindowingData share)
{
GLWindowingData ret = {0};
if(glXCreateContextAttribsARB_real)
{
const int attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB,
3,
GLX_CONTEXT_MINOR_VERSION_ARB,
2,
GLX_CONTEXT_FLAGS_ARB,
0,
0, 0,
};
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfigProc = (PFNGLXCHOOSEFBCONFIGPROC)dlsym(RTLD_NEXT, "glXChooseFBConfig");
if(glXChooseFBConfigProc)
{
// don't need to care about the fb config as we won't be using the default framebuffer (backbuffer)
int visAttribs[] = { 0 };
int numCfgs = 0;
GLXFBConfig *fbcfg = glXChooseFBConfigProc(dpy, DefaultScreen(dpy), visAttribs, &numCfgs);
if(fbcfg)
{
ret.dpy = share.dpy;
ret.ctx = glXCreateContextAttribsARB_real(share.dpy, fbcfg[0], share.ctx, false, attribs);
}
}
}
return ret;
}
void DeleteContext(GLWindowingData context)
{
if(context.ctx && glXDestroyContext_real)
glXDestroyContext_real(context.dpy, context.ctx);
}
WrappedOpenGL *GetDriver()
{
@@ -628,3 +668,13 @@ void MakeContextCurrent(GLWindowingData data)
OpenGLHook::glhooks.MakeContextCurrent(data);
}
GLWindowingData MakeContext(GLWindowingData share)
{
return OpenGLHook::glhooks.MakeContext(share);
}
void DeleteContext(GLWindowingData context)
{
OpenGLHook::glhooks.DeleteContext(context);
}
+36
View File
@@ -258,6 +258,32 @@ class OpenGLHook : LibraryHook
if(wglMakeCurrent_hook())
wglMakeCurrent_hook()(data.DC, data.ctx);
}
GLWindowingData MakeContext(GLWindowingData share)
{
GLWindowingData ret = {0};
if(wglCreateContextAttribsARB_realfunc)
{
const int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB,
3,
WGL_CONTEXT_MINOR_VERSION_ARB,
2,
WGL_CONTEXT_FLAGS_ARB,
0,
0, 0,
};
ret.DC = share.DC;
ret.ctx = wglCreateContextAttribsARB_realfunc(share.DC, share.ctx, attribs);
}
return ret;
}
void DeleteContext(GLWindowingData context)
{
if(context.ctx && wglDeleteContext_hook())
wglDeleteContext_hook()(context.ctx);
}
private:
WrappedOpenGL *GetDriver()
@@ -650,3 +676,13 @@ void MakeContextCurrent(GLWindowingData data)
{
OpenGLHook::glhooks.MakeContextCurrent(data);
}
GLWindowingData MakeContext(GLWindowingData share)
{
return OpenGLHook::glhooks.MakeContext(share);
}
void DeleteContext(GLWindowingData context)
{
OpenGLHook::glhooks.DeleteContext(context);
}