-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 There is nothing in the OpenGL specification which prevents the user from calling glGenQueries to generate a new query object while another object is active. Neither is there anything in the Mesa implementation which prevents this. So remove the INVALID_OPERATION errors in this case.
Similarly, it is explicitly allowed by the OpenGL specification to delete an active query, so remove the assertion for that case and be sure to call the driver's EndQuery hook. CC: <mesa-sta...@lists.freedesktop.org> - --- Brian Paul <bri...@vmware.com> writes: > Valgrind found an invalid pointer (and crashed!) when I modified your > piglit test (see other msg). We also need to make sure that the > ctx->Query.CurrentFoo binding point is cleared. Something like this: > > if (q->Active) { > struct gl_query_object **bindpt = > get_query_binding_point(ctx, q->Target); > assert(bindpt); /* _should_ be non-null if q is active */ > if (bindpt) { > *bindpt = NULL; > } Thanks, Brian! This does indeed fix the problem that valgrind found. Here's an updated patch which passes the updated piglit test (see the other thread). I still haven't tested this on anything but Mesa/i965, but I might be able to chase down some other systems for testing if that's necessary. - -Carl src/mesa/main/queryobj.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index a180133..86e7c3a 100644 - --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -202,13 +202,6 @@ _mesa_GenQueries(GLsizei n, GLuint *ids) return; } - - /* No query objects can be active at this time! */ - - if (ctx->Query.CurrentOcclusionObject || - - ctx->Query.CurrentTimerObject) { - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB"); - - return; - - } - - first = _mesa_HashFindFreeKeyBlock(ctx->Query.QueryObjects, n); if (first) { GLsizei i; @@ -241,18 +234,20 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids) return; } - - /* No query objects can be active at this time! */ - - if (ctx->Query.CurrentOcclusionObject || - - ctx->Query.CurrentTimerObject) { - - _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB"); - - return; - - } - - for (i = 0; i < n; i++) { if (ids[i] > 0) { struct gl_query_object *q = _mesa_lookup_query_object(ctx, ids[i]); if (q) { - - ASSERT(!q->Active); /* should be caught earlier */ + if (q->Active) { + struct gl_query_object **bindpt; + bindpt = get_query_binding_point(ctx, q->Target); + assert(bindpt); /* Should be non-null for active q. */ + if (bindpt) { + *bindpt = NULL; + } + q->Active = GL_FALSE; + ctx->Driver.EndQuery(ctx, q); + } _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]); ctx->Driver.DeleteQuery(ctx, q); } - -- 1.8.4.rc3 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) iQIcBAEBCAAGBQJSbqa/AAoJEGACM7qeVNxhczIQAJJ0MvirvNrDN3d7IfogAL7F x4f/GVbc4vhkI8pkieGYO8R0CwoX48vXTf6goCMZKwPgAff/PNRs17OuaT8eELVI GrjhCfkk3cyxxWwf7PI6LswgHdsVG+wkHvAP2Zr588pNBZWQbPT5MSMekQIYRTmG zAgl+3Aiyzuyw0CeuFkTQnKxski5JMfIpf5Ww4CQm+NOsnP33NILom/jhLplXGeI EBYD/dkFMIDVO5FUGRoKdu21rsN102cK8NdoVA+hUayiA7ZFosBju/4BfWb/+bgC QVZ1Lza6VngXc0VrdtfMYrfHmX3QpY9N6MOUpWyR7N9GvctkvigaZdrGA922Cd5y o9wcWPyutAYl5Fuc8MZY7AQ0+2t54cRsvekptroxbk3el8gWmlOb33vCTGRHiley uUi4/NxEUH3v0VGkRJjSfCaR08a6U9y0BlQYodh3cVapUZSjSgaU+K8/j54kwddJ 5jQhEmO896szngfa+hfvwVJAiOb8Pv0J2hAzmQ8bzxF7p765JbZCBTy4DbOwe89Z Bpgh/f8JwG9ovFACyU4Y9FKGIM92K90b7uQEWewShUIrya/4kGzwKe5hoDb54PiR xfdZRTYKj0s6QRaEi39g+SON1ZlzpCTapcRacDA9zztBY5jSndCZz+KYbrWVruOV fqj1t4InTm5rtrUL5vjb =lNny -----END PGP SIGNATURE----- _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev