summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2013-02-27 13:35:05 -0800
committerKenneth Graunke <[email protected]>2013-03-01 22:09:04 -0800
commitcf0c0a778273d6ada00e9bb8ee15938f3595bd7b (patch)
tree27ef962140b364f72517f6ad04358e782003c091 /src
parent961c9b8cac6c438b74d8328a5e8c61215a16ea40 (diff)
i965: Pull query BO reallocation out into a helper function.
We'll want to reuse this for non-occlusion queries in the future. Plus, it's a single logical task, so having it as a helper function clarifies the code somewhat. Signed-off-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_queryobj.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
index ccc504f5241..00655137048 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -489,6 +489,38 @@ static void brw_check_query(struct gl_context *ctx, struct gl_query_object *q)
}
/**
+ * Ensure there query's BO has enough space to store a new pair of values.
+ *
+ * If not, gather the existing BO's results and create a new buffer of the
+ * same size.
+ */
+static void
+ensure_bo_has_space(struct gl_context *ctx, struct brw_query_object *query)
+{
+ struct intel_context *intel = intel_context(ctx);
+
+ if (!query->bo || 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);
+ }
+
+ query->bo = drm_intel_bo_alloc(intel->bufmgr, "query", 4096, 1);
+
+ /* Fill the buffer with zeroes. This is probably superfluous. */
+ drm_intel_bo_map(query->bo, true);
+ memset((char *) query->bo->virtual, 0, 4096);
+ drm_intel_bo_unmap(query->bo);
+
+ query->last_index = 0;
+ }
+}
+
+/**
* Record the PS_DEPTH_COUNT value (for occlusion queries) just before
* primitive drawing.
*
@@ -523,29 +555,7 @@ brw_emit_query_begin(struct brw_context *brw)
if (!query || brw->query.begin_emitted)
return;
- /* Ensure the buffer has enough space to store a new pair of values.
- * If not, create a new one of the same size; we'll gather the existing
- * buffer's results momentarily.
- */
- if (!query->bo || 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);
- }
-
- query->bo = drm_intel_bo_alloc(intel->bufmgr, "query", 4096, 1);
-
- /* Fill the buffer with zeroes. This is probably superfluous. */
- drm_intel_bo_map(query->bo, true);
- memset((char *) query->bo->virtual, 0, 4096);
- drm_intel_bo_unmap(query->bo);
-
- query->last_index = 0;
- }
+ ensure_bo_has_space(ctx, query);
write_depth_count(intel, query->bo, query->last_index * 2);