1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 16:24:12 +01:00

[dxvk] Support multi-plane formats in computeImageSize

This commit is contained in:
Philip Rebohle 2021-05-27 16:17:24 +02:00
parent 6462174c13
commit 55a67988b2
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -75,7 +75,25 @@ namespace dxvk::util {
VkDeviceSize computeImageDataSize(VkFormat format, VkExtent3D extent) {
const DxvkFormatInfo* formatInfo = imageFormatInfo(format);
return formatInfo->elementSize * flattenImageExtent(computeBlockCount(extent, formatInfo->blockSize));
VkDeviceSize size = 0;
for (auto aspects = formatInfo->aspectMask; aspects; ) {
auto aspect = vk::getNextAspect(aspects);
auto elementSize = formatInfo->elementSize;
auto planeExtent = extent;
if (formatInfo->flags.test(DxvkFormatFlag::MultiPlane)) {
auto plane = &formatInfo->planes[vk::getPlaneIndex(aspect)];
planeExtent.width /= plane->blockSize.width;
planeExtent.height /= plane->blockSize.height;
elementSize = plane->elementSize;
}
size += elementSize * flattenImageExtent(computeBlockCount(planeExtent, formatInfo->blockSize));
}
return size;
}