This looks reasonable to me. Acked-by: Sinclair Yeh <s...@vmware.com>
On Thu, Oct 02, 2014 at 09:49:04AM -0600, Brian Paul wrote: > On Windows, the Piglit primitive-restart test was failing a > glGetError()==0 assertion when it was run w/out any command line > arguments. Piglit's all.py script only runs primitive-restart > with arguments so this case isn't normally hit during a full > piglit run. > > The basic problem is Microsoft's opengl32.dll calls glFlush > from wglGetProcAddress() and Piglit uses wglGetProcAddress() to > resolve glPrimitiveRestartNV() which is called inside glBegin/End. > See comments in the code for more info. > > Plus, improve the comments for _mesa_alloc_dispatch_table(). > > Cc: <mesa-sta...@lists.freedesktop.org> > --- > src/mesa/main/context.c | 36 +++++++++++++++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c > index afe43a6..5a8f718 100644 > --- a/src/mesa/main/context.c > +++ b/src/mesa/main/context.c > @@ -891,7 +891,21 @@ _mesa_generic_nop(void) > > > /** > - * Allocate and initialize a new dispatch table. > + * Special no-op glFlush, see below. > + */ > +#if defined(_WIN32) > +static void GLAPIENTRY > +nop_glFlush(void) > +{ > + /* don't record an error like we do in _mesa_generic_nop() */ > +} > +#endif > + > + > +/** > + * Allocate and initialize a new dispatch table. All the dispatch > + * function pointers will point at the _mesa_generic_nop() function > + * which raises GL_INVALID_OPERATION. > */ > struct _glapi_table * > _mesa_alloc_dispatch_table(void) > @@ -911,6 +925,26 @@ _mesa_alloc_dispatch_table(void) > for (i = 0; i < numEntries; i++) { > entry[i] = (_glapi_proc) _mesa_generic_nop; > } > + > +#if defined(_WIN32) > + /* This is a special case for Windows in the event that > + * wglGetProcAddress is called between glBegin/End(). > + * > + * The MS opengl32.dll library apparently calls glFlush from > + * wglGetProcAddress(). If we're inside glBegin/End(), glFlush > + * will dispatch to _mesa_generic_nop() and we'll generate a > + * GL_INVALID_OPERATION error. > + * > + * The specific case which hits this is piglit's primitive-restart > + * test which calls glPrimitiveRestartNV() inside glBegin/End. The > + * first time we call glPrimitiveRestartNV() Piglit's API dispatch > + * code will try to resolve the function by calling wglGetProcAddress. > + * This raises GL_INVALID_OPERATION and an assert(glGetError()==0) > + * will fail causing the test to fail. By suppressing the error, the > + * assertion passes and the test continues. > + */ > + SET_Flush(table, nop_glFlush); > +#endif > } > return table; > } > -- > 1.7.10.4 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=0z9ea8IzZ%2F3am%2F968VnzsA%3D%3D%0A&m=uR%2BbgxEgKLtR41FFJnfOhIvQxuyZU7uaD5Fwrr7QHRI%3D%0A&s=1a422441a95eef77350f89c98b2e593f7aa29a93e9e5fe473ba769f814e12255 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev