On Wed, Jun 29, 2016 at 2:16 PM, Ian Romanick <i...@freedesktop.org> wrote: > On 06/29/2016 02:04 AM, Colin McDonald wrote: >> I'm not familiar with the code, other than diving in to fix these >> indirect multi-texture problems, so you will know much more about it >> than me. >> >> But, my understanding is that __glXInitVertexArrayState needs info >> from the server, obtained by calls to _indirect_glGetString & >> __indirect_glGetIntegerv. Those routines need the current context >> from __glXGetCurrentContext, so __glXSetCurrentContext(gc) must have >> been called first. >> >> I see your point about a "layering violation". I think that to avoid >> that would require a more substantial restructuring, so that the >> indirect layer can run some initialisation code (ie >> __glXInitVertexArrayState or similar) separate from the bind >> callback, once a usable context has been setup. > > Maybe... *If* __glXGetCurrentContext is the only problem, then I think > a small refactor of __indirect_glGetString could also solve the problem. > Just make a new function > > const GLubyte *do_GetString(Display *dpy, struct glx_context *gc, > GLenum name); > > that both __indirect_glGetString and indirect_bind_context call. It > might even be worth folding the contents of __glXGetString into the new > function... though that's probably a follow-up patch.
I tried that (see attached p.patch)... and I get another segfault. (gdb) bt #0 0x00007ffff4a97700 in XGetXCBConnection () from /usr/lib64/libX11-xcb.so.1 #1 0x00007ffff7664a3d in __glXFlushRenderBuffer (ctx=0x662080, pc=0x7ffff7f76010 "") at ../../../mesa/src/glx/glxext.c:987 #2 0x00007ffff769b429 in do_GetString (dpy=0x64fc60, gc=0x662080, name=7939) at ../../../mesa/src/glx/single2.c:678 #3 0x00007ffff7688d55 in indirect_bind_context (gc=0x662080, old=0x7ffff78cf6c0 <dummyContext>, draw=27262978, read=27262978) at ../../../mesa/src/glx/indirect_glx.c:158 #4 0x00007ffff766278a in MakeContextCurrent (dpy=0x64fc60, draw=27262978, read=27262978, gc_user=0x662080) at ../../../mesa/src/glx/glxcurrent.c:228 #5 0x00007ffff70c1af0 in fgPlatformOpenWindow () from /usr/lib64/libglut.so.3 #6 0x00007ffff70bbb06 in fgOpenWindow () from /usr/lib64/libglut.so.3 #7 0x00007ffff70ba42b in fgCreateWindow () from /usr/lib64/libglut.so.3 #8 0x00007ffff70bbc00 in glutCreateWindow () from /usr/lib64/libglut.so.3 #9 0x00000000004022c8 in main (argc=1, argv=0x7fffffffe0f8) at arbvparray.c:294 gc->currentDpy is NULL. Sigh. I don't know what any of this code is doing.
diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index bb121f8..7df8d8e 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -126,6 +126,9 @@ SendMakeCurrentRequest(Display * dpy, CARD8 opcode, return ret; } +const GLubyte * +do_GetString(Display *dpy, struct glx_context *gc, GLenum name); + static int indirect_bind_context(struct glx_context *gc, struct glx_context *old, GLXDrawable draw, GLXDrawable read) @@ -152,8 +155,8 @@ indirect_bind_context(struct glx_context *gc, struct glx_context *old, state = gc->client_state_private; if (state->array_state == NULL) { - glGetString(GL_EXTENSIONS); - glGetString(GL_VERSION); + do_GetString(dpy, gc, GL_EXTENSIONS); + do_GetString(dpy, gc, GL_VERSION); __glXInitVertexArrayState(gc); } diff --git a/src/glx/single2.c b/src/glx/single2.c index 2a1bf06..12141e8 100644 --- a/src/glx/single2.c +++ b/src/glx/single2.c @@ -638,17 +638,14 @@ version_from_string(const char *ver, int *major_version, int *minor_version) *minor_version = minor; } +const GLubyte * +do_GetString(Display *dpy, struct glx_context *gc, GLenum name); const GLubyte * -__indirect_glGetString(GLenum name) +do_GetString(Display *dpy, struct glx_context *gc, GLenum name) { - struct glx_context *gc = __glXGetCurrentContext(); - Display *dpy = gc->currentDpy; GLubyte *s = NULL; - if (!dpy) - return 0; - /* ** Return the cached copy if the string has already been fetched */ @@ -789,6 +786,19 @@ __indirect_glGetString(GLenum name) return s; } + +const GLubyte * +__indirect_glGetString(GLenum name) +{ + struct glx_context *gc = __glXGetCurrentContext(); + Display *dpy = gc->currentDpy; + + if (!dpy) + return 0; + + return do_GetString(dpy, gc, name); +} + GLboolean __indirect_glIsEnabled(GLenum cap) {
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev