Mesa (master): freedreno/a4xx: add fake RGTC support (required for GL3)

Rob Clark robclark at kemper.freedesktop.org
Wed Nov 18 19:31:36 UTC 2015


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

Author: Rob Clark <robclark at freedesktop.org>
Date:   Tue Nov 17 12:35:09 2015 -0500

freedreno/a4xx: add fake RGTC support (required for GL3)

The a4xx bits corresponding to 'freedreno/a3xx: add fake RGTC support
(required for GL3)'

TODO some more r/e.. maybe we get lucky and hw supports some of this
directly?  For now this will help us enable gl3.

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

---

 docs/relnotes/11.1.0.html                        |    2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_format.c  |   20 ++++++++++++++++++++
 src/gallium/drivers/freedreno/a4xx/fd4_format.h  |    1 +
 src/gallium/drivers/freedreno/a4xx/fd4_texture.c |    2 +-
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/docs/relnotes/11.1.0.html b/docs/relnotes/11.1.0.html
index 00d5177..f4563ea 100644
--- a/docs/relnotes/11.1.0.html
+++ b/docs/relnotes/11.1.0.html
@@ -60,7 +60,7 @@ Note: some of the new features are only available with certain drivers.
 <li>GL_ARB_vertex_type_2_10_10_10_rev on freedreno (a3xx)</li>
 <li>GL_EXT_buffer_storage implemented for when ES 3.1 support is gained</li>
 <li>GL_EXT_draw_elements_base_vertex on all drivers</li>
-<li>GL_EXT_texture_compression_rgtc / latc on freedreno (a3xx)</li>
+<li>GL_EXT_texture_compression_rgtc / latc on freedreno (a3xx & a4xx)</li>
 <li>GL_NV_conditional_render on freedreno</li>
 <li>GL_OES_draw_elements_base_vertex on all drivers</li>
 <li>EGL_KHR_create_context on softpipe, llvmpipe</li>
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_format.c b/src/gallium/drivers/freedreno/a4xx/fd4_format.c
index 7ff3c8c..087d04f 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_format.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_format.c
@@ -274,6 +274,16 @@ static struct fd4_format formats[PIPE_FORMAT_COUNT] = {
 	_T(DXT3_SRGBA, DXT3, NONE, WZYX),
 	_T(DXT5_RGBA,  DXT5, NONE, WZYX),
 	_T(DXT5_SRGBA, DXT5, NONE, WZYX),
+
+	/* faked */
+	_T(RGTC1_UNORM, 8_8_8_8_UNORM, NONE, WZYX),
+	_T(RGTC1_SNORM, 8_8_8_8_SNORM, NONE, WZYX),
+	_T(RGTC2_UNORM, 8_8_8_8_UNORM, NONE, WZYX),
+	_T(RGTC2_SNORM, 8_8_8_8_SNORM, NONE, WZYX),
+	_T(LATC1_UNORM, 8_8_8_8_UNORM, NONE, WZYX),
+	_T(LATC1_SNORM, 8_8_8_8_SNORM, NONE, WZYX),
+	_T(LATC2_UNORM, 8_8_8_8_UNORM, NONE, WZYX),
+	_T(LATC2_SNORM, 8_8_8_8_SNORM, NONE, WZYX),
 };
 
 /* convert pipe format to vertex buffer format: */
@@ -316,6 +326,8 @@ fd4_pipe2fetchsize(enum pipe_format format)
 {
 	if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)
 		format = PIPE_FORMAT_Z32_FLOAT;
+	else if (util_format_description(format)->layout == UTIL_FORMAT_LAYOUT_RGTC)
+		format = PIPE_FORMAT_R8G8B8A8_UNORM;
 
 	switch (util_format_get_blocksizebits(format) / util_format_get_blockwidth(format)) {
 	case 8:   return TFETCH4_1_BYTE;
@@ -331,6 +343,14 @@ fd4_pipe2fetchsize(enum pipe_format format)
 	}
 }
 
+unsigned
+fd4_pipe2nblocksx(enum pipe_format format, unsigned width)
+{
+	if (util_format_description(format)->layout == UTIL_FORMAT_LAYOUT_RGTC)
+		format = PIPE_FORMAT_R8G8B8A8_UNORM;
+	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 fd4_tex_swiz() will do the wrong thing,
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_format.h b/src/gallium/drivers/freedreno/a4xx/fd4_format.h
index 04837da..8c365f0 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_format.h
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_format.h
@@ -38,6 +38,7 @@ 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);
+unsigned fd4_pipe2nblocksx(enum pipe_format format, unsigned width);
 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/a4xx/fd4_texture.c b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
index a1e4536..297854f 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
@@ -238,7 +238,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 	so->texconst2 =
 		A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(cso->format)) |
 		A4XX_TEX_CONST_2_PITCH(
-			util_format_get_nblocksx(
+			fd4_pipe2nblocksx(
 				cso->format, rsc->slices[lvl].pitch) * rsc->cpp);
 
 	switch (prsc->target) {




More information about the mesa-commit mailing list