From 191459da4901a3deb95cd0a4c0026378755bc0ee Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 30 Apr 2024 11:57:08 +0200 Subject: [PATCH] rhi: vulkan: Reduce staging copy size for full-width texture uploads Pick-to: 6.6 6.5 Task-number: QTBUG-120565 Change-Id: I057f40ee410df35af87f27a0357252bc26234f04 Reviewed-by: Andy Nichols (cherry picked from commit aa12713c1fdb8dfb9034de6f8f162864cf868753) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhivulkan.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 987745c1274..c7d856def19 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -3225,12 +3225,12 @@ void QRhiVulkan::prepareUploadSubres(QVkTexture *texD, int layer, int level, const int sy = subresDesc.sourceTopLeft().y(); if (!subresDesc.sourceSize().isEmpty()) size = subresDesc.sourceSize(); - if (image.depth() == 32) { - // The staging buffer will get the full image - // regardless, just adjust the vk - // buffer-to-image copy start offset. - copyInfo.bufferOffset += VkDeviceSize(sy * image.bytesPerLine() + sx * 4); - // bufferRowLength remains set to the original image's width + + if (size.width() == image.width()) { + // No need to make a QImage copy here, can copy from the source + // QImage into staging directly. + src = image.constBits() + sy * image.bytesPerLine() + sx * bpc; + copySizeBytes = size.height() * image.bytesPerLine(); } else { image = image.copy(sx, sy, size.width(), size.height()); src = image.constBits();