Mesa (master): freedreno/ir3: split out per-stage emit_consts fxns

Rob Clark robclark at kemper.freedesktop.org
Tue Apr 18 20:51:10 UTC 2017


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

Author: Rob Clark <robdclark at gmail.com>
Date:   Sun Apr 16 12:39:59 2017 -0400

freedreno/ir3: split out per-stage emit_consts fxns

This makes it easier to deal with adding additional stages which have
their own driver-params.  The duplicated code this introduces can be
refactored out after a later patch moves to per-shader-stage dirty
flags.

Signed-off-by: Rob Clark <robdclark at gmail.com>

---

 src/gallium/drivers/freedreno/a3xx/fd3_emit.c  |  4 +--
 src/gallium/drivers/freedreno/a4xx/fd4_emit.c  |  4 +--
 src/gallium/drivers/freedreno/a5xx/fd5_emit.c  |  4 +--
 src/gallium/drivers/freedreno/ir3/ir3_shader.c | 44 ++++++++++++++++++--------
 src/gallium/drivers/freedreno/ir3/ir3_shader.h |  6 ++--
 5 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 9e9d2d9bc4..04e3300efd 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -713,9 +713,9 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 	OUT_RING(ring, HLSQ_FLUSH);
 
 	if (emit->prog == &ctx->prog) { /* evil hack to deal sanely with clear path */
-		ir3_emit_consts(vp, ring, ctx, emit->info, dirty);
+		ir3_emit_vs_consts(vp, ring, ctx, emit->info);
 		if (!emit->key.binning_pass)
-			ir3_emit_consts(fp, ring, ctx, emit->info, dirty);
+			ir3_emit_fs_consts(fp, ring, ctx);
 	}
 
 	if (dirty & (FD_DIRTY_BLEND | FD_DIRTY_FRAMEBUFFER)) {
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
index 997d04a83c..4c79a67ba5 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
@@ -677,9 +677,9 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 	}
 
 	if (emit->prog == &ctx->prog) { /* evil hack to deal sanely with clear path */
-		ir3_emit_consts(vp, ring, ctx, emit->info, dirty);
+		ir3_emit_vs_consts(vp, ring, ctx, emit->info);
 		if (!emit->key.binning_pass)
-			ir3_emit_consts(fp, ring, ctx, emit->info, dirty);
+			ir3_emit_fs_consts(fp, ring, ctx);
 	}
 
 	if ((dirty & FD_DIRTY_BLEND)) {
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
index db85573592..1e5b6dbc29 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
@@ -551,9 +551,9 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 	}
 
 	if (emit->prog == &ctx->prog) { /* evil hack to deal sanely with clear path */
-		ir3_emit_consts(vp, ring, ctx, emit->info, dirty);
+		ir3_emit_vs_consts(vp, ring, ctx, emit->info);
 		if (!emit->key.binning_pass)
-			ir3_emit_consts(fp, ring, ctx, emit->info, dirty);
+			ir3_emit_fs_consts(fp, ring, ctx);
 
 		struct pipe_stream_output_info *info = &vp->shader->stream_output;
 		if (info->num_outputs) {
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
index ffe1b046a8..402d12a205 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
@@ -655,23 +655,19 @@ max_tf_vtx(struct fd_context *ctx, const struct ir3_shader_variant *v)
 }
 
 void
-ir3_emit_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
-		struct fd_context *ctx, const struct pipe_draw_info *info, uint32_t dirty)
+ir3_emit_vs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
+		struct fd_context *ctx, const struct pipe_draw_info *info)
 {
+	uint32_t dirty = ctx->dirty;
+
+	debug_assert(v->type == SHADER_VERTEX);
+
 	if (dirty & (FD_DIRTY_PROG | FD_DIRTY_CONSTBUF)) {
 		struct fd_constbuf_stateobj *constbuf;
 		bool shader_dirty;
 
-		if (v->type == SHADER_VERTEX) {
-			constbuf = &ctx->constbuf[PIPE_SHADER_VERTEX];
-			shader_dirty = !!(dirty & FD_SHADER_DIRTY_VP);
-		} else if (v->type == SHADER_FRAGMENT) {
-			constbuf = &ctx->constbuf[PIPE_SHADER_FRAGMENT];
-			shader_dirty = !!(dirty & FD_SHADER_DIRTY_FP);
-		} else {
-			unreachable("bad shader type");
-			return;
-		}
+		constbuf = &ctx->constbuf[PIPE_SHADER_VERTEX];
+		shader_dirty = !!(dirty & FD_SHADER_DIRTY_VP);
 
 		emit_user_consts(ctx, v, ring, constbuf);
 		emit_ubos(ctx, v, ring, constbuf);
@@ -681,7 +677,7 @@ ir3_emit_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
 
 	/* emit driver params every time: */
 	/* TODO skip emit if shader doesn't use driver params to avoid WFI.. */
-	if (info && (v->type == SHADER_VERTEX)) {
+	if (info) {
 		uint32_t offset = v->constbase.driver_param;
 		if (v->constlen > offset) {
 			uint32_t vertex_params[IR3_DP_COUNT] = {
@@ -717,3 +713,25 @@ ir3_emit_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
 		}
 	}
 }
+
+void
+ir3_emit_fs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
+		struct fd_context *ctx)
+{
+	uint32_t dirty = ctx->dirty;
+
+	debug_assert(v->type == SHADER_FRAGMENT);
+
+	if (dirty & (FD_DIRTY_PROG | FD_DIRTY_CONSTBUF)) {
+		struct fd_constbuf_stateobj *constbuf;
+		bool shader_dirty;
+
+		constbuf = &ctx->constbuf[PIPE_SHADER_FRAGMENT];
+		shader_dirty = !!(dirty & FD_SHADER_DIRTY_FP);
+
+		emit_user_consts(ctx, v, ring, constbuf);
+		emit_ubos(ctx, v, ring, constbuf);
+		if (shader_dirty)
+			emit_immediates(ctx, v, ring);
+	}
+}
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index 59584ec5b7..e5dcb73978 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -318,8 +318,10 @@ uint64_t ir3_shader_outputs(const struct ir3_shader *so);
 
 struct fd_ringbuffer;
 struct fd_context;
-void ir3_emit_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
-		struct fd_context *ctx, const struct pipe_draw_info *info, uint32_t dirty);
+void ir3_emit_vs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
+		struct fd_context *ctx, const struct pipe_draw_info *info);
+void ir3_emit_fs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
+		struct fd_context *ctx);
 
 static inline const char *
 ir3_shader_stage(struct ir3_shader *shader)




More information about the mesa-commit mailing list