summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2013-02-25 23:17:57 -0800
committerKenneth Graunke <[email protected]>2013-03-01 22:09:04 -0800
commit981a22b62bc7f8e50ba8bcb0a7f329c25bd53c8d (patch)
tree8d1a209ae1ab62ead0720780a517d620b1708a7c /src
parent90feda81de3c608d5a6041246fc010904a3afa81 (diff)
i965: Unify query object BO reallocation code.
If we haven't allocated a BO yet, we need to do that. Or, if there isn't enough room to write another pair of values, we need to gather up the existing results and start a new one. This is simple enough. However, the old code was awkwardly split into two blocks, with a write_depth_count() placed in the middle. The new depth count isn't relevant to gathering the old BO's data, so that can go after the reallocation is done. With the two blocks adjacent, we can merge them. Signed-off-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_queryobj.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
index d218631aaf2..0881ab93893 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -532,10 +532,19 @@ brw_emit_query_begin(struct brw_context *brw)
*/
if (brw->query.bo == NULL ||
query->last_index * 2 + 1 >= 4096 / sizeof(uint64_t)) {
+
+ if (query->bo != NULL) {
+ /* The old query BO did not have enough space, so we allocated a new
+ * one. Gather the results so far (adding up the differences) and
+ * release the old BO.
+ */
+ brw_queryobj_get_results(ctx, query);
+ }
drm_intel_bo_unreference(brw->query.bo);
brw->query.bo = NULL;
brw->query.bo = drm_intel_bo_alloc(intel->bufmgr, "query", 4096, 1);
+ drm_intel_bo_reference(brw->query.bo);
/* Fill the buffer with zeroes. This is probably superfluous. */
drm_intel_bo_map(brw->query.bo, true);
@@ -543,21 +552,11 @@ brw_emit_query_begin(struct brw_context *brw)
drm_intel_bo_unmap(brw->query.bo);
query->last_index = 0;
+ query->bo = brw->query.bo;
}
write_depth_count(intel, brw->query.bo, query->last_index * 2);
- if (query->bo != brw->query.bo) {
- if (query->bo != NULL) {
- /* The old query BO did not have enough space, so we allocated a new
- * one. Gather the results so far (adding up the differences) and
- * release the old BO.
- */
- brw_queryobj_get_results(ctx, query);
- }
- drm_intel_bo_reference(brw->query.bo);
- query->bo = brw->query.bo;
- }
brw->query.begin_emitted = true;
}