From bdc3b44e7d4100f9ea0cd1e5e1cb6d4e3e71f3cf Mon Sep 17 00:00:00 2001 From: Gary Sweet Date: Fri, 7 Feb 2020 09:15:13 +0000 Subject: [PATCH] Clamp miplevel size to avoid zero width or height I was seeing a zero height in certain circumstances for textures in scenerendering. --- base/VulkanTexture.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/VulkanTexture.hpp b/base/VulkanTexture.hpp index c23c1fd2..69bd5df2 100644 --- a/base/VulkanTexture.hpp +++ b/base/VulkanTexture.hpp @@ -182,8 +182,8 @@ namespace vks bufferCopyRegion.imageSubresource.mipLevel = i; bufferCopyRegion.imageSubresource.baseArrayLayer = 0; bufferCopyRegion.imageSubresource.layerCount = 1; - bufferCopyRegion.imageExtent.width = ktxTexture->baseWidth >> i; - bufferCopyRegion.imageExtent.height = ktxTexture->baseHeight >> i; + bufferCopyRegion.imageExtent.width = std::max(1u, ktxTexture->baseWidth >> i); + bufferCopyRegion.imageExtent.height = std::max(1u, ktxTexture->baseHeight >> i); bufferCopyRegion.imageExtent.depth = 1; bufferCopyRegion.bufferOffset = offset;