Hi, are there are any reasons why the opengl API glQueryCounter might not work? I have checked the queryObject returned by glGenQueries has the same context. Immediately after the glQueryCounter(queryObject, GL_TIMESTAMP) call, if I invoke, glIsQuery(queryObject), it returns GL_FALSE. There is a context change from c1 to c2 before glQueryCounter is invoked but that shouldn’t be causing a difference right as long as the queryObject generated is in the same context as the context invoking glQueryCounter? Anyone faced similar situations? Thanks!
I think it would help clarify what you are doing if you could show high level order of things, e.g.
create context c1 create context c2 (and share objects with c1??) make current c1 q1 = glGenQuery() glQueryCounter(q1, ...) make current c2 // other stuff make current c1 glIsQuery(q1)
Is that the sequence of calls you have or something else? In particular which contexts are active when you make calls related to the query object and are your contexts are configured to share objects? Note that query objects cannot be shared (see this wiki page).
Yes the high level of flow looks like this
make current c1
make current c2
q1 = glGenQuery()
make current c1
// do other stuff
make current c2
glIsQuery(q1) - returns 1282, GL_INVALID_OPERATION
No, my context is not configured to share objects.
Thanks. Technically the reference page for glIsQuery states that the id must have been used used with
A name returned by glGenQueries, but not yet associated with a query object by calling glBeginQuery, is not the name of a query object.
But I’m not sure if that is just an omission on the reference page. In any case it should only return
GL_FALSE not cause an error. Is it possible that the error is generated by a different command? Are you using
glDebugMessageCallback or just occasional glGetError checks? If the latter, do you loop to drain all accumulated errors?
Also, are those contexts using core profile or compatibility profile? In the core profile using an object id that was not returned by a
glGen* function is an error, so if that were the case it would suggest that somehow your object ids are not used with the context that reserved them.
Thanks for the answer! This is the exact error message that I am getting - Error: GL_INVALID_OPERATION error generated. Query object not found.
That means, I think this is a core profile.
I am using glGetError checks all over the program and the error seems to stem from glGetQueryCounter
It is; the 4.6 specification says (§4.2.2):
Not necessarily. But are you not the one who creates the contexts, you would now if you request a core profile context or not, no?
In any case, it still sounds to me like the ids for your queries get somehow mixed up (maybe across context boundaries or between ids used for
glBeginQuery). If the number of queries in your application is fairly low, perhaps you can just log the results from
glGetQueries calls (and on which context they occur) and the ids passed to
glQueryCounter and just compare if you can spot an inconsistency?
Also try printing the GL_VERSION and GL_VENDOR strings to show what context type you are in (The results will vary on the driver, GPU, and OS you are on).
If you can create the two context with different values so their string are different.
Or use one of the platform CurrentContext() functions to return the present pointer and print it just before the code.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.