Portal:OpenGL Objects/Query Objects

From OpenGL Wiki
Jump to navigation Jump to search

A Query Object represents certain kinds of state, where accessing the state directly would cause severe synchronization problems or degraded performance. So a query object thus represents a result that is not necessarily available yet. Most of these queries are based on rendering operations that happen within a specific, defined boundary.

There are a number of types of queries. There are queries for how many samples in a particular rendering operation passed all of the various post-fragment processing tests and the Fragment Shader itself. That is, how much of a rendered object is visible (if any). There are queries for how long the GPU took to execute some set of commands. And there are queries for how many primitives were written by a Transform Feedback operation.

Like textures, the type of query object is assigned the first time the query object is used. Unlike textures and other OpenGL objects, query objects are never "bound". Because query operations are scoped, query objects use a special begin/end pair of functions. These functions define the type of the query object. Using an existing query object with the wrong type is an error.