diff --git a/src/dxvk/dxvk_util.cpp b/src/dxvk/dxvk_util.cpp index 4066c20fb..4f9879c4f 100644 --- a/src/dxvk/dxvk_util.cpp +++ b/src/dxvk/dxvk_util.cpp @@ -145,10 +145,16 @@ namespace dxvk::util { VkDeviceSize computeImageDataSize(VkFormat format, VkExtent3D extent) { const DxvkFormatInfo* formatInfo = lookupFormatInfo(format); + return computeImageDataSize(format, extent, formatInfo->aspectMask); + } + + + VkDeviceSize computeImageDataSize(VkFormat format, VkExtent3D extent, VkImageAspectFlags aspects) { + const DxvkFormatInfo* formatInfo = lookupFormatInfo(format); VkDeviceSize size = 0; - for (auto aspects = formatInfo->aspectMask; aspects; ) { + while (aspects) { auto aspect = vk::getNextAspect(aspects); auto elementSize = formatInfo->elementSize; auto planeExtent = extent; diff --git a/src/dxvk/dxvk_util.h b/src/dxvk/dxvk_util.h index a9a4b7ee4..967458faf 100644 --- a/src/dxvk/dxvk_util.h +++ b/src/dxvk/dxvk_util.h @@ -298,6 +298,19 @@ namespace dxvk::util { */ VkDeviceSize computeImageDataSize(VkFormat format, VkExtent3D extent); + /** + * \brief Computes image data size, in bytes + * + * Convenience method that can be used to compute the number + * of bytes required to store image data in a given format + * for the given aspects. + * \param [in] format The image format + * \param [in] extent Image size, in pixels + * \param [in] aspects Aspect mask + * \returns Data size, in bytes + */ + VkDeviceSize computeImageDataSize(VkFormat format, VkExtent3D extent, VkImageAspectFlags aspects); + /** * \brief Applies a component mapping to a component mask *