From 796cf7e417489362afbcbf9a4ea879f565a91581 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Mon, 9 Apr 2018 16:22:43 -0400 Subject: [PATCH] MVKImage::getArrayLayers() reports only layer count and excludes depth. --- MoltenVK/MoltenVK/GPUObjects/MVKImage.h | 4 +--- MoltenVK/MoltenVK/GPUObjects/MVKImage.mm | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.h b/MoltenVK/MoltenVK/GPUObjects/MVKImage.h index 93fd9f26..9480a47f 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.h @@ -72,10 +72,8 @@ public: /** * Returns the number of layers at each mipmap level. For an array image type, this is * the number of elements in the array. For cube image type, this is a multiple of 6. - * For a 3D image type, this is the depth of the image. Formally, this value is calculated - * as the multiple of depth and array size. */ - inline uint32_t getLayerCount() { return _extent.depth * _arrayLayers; } + inline uint32_t getLayerCount() { return _arrayLayers; } /** Returns the number of samples for each pixel of this image. */ inline uint32_t getSampleCount() { return _samples; } diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm index ce10d1c6..b2fc2e35 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm @@ -454,9 +454,8 @@ MVKImage::MVKImage(MVKDevice* device, const VkImageCreateInfo* pCreateInfo) : MV _hasExpectedTexelSize = (mvkMTLPixelFormatBytesPerBlock(_mtlPixelFormat) == mvkVkFormatBytesPerBlock(pCreateInfo->format)); // Calc _byteCount after _mtlTexture & _byteAlignment - uint32_t layerCount = getLayerCount(); // Combines depth & arrays for (uint32_t mipLvl = 0; mipLvl < _mipLevels; mipLvl++) { - _byteCount += getBytesPerLayer(mipLvl) * layerCount; + _byteCount += getBytesPerLayer(mipLvl) * _extent.depth * _arrayLayers; } initSubresources(pCreateInfo); @@ -488,14 +487,13 @@ void MVKImage::initSubresourceLayout(MVKImageSubresource& imgSubRez) { uint32_t currArrayLayer = subresource.arrayLayer; VkDeviceSize bytesPerLayerCurrLevel = getBytesPerLayer(currMipLevel); - uint32_t layCnt = getLayerCount(); // Accumulate the byte offset for the specified sub-resource. // This is the sum of the bytes consumed by all layers in all mipmap levels before the // desired level, plus the layers before the desired layer at the desired level. VkDeviceSize offset = 0; for (uint32_t mipLvl = 0; mipLvl < currMipLevel; mipLvl++) { - offset += (getBytesPerLayer(mipLvl) * layCnt); + offset += (getBytesPerLayer(mipLvl) * _extent.depth * _arrayLayers); } offset += (bytesPerLayerCurrLevel * currArrayLayer);