Mesa (master): freedreno: fdN_gmem_restore_format() is not gen specific

Rob Clark robclark at kemper.freedesktop.org
Sun Dec 18 19:11:46 UTC 2016


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

Author: Rob Clark <robdclark at gmail.com>
Date:   Mon Dec 12 16:59:09 2016 -0500

freedreno: fdN_gmem_restore_format() is not gen specific

Refactor out into a common helper, since this is the same across
generations when we need equiv z/s gmem restore format.

Next patch needs this in a5xx, rather than creating yet another
helper push this into core.

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

---

 src/gallium/drivers/freedreno/a3xx/fd3_emit.c   |  4 ++--
 src/gallium/drivers/freedreno/a3xx/fd3_format.c | 21 ---------------------
 src/gallium/drivers/freedreno/a3xx/fd3_format.h |  1 -
 src/gallium/drivers/freedreno/a4xx/fd4_emit.c   |  4 ++--
 src/gallium/drivers/freedreno/a4xx/fd4_format.c | 23 -----------------------
 src/gallium/drivers/freedreno/a4xx/fd4_format.h |  1 -
 src/gallium/drivers/freedreno/freedreno_util.c  | 20 ++++++++++++++++++++
 src/gallium/drivers/freedreno/freedreno_util.h  |  1 +
 8 files changed, 25 insertions(+), 50 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 397a433..95e6d26 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -299,13 +299,13 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
 		}
 
 		struct fd_resource *rsc = fd_resource(psurf[i]->texture);
-		enum pipe_format format = fd3_gmem_restore_format(psurf[i]->format);
+		enum pipe_format format = fd_gmem_restore_format(psurf[i]->format);
 		/* The restore blit_zs shader expects stencil in sampler 0, and depth
 		 * in sampler 1
 		 */
 		if (rsc->stencil && i == 0) {
 			rsc = rsc->stencil;
-			format = fd3_gmem_restore_format(rsc->base.b.format);
+			format = fd_gmem_restore_format(rsc->base.b.format);
 		}
 
 		/* note: PIPE_BUFFER disallowed for surfaces */
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.c b/src/gallium/drivers/freedreno/a3xx/fd3_format.c
index 5cf458b..f850897 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_format.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.c
@@ -348,27 +348,6 @@ fd3_pipe2nblocksx(enum pipe_format format, unsigned width)
 	return util_format_get_nblocksx(format, width);
 }
 
