Mesa (master): r600g: only call bo loop if nbos is positive.

Dave Airlie airlied at kemper.freedesktop.org
Mon Jun 6 23:44:43 UTC 2011


Module: Mesa
Branch: master
Commit: eb4bb48ef41483750fa678ab21ef52accbf4e628
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb4bb48ef41483750fa678ab21ef52accbf4e628

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Jun  6 11:15:10 2011 +1000

r600g: only call bo loop if nbos is positive.

we don't need to loop over all the registers unless we have
some bos in the block, also avoid setting the ctx flags,
and move the optional stuff down below this chunk.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/winsys/r600/drm/r600_hw_context.c |   36 +++++++++++++-----------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c
index 4c21d60..1be4854 100644
--- a/src/gallium/winsys/r600/drm/r600_hw_context.c
+++ b/src/gallium/winsys/r600/drm/r600_hw_context.c
@@ -1183,31 +1183,33 @@ void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *
 {
 	int id;
 	int optional = block->nbo == 0 && !(block->flags & REG_FLAG_DIRTY_ALWAYS);
-	int cp_dwords = block->pm4_ndwords, start_dword;
-	int new_dwords;
+	int cp_dwords = block->pm4_ndwords, start_dword = 0;
+	int new_dwords = 0;
 
 	if (block->nreg_dirty == 0 && optional) {
 		goto out;
 	}
 
-	optional &= (block->nreg_dirty != block->nreg);
-
-	ctx->flags |= R600_CONTEXT_CHECK_EVENT_FLUSH;
-	for (int j = 0; j < block->nreg; j++) {
-		if (block->pm4_bo_index[j]) {
-			/* find relocation */
-			id = block->pm4_bo_index[j];
-			r600_context_bo_reloc(ctx,
-					&block->pm4[block->reloc[id].bo_pm4_index],
-					block->reloc[id].bo);
-			r600_context_bo_flush(ctx,
-					block->reloc[id].flush_flags,
-					block->reloc[id].flush_mask,
-					block->reloc[id].bo);
+	if (block->nbo) {
+		ctx->flags |= R600_CONTEXT_CHECK_EVENT_FLUSH;
+
+		for (int j = 0; j < block->nreg; j++) {
+			if (block->pm4_bo_index[j]) {
+				/* find relocation */
+				id = block->pm4_bo_index[j];
+				r600_context_bo_reloc(ctx,
+						      &block->pm4[block->reloc[id].bo_pm4_index],
+						      block->reloc[id].bo);
+				r600_context_bo_flush(ctx,
+						      block->reloc[id].flush_flags,
+						      block->reloc[id].flush_mask,
+						      block->reloc[id].bo);
+			}
 		}
+		ctx->flags &= ~R600_CONTEXT_CHECK_EVENT_FLUSH;
 	}
-	ctx->flags &= ~R600_CONTEXT_CHECK_EVENT_FLUSH;
 
+	optional &= (block->nreg_dirty != block->nreg);
 	if (optional) {
 		new_dwords = block->nreg_dirty;
 		start_dword = ctx->pm4_cdwords;




More information about the mesa-commit mailing list