Commit 3c7ad5c6 authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

vk: Fix mipmap generation for npot textures

parent dfff3935
...@@ -4088,7 +4088,7 @@ int QRhi::ubufAligned(int v) const ...@@ -4088,7 +4088,7 @@ int QRhi::ubufAligned(int v) const
*/ */
int QRhi::mipLevelsForSize(const QSize &size) const int QRhi::mipLevelsForSize(const QSize &size) const
{ {
return qCeil(std::log2(qMax(size.width(), size.height()))) + 1; return qFloor(std::log2(qMax(size.width(), size.height()))) + 1;
} }
/*! /*!
...@@ -4097,8 +4097,8 @@ int QRhi::mipLevelsForSize(const QSize &size) const ...@@ -4097,8 +4097,8 @@ int QRhi::mipLevelsForSize(const QSize &size) const
*/ */
QSize QRhi::sizeForMipLevel(int mipLevel, const QSize &baseLevelSize) const QSize QRhi::sizeForMipLevel(int mipLevel, const QSize &baseLevelSize) const
{ {
const int w = qFloor(float(qMax(1, baseLevelSize.width() >> mipLevel))); const int w = qMax(1, baseLevelSize.width() >> mipLevel);
const int h = qFloor(float(qMax(1, baseLevelSize.height() >> mipLevel))); const int h = qMax(1, baseLevelSize.height() >> mipLevel);
return QSize(w, h); return QSize(w, h);
} }
......
...@@ -2636,8 +2636,8 @@ void QRhiVulkan::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdat ...@@ -2636,8 +2636,8 @@ void QRhiVulkan::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdat
region.srcSubresource.baseArrayLayer = 0; region.srcSubresource.baseArrayLayer = 0;
region.srcSubresource.layerCount = layerCount; region.srcSubresource.layerCount = layerCount;
region.srcOffsets[1].x = w; region.srcOffsets[1].x = qMax(1, w);
region.srcOffsets[1].y = h; region.srcOffsets[1].y = qMax(1, h);
region.srcOffsets[1].z = 1; region.srcOffsets[1].z = 1;
region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
...@@ -2645,8 +2645,8 @@ void QRhiVulkan::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdat ...@@ -2645,8 +2645,8 @@ void QRhiVulkan::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdat
region.dstSubresource.baseArrayLayer = 0; region.dstSubresource.baseArrayLayer = 0;
region.dstSubresource.layerCount = layerCount; region.dstSubresource.layerCount = layerCount;
region.dstOffsets[1].x = w >> 1; region.dstOffsets[1].x = qMax(1, w >> 1);
region.dstOffsets[1].y = h >> 1; region.dstOffsets[1].y = qMax(1, h >> 1);
region.dstOffsets[1].z = 1; region.dstOffsets[1].z = 1;
df->vkCmdBlitImage(cbD->cb, df->vkCmdBlitImage(cbD->cb,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment