Mesa (master): nv50: enable texture compression

Ilia Mirkin imirkin at kemper.freedesktop.org
Mon Jan 5 05:42:01 UTC 2015


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

Author: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
Date:   Sat Jan  3 01:00:08 2015 +0100

nv50: enable texture compression

Compression seems to be supported for only some formats. Enable it for
those. Previously this was disabled for everything despite the code
looking like it was actually enabled.

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

 src/gallium/drivers/nouveau/nv50/nv50_miptree.c |   22 +++++++++++++++++++---
 src/gallium/drivers/nouveau/nv50/nv50_screen.c  |    7 +++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
index 1aacaec..2e41091 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
@@ -65,8 +65,7 @@ nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz)
 static uint32_t
 nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed)
 {
-   const unsigned ms = mt->ms_x + mt->ms_y;
-
+   const unsigned ms = util_logbase2(mt->base.base.nr_samples);
    uint32_t tile_flags;
 
    if (unlikely(mt->base.base.flags & NOUVEAU_RESOURCE_FLAG_LINEAR))
@@ -96,6 +95,22 @@ nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed)
       tile_flags = 0x60 + ms;
       break;
    default:
+      /* Most color formats don't work with compression. */
+      compressed = false;
+      /* fallthrough */
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+   case PIPE_FORMAT_R8G8B8A8_SRGB:
+   case PIPE_FORMAT_R8G8B8X8_UNORM:
+   case PIPE_FORMAT_R8G8B8X8_SRGB:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
+   case PIPE_FORMAT_B8G8R8A8_SRGB:
+   case PIPE_FORMAT_B8G8R8X8_UNORM:
+   case PIPE_FORMAT_B8G8R8X8_SRGB:
+   case PIPE_FORMAT_R10G10B10A2_UNORM:
+   case PIPE_FORMAT_B10G10R10A2_UNORM:
+   case PIPE_FORMAT_R16G16B16A16_FLOAT:
+   case PIPE_FORMAT_R16G16B16X16_FLOAT:
+   case PIPE_FORMAT_R11G11B10_FLOAT:
       switch (util_format_get_blocksizebits(mt->base.base.format)) {
       case 128:
          assert(ms < 3);
@@ -318,6 +333,7 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    struct nouveau_device *dev = nouveau_screen(pscreen)->device;
    struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
    struct pipe_resource *pt = &mt->base.base;
+   boolean compressed = dev->drm_version >= 0x01000101;
    int ret;
    union nouveau_bo_config bo_config;
    uint32_t bo_flags;
@@ -333,7 +349,7 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    if (pt->bind & PIPE_BIND_LINEAR)
       pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
 
-   bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, TRUE);
+   bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, compressed);
 
    if (!nv50_miptree_init_ms_mode(mt)) {
       FREE(mt);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 2d8347b..da237f9 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -449,6 +449,13 @@ nv50_screen_init_hwctx(struct nv50_screen *screen)
       PUSH_DATA (push, 0x18);
    }
 
+   BEGIN_NV04(push, NV50_3D(ZETA_COMP_ENABLE), 1);
+   PUSH_DATA(push, screen->base.device->drm_version >= 0x01000101);
+
+   BEGIN_NV04(push, NV50_3D(RT_COMP_ENABLE(0)), 8);
+   for (i = 0; i < 8; ++i)
+      PUSH_DATA(push, screen->base.device->drm_version >= 0x01000101);
+
    BEGIN_NV04(push, NV50_3D(RT_CONTROL), 1);
    PUSH_DATA (push, 1);
 




More information about the mesa-commit mailing list