i965: Add a pile of comments to brw_queryobj.c.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 25 Feb 2013 23:22:02 +0000 (15:22 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 2 Mar 2013 06:09:04 +0000 (22:09 -0800)
commitd92c7d8eed4eb0a1c1291a93d84439ba9a9983a2
tree50c8089c2ca9d554d42ca5dd4abeafeb2d421c1f
parentd1b34baf9b9c977d2bcd612aa8ea7256f2143ad8
i965: Add a pile of comments to brw_queryobj.c.

This code was really difficult to follow, for a number of reasons:

- Queries were handled in four different ways (TIMESTAMP writes a single
  value, TIME_ELAPSED writes a single pair of values, occlusion queries
  write pairs of values for the start and end of each batch, and other
  queries are done entirely in software.  It turns out that there are
  very good reasons each query is handled the way it is, but
  insufficient comments explaining the rationale.

- It wasn't immediately obvious which functions were driver hooks
  and which were helper functions.  For example, brw_query_begin() is
  a driver hook that implements glBeginQuery() for all query types, but
  the similarly named brw_emit_query_begin() is a helper function that's
  only relevant for occlusion queries.

Extra explanatory comments should save me and others from constantly
having to ask how this code works and why various query types are
handled differently.

v2: Incorporate Eric's feedback: change "as soon as possible" to "the
    results will be present when mapped."

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_queryobj.c