MVKImage::getArrayLayers() reports only layer count and excludes depth.

This commit is contained in:
Bill Hollings 2018-04-09 16:22:43 -04:00
parent c08e22e097
commit 796cf7e417
2 changed files with 3 additions and 7 deletions

View File

@ -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; }

View File

@ -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);