[Mesa-dev] [PATCH 01/19] gallium/radeon: inline r600_context_add_resource_size

Marek Olšák maraeo at gmail.com
Sun Oct 2 21:09:16 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeon/r600_pipe_common.c | 20 --------------------
 src/gallium/drivers/radeon/r600_pipe_common.h | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 95950c3..0f156df 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -594,40 +594,20 @@ void r600_common_context_cleanup(struct r600_common_context *rctx)
 
 	slab_destroy(&rctx->pool_transfers);
 
 	if (rctx->allocator_zeroed_memory) {
 		u_suballocator_destroy(rctx->allocator_zeroed_memory);
 	}
 	rctx->ws->fence_reference(&rctx->last_gfx_fence, NULL);
 	rctx->ws->fence_reference(&rctx->last_sdma_fence, NULL);
 }
 
-void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r)
-{
-	struct r600_common_context *rctx = (struct r600_common_context *)ctx;
-	struct r600_resource *rr = (struct r600_resource *)r;
-
-	if (!r) {
-		return;
-	}
-
-	/*
-	 * The idea is to compute a gross estimate of memory requirement of
-	 * each draw call. After each draw call, memory will be precisely
-	 * accounted. So the uncertainty is only on the current draw call.
-	 * In practice this gave very good estimate (+/- 10% of the target
-	 * memory limit).
-	 */
-	rctx->vram += rr->vram_usage;
-	rctx->gtt += rr->gart_usage;
-}
-
 /*
  * pipe_screen
  */
 
 static const struct debug_named_value common_debug_options[] = {
 	/* logging */
 	{ "tex", DBG_TEX, "Print texture info" },
 	{ "compute", DBG_COMPUTE, "Print compute info" },
 	{ "vm", DBG_VM, "Print virtual addresses when creating resources" },
 	{ "info", DBG_INFO, "Print driver information" },
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index c6669cc..038c7c7 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -711,21 +711,20 @@ void r600_draw_rectangle(struct blitter_context *blitter,
 			 const union pipe_color_union *attrib);
 bool r600_common_screen_init(struct r600_common_screen *rscreen,
 			     struct radeon_winsys *ws);
 void r600_destroy_common_screen(struct r600_common_screen *rscreen);
 void r600_preflush_suspend_features(struct r600_common_context *ctx);
 void r600_postflush_resume_features(struct r600_common_context *ctx);
 bool r600_common_context_init(struct r600_common_context *rctx,
 			      struct r600_common_screen *rscreen,
 			      unsigned context_flags);
 void r600_common_context_cleanup(struct r600_common_context *rctx);
-void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r);
 bool r600_can_dump_shader(struct r600_common_screen *rscreen,
 			  unsigned processor);
 void r600_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_resource *dst,
 			      uint64_t offset, uint64_t size, unsigned value,
 			      enum r600_coherency coher);
 struct pipe_resource *r600_resource_create_common(struct pipe_screen *screen,
 						  const struct pipe_resource *templ);
 const char *r600_get_llvm_processor_name(enum radeon_family family);
 void r600_need_dma_space(struct r600_common_context *ctx, unsigned num_dw,
 			 struct r600_resource *dst, struct r600_resource *src);
@@ -850,20 +849,33 @@ r600_resource_reference(struct r600_resource **ptr, struct r600_resource *res)
 	pipe_resource_reference((struct pipe_resource **)ptr,
 				(struct pipe_resource *)res);
 }
 
 static inline void
 r600_texture_reference(struct r600_texture **ptr, struct r600_texture *res)
 {
 	pipe_resource_reference((struct pipe_resource **)ptr, &res->resource.b.b);
 }
 
+static inline void
+r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r)
+{
+	struct r600_common_context *rctx = (struct r600_common_context *)ctx;
+	struct r600_resource *res = (struct r600_resource *)r;
+
+	if (res) {
+		/* Add memory usage for need_gfx_cs_space */
+		rctx->vram += res->vram_usage;
+		rctx->gtt += res->gart_usage;
+	}
+}
+
 static inline bool r600_get_strmout_en(struct r600_common_context *rctx)
 {
 	return rctx->streamout.streamout_enabled ||
 	       rctx->streamout.prims_gen_query_enabled;
 }
 
 #define     SQ_TEX_XY_FILTER_POINT                         0x00
 #define     SQ_TEX_XY_FILTER_BILINEAR                      0x01
 #define     SQ_TEX_XY_FILTER_ANISO_POINT                   0x02
 #define     SQ_TEX_XY_FILTER_ANISO_BILINEAR                0x03
-- 
2.7.4



More information about the mesa-dev mailing list