From: Jerome Glisse <jgli...@redhat.com>

Most test pass, issue are with border color and swizzle.

Based on ircnick<maelcum> patch.

v2: Restaged commit hunk

Signed-off-by: Jerome Glisse <jgli...@redhat.com>
---
 src/gallium/drivers/radeonsi/si_state.c | 71 ++++++++++++++++++++++++++++++++-
 src/gallium/drivers/radeonsi/sid.h      |  7 ++++
 2 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 61ede64..a39843c 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -30,6 +30,7 @@
 #include "util/u_helpers.h"
 #include "util/u_math.h"
 #include "util/u_pack_color.h"
+#include "util/u_format_s3tc.h"
 #include "tgsi/tgsi_parse.h"
 #include "radeonsi_pipe.h"
 #include "radeonsi_shader.h"
@@ -1164,6 +1165,8 @@ static uint32_t si_translate_texformat(struct pipe_screen 
*screen,
                                       const struct util_format_description 
*desc,
                                       int first_non_void)
 {
+       struct r600_screen *rscreen = (struct r600_screen*)screen;
+       bool enable_s3tc = rscreen->info.drm_minor >= 31;
        boolean uniform = TRUE;
        int i;
 
@@ -1205,7 +1208,51 @@ static uint32_t si_translate_texformat(struct 
pipe_screen *screen,
                break;
        }
 
-       /* TODO compressed formats */
+       if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC) {
+               if (!enable_s3tc)
+                       goto out_unknown;
+
+               switch (format) {
+               case PIPE_FORMAT_RGTC1_SNORM:
+               case PIPE_FORMAT_LATC1_SNORM:
+               case PIPE_FORMAT_RGTC1_UNORM:
+               case PIPE_FORMAT_LATC1_UNORM:
+                       return V_008F14_IMG_DATA_FORMAT_BC4;
+               case PIPE_FORMAT_RGTC2_SNORM:
+               case PIPE_FORMAT_LATC2_SNORM:
+               case PIPE_FORMAT_RGTC2_UNORM:
+               case PIPE_FORMAT_LATC2_UNORM:
+                       return V_008F14_IMG_DATA_FORMAT_BC5;
+               default:
+                       goto out_unknown;
+               }
+       }
+
+       if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
+
+               if (!enable_s3tc)
+                       goto out_unknown;
+
+               if (!util_format_s3tc_enabled) {
+                       goto out_unknown;
+               }
+
+               switch (format) {
+               case PIPE_FORMAT_DXT1_RGB:
+               case PIPE_FORMAT_DXT1_RGBA:
+               case PIPE_FORMAT_DXT1_SRGB:
+               case PIPE_FORMAT_DXT1_SRGBA:
+                       return V_008F14_IMG_DATA_FORMAT_BC1;
+               case PIPE_FORMAT_DXT3_RGBA:
+               case PIPE_FORMAT_DXT3_SRGBA:
+                       return V_008F14_IMG_DATA_FORMAT_BC2;
+               case PIPE_FORMAT_DXT5_RGBA:
+               case PIPE_FORMAT_DXT5_SRGBA:
+                       return V_008F14_IMG_DATA_FORMAT_BC3;
+               default:
+                       goto out_unknown;
+               }
+       }
 
        if (format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
                return V_008F14_IMG_DATA_FORMAT_5_9_9_9;
@@ -2109,7 +2156,27 @@ static struct pipe_sampler_view 
*si_create_sampler_view(struct pipe_context *ctx
                break;
        default:
                if (first_non_void < 0) {
-                       num_format = V_008F14_IMG_NUM_FORMAT_FLOAT;
+                       if (util_format_is_compressed(pipe_format)) {
+                               switch (pipe_format) {
+                               case PIPE_FORMAT_DXT1_SRGB:
+                               case PIPE_FORMAT_DXT1_SRGBA:
+                               case PIPE_FORMAT_DXT3_SRGBA:
+                               case PIPE_FORMAT_DXT5_SRGBA:
+                                       num_format = 
V_008F14_IMG_NUM_FORMAT_SRGB;
+                                       break;
+                               case PIPE_FORMAT_RGTC1_SNORM:
+                               case PIPE_FORMAT_LATC1_SNORM:
+                               case PIPE_FORMAT_RGTC2_SNORM:
+                               case PIPE_FORMAT_LATC2_SNORM:
+                                       num_format = 
V_008F14_IMG_NUM_FORMAT_SNORM;
+                                       break;
+                               default:
+                                       num_format = 
V_008F14_IMG_NUM_FORMAT_UNORM;
+                                       break;
+                               }
+                       } else {
+                               num_format = V_008F14_IMG_NUM_FORMAT_FLOAT;
+                       }
                } else if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
                        num_format = V_008F14_IMG_NUM_FORMAT_SRGB;
                } else {
diff --git a/src/gallium/drivers/radeonsi/sid.h 
b/src/gallium/drivers/radeonsi/sid.h
index 8528981..2722c79 100644
--- a/src/gallium/drivers/radeonsi/sid.h
+++ b/src/gallium/drivers/radeonsi/sid.h
@@ -3434,6 +3434,13 @@
 #define     V_008F14_IMG_DATA_FORMAT_GB_GR                          0x20
 #define     V_008F14_IMG_DATA_FORMAT_BG_RG                          0x21
 #define     V_008F14_IMG_DATA_FORMAT_5_9_9_9                        0x22
+#define     V_008F14_IMG_DATA_FORMAT_BC1                            0x23
+#define     V_008F14_IMG_DATA_FORMAT_BC2                            0x24
+#define     V_008F14_IMG_DATA_FORMAT_BC3                            0x25
+#define     V_008F14_IMG_DATA_FORMAT_BC4                            0x26
+#define     V_008F14_IMG_DATA_FORMAT_BC5                            0x27
+#define     V_008F14_IMG_DATA_FORMAT_BC6                            0x28
+#define     V_008F14_IMG_DATA_FORMAT_BC7                            0x29
 #define     V_008F14_IMG_DATA_FORMAT_RESERVED_42                    0x2A
 #define     V_008F14_IMG_DATA_FORMAT_RESERVED_43                    0x2B
 #define     V_008F14_IMG_DATA_FORMAT_FMASK8_S2_F1                   0x2C
-- 
1.8.1.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to