Fixed incorrect mipmap generation on Vulkan for Cubemaps (#3236) (#3290)

This commit is contained in:
Nikolay Ivanov 2024-05-10 17:34:44 +03:00 committed by GitHub
parent 3a116a90e5
commit 2d17b9866b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6251,6 +6251,12 @@ VK_DESTROY
const VkImageLayout oldLayout = m_currentImageLayout; const VkImageLayout oldLayout = m_currentImageLayout;
const VkImageLayout oldSingleMsaaLayout = m_currentSingleMsaaImageLayout; const VkImageLayout oldSingleMsaaLayout = m_currentSingleMsaaImageLayout;
auto numLayers = _numLayers;
if(m_type == VK_IMAGE_VIEW_TYPE_CUBE || VK_IMAGE_VIEW_TYPE_CUBE_ARRAY)
{
numLayers = m_numSides;
}
if (needResolve) if (needResolve)
{ {
setImageMemoryBarrier(_commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); setImageMemoryBarrier(_commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
@ -6266,11 +6272,11 @@ VK_DESTROY
resolve.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; resolve.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
resolve.srcSubresource.mipLevel = _mip; resolve.srcSubresource.mipLevel = _mip;
resolve.srcSubresource.baseArrayLayer = _layer; resolve.srcSubresource.baseArrayLayer = _layer;
resolve.srcSubresource.layerCount = _numLayers; resolve.srcSubresource.layerCount = numLayers;
resolve.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; resolve.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
resolve.dstSubresource.mipLevel = _mip; resolve.dstSubresource.mipLevel = _mip;
resolve.dstSubresource.baseArrayLayer = _layer; resolve.dstSubresource.baseArrayLayer = _layer;
resolve.dstSubresource.layerCount = _numLayers; resolve.dstSubresource.layerCount = numLayers;
resolve.extent.width = m_width; resolve.extent.width = m_width;
resolve.extent.height = m_height; resolve.extent.height = m_height;
resolve.extent.depth = 1; resolve.extent.depth = 1;
@ -6304,13 +6310,13 @@ VK_DESTROY
blit.srcSubresource.aspectMask = m_aspectMask; blit.srcSubresource.aspectMask = m_aspectMask;
blit.srcSubresource.mipLevel = 0; blit.srcSubresource.mipLevel = 0;
blit.srcSubresource.baseArrayLayer = _layer; blit.srcSubresource.baseArrayLayer = _layer;
blit.srcSubresource.layerCount = _numLayers; blit.srcSubresource.layerCount = numLayers;
blit.dstOffsets[0] = { 0, 0, 0 }; blit.dstOffsets[0] = { 0, 0, 0 };
blit.dstOffsets[1] = { mipWidth, mipHeight, 1 }; blit.dstOffsets[1] = { mipWidth, mipHeight, 1 };
blit.dstSubresource.aspectMask = m_aspectMask; blit.dstSubresource.aspectMask = m_aspectMask;
blit.dstSubresource.mipLevel = 0; blit.dstSubresource.mipLevel = 0;
blit.dstSubresource.baseArrayLayer = _layer; blit.dstSubresource.baseArrayLayer = _layer;
blit.dstSubresource.layerCount = _numLayers; blit.dstSubresource.layerCount = numLayers;
for (uint32_t i = _mip + 1; i < m_numMips; i++) for (uint32_t i = _mip + 1; i < m_numMips; i++)
{ {
@ -6333,7 +6339,7 @@ VK_DESTROY
, blit.srcSubresource.mipLevel , blit.srcSubresource.mipLevel
, 1 , 1
, _layer , _layer
, _numLayers , numLayers
); );
vkCmdBlitImage( vkCmdBlitImage(
@ -6357,7 +6363,7 @@ VK_DESTROY
, _mip , _mip
, m_numMips - _mip - 1 , m_numMips - _mip - 1
, _layer , _layer
, _numLayers , numLayers
); );
} }