1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[dxvk] Added convenience functions to work with compressed image sizes

This commit is contained in:
Philip Rebohle 2018-01-20 20:31:47 +01:00
parent 496acd71b1
commit a84e45bdd2
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 51 additions and 30 deletions

View File

@ -35,29 +35,3 @@ namespace dxvk::util {
}
}
bool operator == (VkExtent3D a, VkExtent3D b) {
return a.width == b.width
&& a.height == b.height
&& a.depth == b.depth;
}
bool operator != (VkExtent3D a, VkExtent3D b) {
return a.width != b.width
|| a.height != b.height
|| a.depth != b.depth;
}
bool operator == (VkExtent2D a, VkExtent2D b) {
return a.width == b.width
&& a.height == b.height;
}
bool operator != (VkExtent2D a, VkExtent2D b) {
return a.width != b.width
|| a.height != b.height;
}

View File

@ -21,10 +21,57 @@ namespace dxvk::util {
*/
uint32_t computeMipLevelCount(VkExtent3D imageSize);
/**
* \brief Computes block count for compressed images
*
* Convenience function to compute the size, in
* blocks, of compressed images subresources.
* \param [in] imageSize The image size
* \param [in] blockSize Size per pixel block
* \returns Number of blocks in the image
*/
inline VkExtent3D computeBlockCount(VkExtent3D imageSize, VkExtent3D blockSize) {
return VkExtent3D {
(imageSize.width + blockSize.width - 1) / blockSize.width,
(imageSize.height + blockSize.height - 1) / blockSize.height,
(imageSize.depth + blockSize.depth - 1) / blockSize.depth };
}
/**
* \brief Computes number of pixels or blocks of an image
*
* Basically returns the product of width, height and depth.
* \param [in] extent Image extent, in pixels or blocks
* \returns Flattened number of pixels or blocks
*/
inline uint32_t flattenImageExtent(VkExtent3D extent) {
return extent.width * extent.height * extent.depth;
}
}
bool operator == (VkExtent3D a, VkExtent3D b);
bool operator != (VkExtent3D a, VkExtent3D b);
bool operator == (VkExtent2D a, VkExtent2D b);
bool operator != (VkExtent2D a, VkExtent2D b);
inline bool operator == (VkExtent3D a, VkExtent3D b) {
return a.width == b.width
&& a.height == b.height
&& a.depth == b.depth;
}
inline bool operator != (VkExtent3D a, VkExtent3D b) {
return a.width != b.width
|| a.height != b.height
|| a.depth != b.depth;
}
inline bool operator == (VkExtent2D a, VkExtent2D b) {
return a.width == b.width
&& a.height == b.height;
}
inline bool operator != (VkExtent2D a, VkExtent2D b) {
return a.width != b.width
|| a.height != b.height;
}