radeonsi: add ETC2 support for Stoney
authorMarek Olšák <marek.olsak@amd.com>
Mon, 3 Aug 2015 19:47:38 +0000 (21:47 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 22 Jan 2016 14:36:14 +0000 (15:36 +0100)
Tested and working.

src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/sid.h

index a3ddee8b42ca7708dd16cd5a76e6a4680bb804ed..a50a4474b27aaada13c73fbc78c3f864e7c0af33 100644 (file)
@@ -1376,6 +1376,29 @@ static uint32_t si_translate_texformat(struct pipe_screen *screen,
                }
        }
 
+       if (desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
+           sscreen->b.family >= CHIP_STONEY) {
+               switch (format) {
+               case PIPE_FORMAT_ETC2_RGB8:
+               case PIPE_FORMAT_ETC2_SRGB8:
+                       return V_008F14_IMG_DATA_FORMAT_ETC2_RGB;
+               case PIPE_FORMAT_ETC2_RGB8A1:
+               case PIPE_FORMAT_ETC2_SRGB8A1:
+                       return V_008F14_IMG_DATA_FORMAT_ETC2_RGBA1;
+               case PIPE_FORMAT_ETC2_RGBA8:
+               case PIPE_FORMAT_ETC2_SRGBA8:
+                       return V_008F14_IMG_DATA_FORMAT_ETC2_RGBA;
+               case PIPE_FORMAT_ETC2_R11_UNORM:
+               case PIPE_FORMAT_ETC2_R11_SNORM:
+                       return V_008F14_IMG_DATA_FORMAT_ETC2_R;
+               case PIPE_FORMAT_ETC2_RG11_UNORM:
+               case PIPE_FORMAT_ETC2_RG11_SNORM:
+                       return V_008F14_IMG_DATA_FORMAT_ETC2_RG;
+               default:
+                       goto out_unknown;
+               }
+       }
+
        if (desc->layout == UTIL_FORMAT_LAYOUT_BPTC) {
                if (!enable_compressed_formats)
                        goto out_unknown;
@@ -2808,12 +2831,17 @@ si_create_sampler_view_custom(struct pipe_context *ctx,
                                case PIPE_FORMAT_DXT3_SRGBA:
                                case PIPE_FORMAT_DXT5_SRGBA:
                                case PIPE_FORMAT_BPTC_SRGBA:
+                               case PIPE_FORMAT_ETC2_SRGB8:
+                               case PIPE_FORMAT_ETC2_SRGB8A1:
+                               case PIPE_FORMAT_ETC2_SRGBA8:
                                        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:
+                               case PIPE_FORMAT_ETC2_R11_SNORM:
+                               case PIPE_FORMAT_ETC2_RG11_SNORM:
                                /* implies float, so use SNORM/UNORM to determine
                                   whether data is signed or not */
                                case PIPE_FORMAT_BPTC_RGB_FLOAT:
index 573ab78b4827d001487eb67cae8db0aa2ddcc9a2..9e1e158219fa93c3447a2f5e75023de9d67e6418 100644 (file)
 #define     V_008F14_IMG_DATA_FORMAT_8_24                           0x14
 #define     V_008F14_IMG_DATA_FORMAT_24_8                           0x15
 #define     V_008F14_IMG_DATA_FORMAT_X24_8_32                       0x16
-#define     V_008F14_IMG_DATA_FORMAT_RESERVED_23                    0x17
-#define     V_008F14_IMG_DATA_FORMAT_RESERVED_24                    0x18
-#define     V_008F14_IMG_DATA_FORMAT_RESERVED_25                    0x19
-#define     V_008F14_IMG_DATA_FORMAT_RESERVED_26                    0x1A
-#define     V_008F14_IMG_DATA_FORMAT_RESERVED_27                    0x1B
-#define     V_008F14_IMG_DATA_FORMAT_RESERVED_28                    0x1C
+#define     V_008F14_IMG_DATA_FORMAT_8_AS_8_8_8_8                   0x17 /* stoney+ */
+#define     V_008F14_IMG_DATA_FORMAT_ETC2_RGB                       0x18 /* stoney+ */
+#define     V_008F14_IMG_DATA_FORMAT_ETC2_RGBA                      0x19 /* stoney+ */
+#define     V_008F14_IMG_DATA_FORMAT_ETC2_R                         0x1A /* stoney+ */
+#define     V_008F14_IMG_DATA_FORMAT_ETC2_RG                        0x1B /* stoney+ */
+#define     V_008F14_IMG_DATA_FORMAT_ETC2_RGBA1                     0x1C /* stoney+ */
 #define     V_008F14_IMG_DATA_FORMAT_RESERVED_29                    0x1D
 #define     V_008F14_IMG_DATA_FORMAT_RESERVED_30                    0x1E
 #define     V_008F14_IMG_DATA_FORMAT_RESERVED_31                    0x1F
 #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_16_AS_16_16_16_16              0x2A /* stoney+ */
+#define     V_008F14_IMG_DATA_FORMAT_16_AS_32_32_32_32              0x2B /* stoney+ */
 #define     V_008F14_IMG_DATA_FORMAT_FMASK8_S2_F1                   0x2C
 #define     V_008F14_IMG_DATA_FORMAT_FMASK8_S4_F1                   0x2D
 #define     V_008F14_IMG_DATA_FORMAT_FMASK8_S8_F1                   0x2E
 #define     V_008F14_IMG_DATA_FORMAT_6_5_5                          0x3A
 #define     V_008F14_IMG_DATA_FORMAT_1                              0x3B
 #define     V_008F14_IMG_DATA_FORMAT_1_REVERSED                     0x3C
-#define     V_008F14_IMG_DATA_FORMAT_32_AS_8                        0x3D
-#define     V_008F14_IMG_DATA_FORMAT_32_AS_8_8                      0x3E
+#define     V_008F14_IMG_DATA_FORMAT_32_AS_8                        0x3D /* not on stoney */
+#define     V_008F14_IMG_DATA_FORMAT_32_AS_8_8                      0x3E /* not on stoney */
 #define     V_008F14_IMG_DATA_FORMAT_32_AS_32_32_32_32              0x3F
 #define   S_008F14_NUM_FORMAT(x)                                      (((x) & 0x0F) << 26)
 #define   G_008F14_NUM_FORMAT(x)                                      (((x) >> 26) & 0x0F)