[Mesa-dev] [PATCH 37/55] radeonsi: use si_context instead of pipe_context in parameters pt2

Marek Olšák maraeo at gmail.com
Mon Apr 2 04:08:30 UTC 2018


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

---
 src/gallium/drivers/radeon/r600_pipe_common.h |  6 +++---
 src/gallium/drivers/radeon/r600_texture.c     | 24 +++++++++++-------------
 src/gallium/drivers/radeon/radeon_video.c     |  4 ++--
 src/gallium/drivers/radeonsi/cik_sdma.c       |  5 ++---
 src/gallium/drivers/radeonsi/si_clear.c       |  6 +++---
 src/gallium/drivers/radeonsi/si_cp_dma.c      |  9 ++++-----
 src/gallium/drivers/radeonsi/si_dma.c         |  5 ++---
 src/gallium/drivers/radeonsi/si_dma_cs.c      |  2 +-
 src/gallium/drivers/radeonsi/si_pipe.c        |  4 ++--
 src/gallium/drivers/radeonsi/si_pipe.h        |  2 +-
 src/gallium/drivers/radeonsi/si_state.c       |  4 ++--
 src/gallium/drivers/radeonsi/si_test_dma.c    |  2 +-
 12 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 6196102..55560d0 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -476,7 +476,7 @@ struct r600_common_context {
 			 unsigned src_level,
 			 const struct pipe_box *src_box);
 
-	void (*dma_clear_buffer)(struct pipe_context *ctx, struct pipe_resource *dst,
+	void (*dma_clear_buffer)(struct si_context *sctx, struct pipe_resource *dst,
 				 uint64_t offset, uint64_t size, unsigned value);
 };
 
