Mesa (master): freedreno: move bind_sampler_states to per-generation

Rob Clark robclark at kemper.freedesktop.org
Mon Sep 29 22:34:04 UTC 2014


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

Author: Rob Clark <robclark at freedesktop.org>
Date:   Mon Sep 29 14:55:38 2014 -0400

freedreno: move bind_sampler_states to per-generation

Keep the existing function as a common helper.  But this lets us move an
a2xx specific hack out of common code.  And the PIPE_TEX_WRAP_CLAMP
emulation will require an a3xx specific hack.  So rather than piling on
hacks, split this out.

Signed-off-by: Rob Clark <robclark at freedesktop.org>

---

 src/gallium/drivers/freedreno/a2xx/fd2_texture.c  |   20 +++++++++++
 src/gallium/drivers/freedreno/a3xx/fd3_texture.c  |    9 +++++
 src/gallium/drivers/freedreno/freedreno_texture.c |   38 ++++++++-------------
 src/gallium/drivers/freedreno/freedreno_texture.h |    4 +++
 4 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
index 870694c..e5e1f35 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
@@ -101,6 +101,25 @@ fd2_sampler_state_create(struct pipe_context *pctx,
 	return so;
 }
 
+static void
+fd2_sampler_states_bind(struct pipe_context *pctx,
+		unsigned shader, unsigned start,
+		unsigned nr, void **hwcso)
+{
+	if (shader == PIPE_SHADER_FRAGMENT) {
+		struct fd_context *ctx = fd_context(pctx);
+
+		/* on a2xx, since there is a flat address space for textures/samplers,
+		 * a change in # of fragment textures/samplers will trigger patching and
+		 * re-emitting the vertex shader:
+		 */
+		if (nr != ctx->fragtex.num_samplers)
+			ctx->dirty |= FD_DIRTY_TEXSTATE;
+	}
+
+	fd_sampler_states_bind(pctx, shader, start, nr, hwcso);
+}
+
 static struct pipe_sampler_view *
 fd2_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 		const struct pipe_sampler_view *cso)
@@ -154,5 +173,6 @@ void
 fd2_texture_init(struct pipe_context *pctx)
 {
 	pctx->create_sampler_state = fd2_sampler_state_create;
+	pctx->bind_sampler_states = fd2_sampler_states_bind;
 	pctx->create_sampler_view = fd2_sampler_view_create;
 }
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
index 436d51a..918dcc4 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
@@ -119,6 +119,14 @@ fd3_sampler_state_create(struct pipe_context *pctx,
 	return so;
 }
 
+static void
+fd3_sampler_states_bind(struct pipe_context *pctx,
+		unsigned shader, unsigned start,
+		unsigned nr, void **hwcso)
+{
+	fd_sampler_states_bind(pctx, shader, start, nr, hwcso);
+}
+
 static enum a3xx_tex_type
 tex_type(unsigned target)
 {
@@ -204,5 +212,6 @@ void
 fd3_texture_init(struct pipe_context *pctx)
 {
 	pctx->create_sampler_state = fd3_sampler_state_create;
+	pctx->bind_sampler_states = fd3_sampler_states_bind;
 	pctx->create_sampler_view = fd3_sampler_view_create;
 }
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c
index 212e506..e61bf8a 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.c
+++ b/src/gallium/drivers/freedreno/freedreno_texture.c
@@ -49,7 +49,7 @@ fd_sampler_view_destroy(struct pipe_context *pctx,
 	FREE(view);
 }
 
-static void bind_sampler_states(struct fd_texture_stateobj *prog,
+static void bind_sampler_states(struct fd_texture_stateobj *tex,
 		unsigned nr, void **hwcso)
 {
 	unsigned i;
@@ -58,19 +58,19 @@ static void bind_sampler_states(struct fd_texture_stateobj *prog,
 	for (i = 0; i < nr; i++) {
 		if (hwcso[i])
 			new_nr = i + 1;
-		prog->samplers[i] = hwcso[i];
-		prog->dirty_samplers |= (1 << i);
+		tex->samplers[i] = hwcso[i];
+		tex->dirty_samplers |= (1 << i);
 	}
 
-	for (; i < prog->num_samplers; i++) {
-		prog->samplers[i] = NULL;
-		prog->dirty_samplers |= (1 << i);
+	for (; i < tex->num_samplers; i++) {
+		tex->samplers[i] = NULL;
+		tex->dirty_samplers |= (1 << i);
 	}
 
-	prog->num_samplers = new_nr;
+	tex->num_samplers = new_nr;
 }
 
-static void set_sampler_views(struct fd_texture_stateobj *prog,
+static void set_sampler_views(struct fd_texture_stateobj *tex,
 		unsigned nr, struct pipe_sampler_view **views)
 {
 	unsigned i;
@@ -79,19 +79,19 @@ static void set_sampler_views(struct fd_texture_stateobj *prog,
 	for (i = 0; i < nr; i++) {
 		if (views[i])
 			new_nr = i + 1;
-		pipe_sampler_view_reference(&prog->textures[i], views[i]);
-		prog->dirty_samplers |= (1 << i);
+		pipe_sampler_view_reference(&tex->textures[i], views[i]);
+		tex->dirty_samplers |= (1 << i);
 	}
 
-	for (; i < prog->num_textures; i++) {
-		pipe_sampler_view_reference(&prog->textures[i], NULL);
-		prog->dirty_samplers |= (1 << i);
+	for (; i < tex->num_textures; i++) {
+		pipe_sampler_view_reference(&tex->textures[i], NULL);
+		tex->dirty_samplers |= (1 << i);
 	}
 
-	prog->num_textures = new_nr;
+	tex->num_textures = new_nr;
 }
 
-static void
+void
 fd_sampler_states_bind(struct pipe_context *pctx,
 		unsigned shader, unsigned start,
 		unsigned nr, void **hwcso)
@@ -101,13 +101,6 @@ fd_sampler_states_bind(struct pipe_context *pctx,
 	assert(start == 0);
 
 	if (shader == PIPE_SHADER_FRAGMENT) {
-		/* on a2xx, since there is a flat address space for textures/samplers,
-		 * a change in # of fragment textures/samplers will trigger patching and
-		 * re-emitting the vertex shader:
-		 */
-		if (nr != ctx->fragtex.num_samplers)
-			ctx->dirty |= FD_DIRTY_TEXSTATE;
-
 		bind_sampler_states(&ctx->fragtex, nr, hwcso);
 		ctx->dirty |= FD_DIRTY_FRAGTEX;
 	}
@@ -169,6 +162,5 @@ fd_texture_init(struct pipe_context *pctx)
 
 	pctx->sampler_view_destroy = fd_sampler_view_destroy;
 
-	pctx->bind_sampler_states = fd_sampler_states_bind;
 	pctx->set_sampler_views = fd_set_sampler_views;
 }
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.h b/src/gallium/drivers/freedreno/freedreno_texture.h
index f73110d..388b980 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.h
+++ b/src/gallium/drivers/freedreno/freedreno_texture.h
@@ -31,6 +31,10 @@
 
 #include "pipe/p_context.h"
 
+void fd_sampler_states_bind(struct pipe_context *pctx,
+		unsigned shader, unsigned start,
+		unsigned nr, void **hwcso);
+
 void fd_texture_init(struct pipe_context *pctx);
 
 #endif /* FREEDRENO_TEXTURE_H_ */




More information about the mesa-commit mailing list