freedreno/a4xx: add astc formats
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 21 Nov 2015 16:49:03 +0000 (11:49 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 23 Nov 2015 16:17:15 +0000 (11:17 -0500)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/a4xx/fd4_format.c
src/gallium/drivers/freedreno/freedreno_resource.c

index dceb3b98c75527de91f28681023f3b4a54e575a8..dc126b153cf127a5f2c664ceca1db58ba931cf17 100644 (file)
@@ -303,6 +303,36 @@ static struct fd4_format formats[PIPE_FORMAT_COUNT] = {
        _T(LATC1_SNORM, RGTC1_SNORM, NONE, WZYX),
        _T(LATC2_UNORM, RGTC2_UNORM, NONE, WZYX),
        _T(LATC2_SNORM, RGTC2_SNORM, NONE, WZYX),
+
+       _T(ASTC_4x4,   ASTC_4x4,   NONE, WZYX),
+       _T(ASTC_5x4,   ASTC_5x4,   NONE, WZYX),
+       _T(ASTC_5x5,   ASTC_5x5,   NONE, WZYX),
+       _T(ASTC_6x5,   ASTC_6x5,   NONE, WZYX),
+       _T(ASTC_6x6,   ASTC_6x6,   NONE, WZYX),
+       _T(ASTC_8x5,   ASTC_8x5,   NONE, WZYX),
+       _T(ASTC_8x6,   ASTC_8x6,   NONE, WZYX),
+       _T(ASTC_8x8,   ASTC_8x8,   NONE, WZYX),
+       _T(ASTC_10x5,  ASTC_10x5,  NONE, WZYX),
+       _T(ASTC_10x6,  ASTC_10x6,  NONE, WZYX),
+       _T(ASTC_10x8,  ASTC_10x8,  NONE, WZYX),
+       _T(ASTC_10x10, ASTC_10x10, NONE, WZYX),
+       _T(ASTC_12x10, ASTC_12x10, NONE, WZYX),
+       _T(ASTC_12x12, ASTC_12x12, NONE, WZYX),
+
+       _T(ASTC_4x4_SRGB,   ASTC_4x4,   NONE, WZYX),
+       _T(ASTC_5x4_SRGB,   ASTC_5x4,   NONE, WZYX),
+       _T(ASTC_5x5_SRGB,   ASTC_5x5,   NONE, WZYX),
+       _T(ASTC_6x5_SRGB,   ASTC_6x5,   NONE, WZYX),
+       _T(ASTC_6x6_SRGB,   ASTC_6x6,   NONE, WZYX),
+       _T(ASTC_8x5_SRGB,   ASTC_8x5,   NONE, WZYX),
+       _T(ASTC_8x6_SRGB,   ASTC_8x6,   NONE, WZYX),
+       _T(ASTC_8x8_SRGB,   ASTC_8x8,   NONE, WZYX),
+       _T(ASTC_10x5_SRGB,  ASTC_10x5,  NONE, WZYX),
+       _T(ASTC_10x6_SRGB,  ASTC_10x6,  NONE, WZYX),
+       _T(ASTC_10x8_SRGB,  ASTC_10x8,  NONE, WZYX),
+       _T(ASTC_10x10_SRGB, ASTC_10x10, NONE, WZYX),
+       _T(ASTC_12x10_SRGB, ASTC_12x10, NONE, WZYX),
+       _T(ASTC_12x12_SRGB, ASTC_12x12, NONE, WZYX),
 };
 
 /* convert pipe format to vertex buffer format: */
@@ -346,6 +376,9 @@ fd4_pipe2fetchsize(enum pipe_format format)
        if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)
                format = PIPE_FORMAT_Z32_FLOAT;
 
+       if (util_format_description(format)->layout == UTIL_FORMAT_LAYOUT_ASTC)
+               return TFETCH4_16_BYTE;
+
        switch (util_format_get_blocksizebits(format) / util_format_get_blockwidth(format)) {
        case 8:   return TFETCH4_1_BYTE;
        case 16:  return TFETCH4_2_BYTE;
index c8e2779d390e0a3e267cff25e84481302a0d0fbd..63ca9e30620acbcab4d7b7207ccbf421144efd65 100644 (file)
@@ -484,6 +484,7 @@ static uint32_t
 setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format format)
 {
        struct pipe_resource *prsc = &rsc->base.b;
+       enum util_format_layout layout = util_format_description(format)->layout;
        uint32_t level, size = 0;
        uint32_t width = prsc->width0;
        uint32_t height = prsc->height0;
@@ -497,7 +498,11 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
                struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
                uint32_t blocks;
 
-               slice->pitch = width = align(width, 32);
+               if (layout == UTIL_FORMAT_LAYOUT_ASTC)
+                       slice->pitch = width =
+                               util_align_npot(width, 32 * util_format_get_blockwidth(format));
+               else
+                       slice->pitch = width = align(width, 32);
                slice->offset = size;
                blocks = util_format_get_nblocks(format, width, height);
                /* 1d array and 2d array textures must all have the same layer size