-/* we need to special case a bit the depth/stencil restore, because we are
- * using the texture sampler to blit into the depth/stencil buffer, *not*
- * into a color buffer.  Otherwise fd3_tex_swiz() will do the wrong thing,
- * as it is assuming that you are sampling into normal render target..
- */
-enum pipe_format
-fd3_gmem_restore_format(enum pipe_format format)
-{
-	switch (format) {
-	case PIPE_FORMAT_Z24X8_UNORM:
-	case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-		return PIPE_FORMAT_R8G8B8A8_UNORM;
-	case PIPE_FORMAT_Z16_UNORM:
-		return PIPE_FORMAT_R8G8_UNORM;
-	case PIPE_FORMAT_S8_UINT:
-		return PIPE_FORMAT_R8_UNORM;
-	default:
-		return format;
-	}
-}
-
 enum a3xx_color_fmt
 fd3_fs_output_format(enum pipe_format format)
 {
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.h b/src/gallium/drivers/freedreno/a3xx/fd3_format.h
index 48c503e..7286770 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_format.h
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.h
@@ -34,7 +34,6 @@ enum a3xx_vtx_fmt fd3_pipe2vtx(enum pipe_format format);
 enum a3xx_tex_fmt fd3_pipe2tex(enum pipe_format format);
 enum a3xx_tex_fetchsize fd3_pipe2fetchsize(enum pipe_format format);
 enum a3xx_color_fmt fd3_pipe2color(enum pipe_format format);
-enum pipe_format fd3_gmem_restore_format(enum pipe_format format);
 enum a3xx_color_fmt fd3_fs_output_format(enum pipe_format format);
 enum a3xx_color_swap fd3_pipe2swap(enum pipe_format format);
 unsigned fd3_pipe2nblocksx(enum pipe_format format, unsigned width);
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
index a5fedc7..9231823 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
@@ -291,14 +291,14 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
 	for (i = 0; i < nr_bufs; i++) {
 		if (bufs[i]) {
 			struct fd_resource *rsc = fd_resource(bufs[i]->texture);
-			enum pipe_format format = fd4_gmem_restore_format(bufs[i]->format);
+			enum pipe_format format = fd_gmem_restore_format(bufs[i]->format);
 
 			/* The restore blit_zs shader expects stencil in sampler 0,
 			 * and depth in sampler 1
 			 */
 			if (rsc->stencil && (i == 0)) {
 				rsc = rsc->stencil;
-				format = fd4_gmem_restore_format(rsc->base.b.format);
+				format = fd_gmem_restore_format(rsc->base.b.format);
 			}
 
 			/* note: PIPE_BUFFER disallowed for surfaces */
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_format.c b/src/gallium/drivers/freedreno/a4xx/fd4_format.c
index efc5e7c..3e1dc27 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_format.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_format.c
@@ -394,29 +394,6 @@ fd4_pipe2fetchsize(enum pipe_format format)
 	}
 }
 
-/* we need to special case a bit the depth/stencil restore, because we are
- * using the texture sampler to blit into the depth/stencil buffer, *not*
- * into a color buffer.  Otherwise fd4_tex_swiz() will do the wrong thing,
- * as it is assuming that you are sampling into normal render target..
- *
- * TODO looks like we can probably share w/ a3xx..
- */
-enum pipe_format
-fd4_gmem_restore_format(enum pipe_format format)
-{
-	switch (format) {
-	case PIPE_FORMAT_Z24X8_UNORM:
-	case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-		return PIPE_FORMAT_R8G8B8A8_UNORM;
-	case PIPE_FORMAT_Z16_UNORM:
-		return PIPE_FORMAT_R8G8_UNORM;
-	case PIPE_FORMAT_S8_UINT:
-		return PIPE_FORMAT_R8_UNORM;
-	default:
-		return format;
-	}
-}
-
 enum a4xx_depth_format
 fd4_pipe2depth(enum pipe_format format)
 {
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_format.h b/src/gallium/drivers/freedreno/a4xx/fd4_format.h
index 04837da..a558e42 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_format.h
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_format.h
@@ -36,7 +36,6 @@
 enum a4xx_vtx_fmt fd4_pipe2vtx(enum pipe_format format);
 enum a4xx_tex_fmt fd4_pipe2tex(enum pipe_format format);
 enum a4xx_color_fmt fd4_pipe2color(enum pipe_format format);
-enum pipe_format fd4_gmem_restore_format(enum pipe_format format);
 enum a3xx_color_swap fd4_pipe2swap(enum pipe_format format);
 enum a4xx_tex_fetchsize fd4_pipe2fetchsize(enum pipe_format format);
 enum a4xx_depth_format fd4_pipe2depth(enum pipe_format format);
diff --git a/src/gallium/drivers/freedreno/freedreno_util.c b/src/gallium/drivers/freedreno/freedreno_util.c
index c8f2127..5d0ea4e 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.c
+++ b/src/gallium/drivers/freedreno/freedreno_util.c
@@ -67,6 +67,26 @@ fd_pipe2index(enum pipe_format format)
 	}
 }
 
+/* we need to special case a bit the depth/stencil restore, because we are
+ * using the texture sampler to blit into the depth/stencil buffer, *not*
+ * into a color buffer.  Otherwise fdN_tex_swiz() will do the wrong thing,
+ * as it is assuming that you are sampling into normal render target..
+ */
+enum pipe_format
+fd_gmem_restore_format(enum pipe_format format)
+{
+	switch (format) {
+	case PIPE_FORMAT_Z24X8_UNORM:
+	case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+		return PIPE_FORMAT_R8G8B8A8_UNORM;
+	case PIPE_FORMAT_Z16_UNORM:
+		return PIPE_FORMAT_R8G8_UNORM;
+	case PIPE_FORMAT_S8_UINT:
+		return PIPE_FORMAT_R8_UNORM;
+	default:
+		return format;
+	}
+}
 
 enum adreno_rb_blend_factor
 fd_blend_factor(unsigned factor)
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h
index a2d1358..c699f7b 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/src/gallium/drivers/freedreno/freedreno_util.h
@@ -46,6 +46,7 @@
 
 enum adreno_rb_depth_format fd_pipe2depth(enum pipe_format format);
 enum pc_di_index_size fd_pipe2index(enum pipe_format format);
+enum pipe_format fd_gmem_restore_format(enum pipe_format format);
 enum adreno_rb_blend_factor fd_blend_factor(unsigned factor);
 enum adreno_pa_su_sc_draw fd_polygon_mode(unsigned mode);
 enum adreno_stencil_op fd_stencil_op(unsigned op);




More information about the mesa-commit mailing list