summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-08-14 12:16:46 -0700
committerEric Anholt <[email protected]>2019-08-26 19:44:00 +0000
commit9d988f92919afa08037b9bd8cc9ebbf691982a13 (patch)
tree2d113be333b079885e8994d33a1305cffb20e50a /src/gallium
parent530f4247351623699b829572e251cc76fc435bed (diff)
gallium: Add block depth to the format utils.
I decided not to update nblocks() with a depth arg as the callers wouldn't be doing ASTC 3D. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_format.h25
-rw-r--r--src/gallium/auxiliary/util/u_format_table.py2
2 files changed, 26 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index eb8c2f6ae3f..6922424c47a 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -102,6 +102,9 @@ struct util_format_block
/** Block height in pixels */
unsigned height;
+ /** Block depth in pixels */
+ unsigned depth;
+
/** Block size in bits */
unsigned bits;
};
@@ -842,6 +845,19 @@ util_format_get_blockheight(enum pipe_format format)
return desc->block.height;
}
+static inline uint
+util_format_get_blockdepth(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(desc);
+ if (!desc) {
+ return 1;
+ }
+
+ return desc->block.depth;
+}
+
static inline unsigned
util_format_get_nblocksx(enum pipe_format format,
unsigned x)
@@ -859,10 +875,19 @@ util_format_get_nblocksy(enum pipe_format format,
}
static inline unsigned
+util_format_get_nblocksz(enum pipe_format format,
+ unsigned z)
+{
+ unsigned blockdepth = util_format_get_blockdepth(format);
+ return (z + blockdepth - 1) / blockdepth;
+}
+
+static inline unsigned
util_format_get_nblocks(enum pipe_format format,
unsigned width,
unsigned height)
{
+ assert(util_format_get_blockdepth(format) == 1);
return util_format_get_nblocksx(format, width) * util_format_get_nblocksy(format, height);
}
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index 731e2fbae78..991b3c4545b 100644
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -130,7 +130,7 @@ def write_format_table(formats):
print(" %s," % (format.name,))
print(" \"%s\"," % (format.name,))
print(" \"%s\"," % (format.short_name(),))
- print(" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
+ print(" {%u, %u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_depth, format.block_size()))
print(" %s," % (layout_map(format.layout),))
print(" %u,\t/* nr_channels */" % (format.nr_channels(),))
print(" %s,\t/* is_array */" % (bool_map(format.is_array()),))