@@ -568,9 +568,9 @@ struct pipe_surface *si_create_surface_custom(struct pipe_context *pipe,
 unsigned si_translate_colorswap(enum pipe_format format, bool do_endian_swap);
 void vi_separate_dcc_try_enable(struct si_context *sctx,
 				struct r600_texture *tex);
-void vi_separate_dcc_start_query(struct pipe_context *ctx,
+void vi_separate_dcc_start_query(struct si_context *sctx,
 				 struct r600_texture *tex);
-void vi_separate_dcc_stop_query(struct pipe_context *ctx,
+void vi_separate_dcc_stop_query(struct si_context *sctx,
 				struct r600_texture *tex);
 void vi_separate_dcc_process_and_reset_stats(struct pipe_context *ctx,
 					     struct r600_texture *tex);
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 4b76ebd..9ec8ba4 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -2123,7 +2123,7 @@ static void vi_dcc_clean_up_context_slot(struct si_context *sctx,
 	int i;
 
 	if (sctx->b.dcc_stats[slot].query_active)
-		vi_separate_dcc_stop_query(&sctx->b.b,
+		vi_separate_dcc_stop_query(sctx,
 					   sctx->b.dcc_stats[slot].tex);
 
 	for (i = 0; i < ARRAY_SIZE(sctx->b.dcc_stats[slot].ps_stats); i++)
@@ -2185,10 +2185,10 @@ static unsigned vi_get_context_dcc_stats_index(struct si_context *sctx,
 }
 
 static struct pipe_query *
-vi_create_resuming_pipestats_query(struct pipe_context *ctx)
+vi_create_resuming_pipestats_query(struct si_context *sctx)
 {
 	struct r600_query_hw *query = (struct r600_query_hw*)
-		ctx->create_query(ctx, PIPE_QUERY_PIPELINE_STATISTICS, 0);
+		sctx->b.b.create_query(&sctx->b.b, PIPE_QUERY_PIPELINE_STATISTICS, 0);
 
 	query->flags |= R600_QUERY_HW_FLAG_BEGIN_RESUMES;
 	return (struct pipe_query*)query;
@@ -2197,36 +2197,34 @@ vi_create_resuming_pipestats_query(struct pipe_context *ctx)
 /**
  * Called when binding a color buffer.
  */
-void vi_separate_dcc_start_query(struct pipe_context *ctx,
+void vi_separate_dcc_start_query(struct si_context *sctx,
 				 struct r600_texture *tex)
 {
-	struct si_context *sctx = (struct si_context*)ctx;
 	unsigned i = vi_get_context_dcc_stats_index(sctx, tex);
 
 	assert(!sctx->b.dcc_stats[i].query_active);
 
 	if (!sctx->b.dcc_stats[i].ps_stats[0])
-		sctx->b.dcc_stats[i].ps_stats[0] = vi_create_resuming_pipestats_query(ctx);
+		sctx->b.dcc_stats[i].ps_stats[0] = vi_create_resuming_pipestats_query(sctx);
 
 	/* begin or resume the query */
-	ctx->begin_query(ctx, sctx->b.dcc_stats[i].ps_stats[0]);
+	sctx->b.b.begin_query(&sctx->b.b, sctx->b.dcc_stats[i].ps_stats[0]);
 	sctx->b.dcc_stats[i].query_active = true;
 }
 
 /**
  * Called when unbinding a color buffer.
  */
-void vi_separate_dcc_stop_query(struct pipe_context *ctx,
+void vi_separate_dcc_stop_query(struct si_context *sctx,
 				struct r600_texture *tex)
 {
-	struct si_context *sctx = (struct si_context*)ctx;
 	unsigned i = vi_get_context_dcc_stats_index(sctx, tex);
 
 	assert(sctx->b.dcc_stats[i].query_active);
 	assert(sctx->b.dcc_stats[i].ps_stats[0]);
 
 	/* pause or end the query */
-	ctx->end_query(ctx, sctx->b.dcc_stats[i].ps_stats[0]);
+	sctx->b.b.end_query(&sctx->b.b, sctx->b.dcc_stats[i].ps_stats[0]);
 	sctx->b.dcc_stats[i].query_active = false;
 }
 
@@ -2257,7 +2255,7 @@ void vi_separate_dcc_try_enable(struct si_context *sctx,
 	/* Enable the DCC stat gathering. */
 	if (!tex->dcc_gather_statistics) {
 		tex->dcc_gather_statistics = true;
-		vi_separate_dcc_start_query(&sctx->b.b, tex);
+		vi_separate_dcc_start_query(sctx, tex);
 	}
 
 	if (!vi_should_enable_separate_dcc(tex))
@@ -2330,7 +2328,7 @@ void vi_separate_dcc_process_and_reset_stats(struct pipe_context *ctx,
 
 	/* stop the statistics query for ps_stats[0] */
 	if (query_active)
-		vi_separate_dcc_stop_query(ctx, tex);
+		vi_separate_dcc_stop_query(sctx, tex);
 
 	/* Move the queries in the queue by one. */
 	tmp = sctx->b.dcc_stats[i].ps_stats[2];
@@ -2340,7 +2338,7 @@ void vi_separate_dcc_process_and_reset_stats(struct pipe_context *ctx,
 
 	/* create and start a new query as ps_stats[0] */
 	if (query_active)
-		vi_separate_dcc_start_query(ctx, tex);
+		vi_separate_dcc_start_query(sctx, tex);
 
 	if (disable) {
 		assert(!tex->last_dcc_separate_buffer);
diff --git a/src/gallium/drivers/radeon/radeon_video.c b/src/gallium/drivers/radeon/radeon_video.c
index 3ae1d21..b2238fb 100644
--- a/src/gallium/drivers/radeon/radeon_video.c
+++ b/src/gallium/drivers/radeon/radeon_video.c
@@ -121,8 +121,8 @@ void si_vid_clear_buffer(struct pipe_context *context, struct rvid_buffer* buffe
 {
 	struct si_context *sctx = (struct si_context*)context;
 
-	sctx->b.dma_clear_buffer(context, &buffer->res->b.b, 0,
-			       buffer->res->buf->size, 0);
+	sctx->b.dma_clear_buffer(sctx, &buffer->res->b.b, 0,
+				 buffer->res->buf->size, 0);
 	context->flush(context, NULL, 0);
 }
 
diff --git a/src/gallium/drivers/radeonsi/cik_sdma.c b/src/gallium/drivers/radeonsi/cik_sdma.c
index 05a5ce3..8aaf489 100644
--- a/src/gallium/drivers/radeonsi/cik_sdma.c
+++ b/src/gallium/drivers/radeonsi/cik_sdma.c
@@ -67,20 +67,19 @@ static void cik_sdma_copy_buffer(struct si_context *ctx,
 	}
 }
 
-static void cik_sdma_clear_buffer(struct pipe_context *ctx,
+static void cik_sdma_clear_buffer(struct si_context *sctx,
 				  struct pipe_resource *dst,
 				  uint64_t offset,
 				  uint64_t size,
 				  unsigned clear_value)
 {
-	struct si_context *sctx = (struct si_context *)ctx;
 	struct radeon_winsys_cs *cs = sctx->b.dma_cs;
 	unsigned i, ncopy, csize;
 	struct r600_resource *rdst = r600_resource(dst);
 
 	if (!cs || offset % 4 != 0 || size % 4 != 0 ||
 	    dst->flags & PIPE_RESOURCE_FLAG_SPARSE) {
-		ctx->clear_buffer(ctx, dst, offset, size, &clear_value, 4);
+		sctx->b.b.clear_buffer(&sctx->b.b, dst, offset, size, &clear_value, 4);
 		return;
 	}
 
diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c
index c13e98b..8198ffb 100644
--- a/src/gallium/drivers/radeonsi/si_clear.c
+++ b/src/gallium/drivers/radeonsi/si_clear.c
@@ -230,7 +230,7 @@ void vi_dcc_clear_level(struct si_context *sctx,
 			     num_layers;
 	}
 
-	si_clear_buffer(&sctx->b.b, dcc_buffer, dcc_offset, clear_size,
+	si_clear_buffer(sctx, dcc_buffer, dcc_offset, clear_size,
 			clear_value, R600_COHERENCY_CB_META);
 }
 
@@ -459,7 +459,7 @@ static void si_do_fast_color_clear(struct si_context *sctx,
 				if (clear_words_needed)
 					continue;
 
-				si_clear_buffer(&sctx->b.b, &tex->cmask_buffer->b.b,
+				si_clear_buffer(sctx, &tex->cmask_buffer->b.b,
 						tex->cmask.offset, tex->cmask.size,
 						0xCCCCCCCC, R600_COHERENCY_CB_META);
 				need_decompress_pass = true;
@@ -491,7 +491,7 @@ static void si_do_fast_color_clear(struct si_context *sctx,
 			}
 
 			/* Do the fast clear. */
-			si_clear_buffer(&sctx->b.b, &tex->cmask_buffer->b.b,
+			si_clear_buffer(sctx, &tex->cmask_buffer->b.b,
 					tex->cmask.offset, tex->cmask.size, 0,
 					R600_COHERENCY_CB_META);
 			need_decompress_pass = true;
diff --git a/src/gallium/drivers/radeonsi/si_cp_dma.c b/src/gallium/drivers/radeonsi/si_cp_dma.c
index 7e3d825..17e15d1 100644
--- a/src/gallium/drivers/radeonsi/si_cp_dma.c
+++ b/src/gallium/drivers/radeonsi/si_cp_dma.c
@@ -204,11 +204,10 @@ static void si_cp_dma_prepare(struct si_context *sctx, struct pipe_resource *dst
 		*packet_flags |= CP_DMA_SYNC;
 }
 
-void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
+void si_clear_buffer(struct si_context *sctx, struct pipe_resource *dst,
 		     uint64_t offset, uint64_t size, unsigned value,
 		     enum r600_coherency coher)
 {
-	struct si_context *sctx = (struct si_context*)ctx;
 	struct radeon_winsys *ws = sctx->b.ws;
 	struct r600_resource *rdst = r600_resource(dst);
 	unsigned tc_l2_flag = get_tc_l2_flag(sctx, coher);
@@ -243,7 +242,7 @@ void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
 	      * of them are moved to SDMA thanks to this. */
 	     !ws->cs_is_buffer_referenced(sctx->b.gfx_cs, rdst->buf,
 				          RADEON_USAGE_READWRITE))) {
-		sctx->b.dma_clear_buffer(ctx, dst, offset, dma_clear_size, value);
+		sctx->b.dma_clear_buffer(sctx, dst, offset, dma_clear_size, value);
 
 		offset += dma_clear_size;
 		size -= dma_clear_size;
@@ -287,7 +286,7 @@ void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
 		assert(dst->target == PIPE_BUFFER);
 		assert(size < 4);
 
-		pipe_buffer_write(ctx, dst, offset, size, &value);
+		pipe_buffer_write(&sctx->b.b, dst, offset, size, &value);
 	}
 }
 
@@ -347,7 +346,7 @@ static void si_pipe_clear_buffer(struct pipe_context *ctx,
 		dword_value = *(uint32_t*)clear_value_ptr;
 	}
 
-	si_clear_buffer(ctx, dst, offset, size, dword_value,
+	si_clear_buffer(sctx, dst, offset, size, dword_value,
 			R600_COHERENCY_SHADER);
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_dma.c b/src/gallium/drivers/radeonsi/si_dma.c
index 12c8459..106fbd5 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -77,20 +77,19 @@ static void si_dma_copy_buffer(struct si_context *ctx,
 	}
 }
 
-static void si_dma_clear_buffer(struct pipe_context *ctx,
+static void si_dma_clear_buffer(struct si_context *sctx,
 				struct pipe_resource *dst,
 				uint64_t offset,
 				uint64_t size,
 				unsigned clear_value)
 {
-	struct si_context *sctx = (struct si_context *)ctx;
 	struct radeon_winsys_cs *cs = sctx->b.dma_cs;
 	unsigned i, ncopy, csize;
 	struct r600_resource *rdst = r600_resource(dst);
 
 	if (!cs || offset % 4 != 0 || size % 4 != 0 ||
 	    dst->flags & PIPE_RESOURCE_FLAG_SPARSE) {
-		ctx->clear_buffer(ctx, dst, offset, size, &clear_value, 4);
+		sctx->b.b.clear_buffer(&sctx->b.b, dst, offset, size, &clear_value, 4);
 		return;
 	}
 
diff --git a/src/gallium/drivers/radeonsi/si_dma_cs.c b/src/gallium/drivers/radeonsi/si_dma_cs.c
index 3fe8ddf..fbe88ac 100644
--- a/src/gallium/drivers/radeonsi/si_dma_cs.c
+++ b/src/gallium/drivers/radeonsi/si_dma_cs.c
@@ -144,7 +144,7 @@ void si_screen_clear_buffer(struct si_screen *sscreen, struct pipe_resource *dst
 	struct si_context *ctx = (struct si_context*)sscreen->aux_context;
 
 	mtx_lock(&sscreen->aux_context_lock);
-	ctx->b.dma_clear_buffer(&ctx->b.b, dst, offset, size, value);
+	ctx->b.dma_clear_buffer(ctx, dst, offset, size, value);
 	sscreen->aux_context->flush(sscreen->aux_context, NULL, 0);
 	mtx_unlock(&sscreen->aux_context_lock);
 }
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 73460f7..52dbd11 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -382,7 +382,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
 				 &sctx->null_const_buf);
 
 		/* Clear the NULL constant buffer, because loads should return zeros. */
-		si_clear_buffer(&sctx->b.b, sctx->null_const_buf.buffer, 0,
+		si_clear_buffer(sctx, sctx->null_const_buf.buffer, 0,
 				sctx->null_const_buf.buffer->width0, 0,
 				R600_COHERENCY_SHADER);
 	}
@@ -601,7 +601,7 @@ static void si_test_vmfault(struct si_screen *sscreen)
 		puts("VM fault test: CP - done.");
 	}
 	if (sscreen->debug_flags & DBG(TEST_VMFAULT_SDMA)) {
-		sctx->b.dma_clear_buffer(ctx, buf, 0, 4, 0);
+		sctx->b.dma_clear_buffer(sctx, buf, 0, 4, 0);
 		ctx->flush(ctx, NULL, 0);
 		puts("VM fault test: SDMA - done.");
 	}
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 79c3396..d100b8d 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -692,7 +692,7 @@ enum r600_coherency {
 	R600_COHERENCY_CB_META,
 };
 
-void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
+void si_clear_buffer(struct si_context *sctx, struct pipe_resource *dst,
 		     uint64_t offset, uint64_t size, unsigned value,
 		     enum r600_coherency coher);
 void si_copy_buffer(struct si_context *sctx,
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 6d79d0d..f0a3c12 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2732,7 +2732,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
 
 		rtex = (struct r600_texture*)sctx->framebuffer.state.cbufs[i]->texture;
 		if (rtex->dcc_gather_statistics)
-			vi_separate_dcc_stop_query(ctx, rtex);
+			vi_separate_dcc_stop_query(sctx, rtex);
 	}
 
 	/* Disable DCC if the formats are incompatible. */
@@ -2874,7 +2874,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
 		if (rtex->dcc_gather_statistics) {
 			/* Dirty tracking must be enabled for DCC usage analysis. */
 			sctx->framebuffer.compressed_cb_mask |= 1 << i;
-			vi_separate_dcc_start_query(ctx, rtex);
+			vi_separate_dcc_start_query(sctx, rtex);
 		}
 	}
 
diff --git a/src/gallium/drivers/radeonsi/si_test_dma.c b/src/gallium/drivers/radeonsi/si_test_dma.c
index bb04d0b..6cf3d3b 100644
--- a/src/gallium/drivers/radeonsi/si_test_dma.c
+++ b/src/gallium/drivers/radeonsi/si_test_dma.c
@@ -307,7 +307,7 @@ void si_test_dma(struct si_screen *sscreen)
 		set_random_pixels(ctx, src, &src_cpu);
 
 		/* clear dst pixels */
-		si_clear_buffer(ctx, dst, 0, rdst->surface.surf_size, 0, true);
+		si_clear_buffer(sctx, dst, 0, rdst->surface.surf_size, 0, true);
 		memset(dst_cpu.ptr, 0, dst_cpu.layer_stride * tdst.array_size);
 
 		/* preparation */
-- 
2.7.4



More information about the mesa-dev mailing list