diff options
Diffstat (limited to 'src/gui/rhi/qrhivulkan.cpp')
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index f0b51146cc..36bbd989cf 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1072,6 +1072,8 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture return VK_FORMAT_D24_UNORM_S8_UINT; case QRhiTexture::D32F: return VK_FORMAT_D32_SFLOAT; + case QRhiTexture::D32FS8: + return VK_FORMAT_D32_SFLOAT_S8_UINT; case QRhiTexture::BC1: return srgb ? VK_FORMAT_BC1_RGB_SRGB_BLOCK : VK_FORMAT_BC1_RGB_UNORM_BLOCK; @@ -1164,6 +1166,7 @@ static constexpr inline bool isDepthTextureFormat(QRhiTexture::Format format) case QRhiTexture::Format::D24: case QRhiTexture::Format::D24S8: case QRhiTexture::Format::D32F: + case QRhiTexture::Format::D32FS8: return true; default: @@ -1598,8 +1601,8 @@ struct RenderPass2SetupHelper #endif // VK_KHR_create_renderpass2 bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, - const QRhiColorAttachment *firstColorAttachment, - const QRhiColorAttachment *lastColorAttachment, + const QRhiColorAttachment *colorAttachmentsBegin, + const QRhiColorAttachment *colorAttachmentsEnd, bool preserveColor, bool preserveDs, bool storeDs, @@ -1610,7 +1613,7 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, // attachment list layout is color (0-8), ds (0-1), resolve (0-8), ds resolve (0-1) int multiViewCount = 0; - for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { + for (auto it = colorAttachmentsBegin; it != colorAttachmentsEnd; ++it) { QVkTexture *texD = QRHI_RES(QVkTexture, it->texture()); QVkRenderBuffer *rbD = QRHI_RES(QVkRenderBuffer, it->renderBuffer()); Q_ASSERT(texD || rbD); @@ -1662,10 +1665,14 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, attDesc.initialLayout = preserveDs ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; rpD->attDescs.append(attDesc); + if (depthTexture && depthTexture->arraySize() >= 2 && colorAttachmentsBegin == colorAttachmentsEnd) { + multiViewCount = depthTexture->arraySize(); + rpD->multiViewCount = multiViewCount; + } } rpD->dsRef = { uint32_t(rpD->attDescs.size() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; - for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { + for (auto it = colorAttachmentsBegin; it != colorAttachmentsEnd; ++it) { if (it->resolveTexture()) { QVkTexture *rtexD = QRHI_RES(QVkTexture, it->resolveTexture()); const VkFormat dstFormat = rtexD->vkformat; @@ -3497,12 +3504,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(); |