summaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan/vk_format.h
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2018-12-21 12:50:55 +0100
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commitd9c3dc8ec8ac1deb7b62f6e43b17bca7a2d7a290 (patch)
tree3a3b6919c95c156baf41feb87a17d679a0602819 /src/freedreno/vulkan/vk_format.h
parent603354cffa8d98c049ff20567164061e8a4fec17 (diff)
turnip: Add image layout calculations.
Diffstat (limited to 'src/freedreno/vulkan/vk_format.h')
-rw-r--r--src/freedreno/vulkan/vk_format.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/freedreno/vulkan/vk_format.h b/src/freedreno/vulkan/vk_format.h
index 75b7fbd05b3..55ad379f8f3 100644
--- a/src/freedreno/vulkan/vk_format.h
+++ b/src/freedreno/vulkan/vk_format.h
@@ -203,6 +203,28 @@ vk_format_get_blockheight(VkFormat format)
return desc->block.height;
}
+static inline unsigned
+vk_format_get_block_count_width(VkFormat format, unsigned width)
+{
+ unsigned blockwidth = vk_format_get_blockwidth(format);
+ return (width + blockwidth - 1) / blockwidth;
+}
+
+static inline unsigned
+vk_format_get_block_count_height(VkFormat format, unsigned height)
+{
+ unsigned blockheight = vk_format_get_blockheight(format);
+ return (height + blockheight - 1) / blockheight;
+}
+
+static inline unsigned
+vk_format_get_block_count(VkFormat format, unsigned width, unsigned height)
+{
+ return vk_format_get_block_count_width(format, width) *
+ vk_format_get_block_count_height(format, height);
+}
+
+
/**
* Return the index of the first non-void channel
* -1 if no non-void channels