From 6ec0fd66324c076b4401351d4a018c6f90022ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Brooke?= Date: Wed, 12 Feb 2025 08:47:24 +0100 Subject: [PATCH] rhi: vulkan: avoid allocations/deallocations in every beginPass() call It is not uncommon to have more than 4 total clear values because of all the color, depth, resolve and shading rate attachments. Set the stack prealloc of the temporary QVarLengthArray to its maximum possible size to avoid any heap (de)allocation in this hot path. For 10 render passes per frame, it saves 600 allocs/deallocs per second. Change-Id: If44fd075d1c1f9c07809ddc9922c690e9dc3ac3d Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhivulkan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index ec82aecdfa4..ce3efa50ba7 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -3235,7 +3235,7 @@ void QRhiVulkan::beginPass(QRhiCommandBuffer *cb, rpBeginInfo.renderArea.extent.width = uint32_t(rtD->pixelSize.width()); rpBeginInfo.renderArea.extent.height = uint32_t(rtD->pixelSize.height()); - QVarLengthArray cvs; + QVarLengthArray cvs; for (int i = 0; i < rtD->colorAttCount; ++i) { VkClearValue cv; cv.color = { { float(colorClearValue.redF()), float(colorClearValue.greenF()), float(colorClearValue.blueF()),