summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-10-01 14:46:44 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-02 13:14:31 +0200
commit0b7aef08dcfc84390380a4b7a1a956d1e3193339 (patch)
tree1fc5ad9097a795873f445322582d44d5a9a514f4 /tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
parentb1101fce301e83fe5dcac3c735959378789a8d16 (diff)
rhi: vk: Alter command buffer strategy
Reports on the Web have it that there's nothing guaranteeing a driver does any actual freeing of resources then doing vkFreeCommandBuffer for a command buffer from a command pool that does not have VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, thus leading to continuously growing resource usage with our current allocate/free pattern. It could be that this is the source of out of memory problems we are seeing on some Android devices. Instead of just going straight for said command pool flag and doing ResetCommandBuffer for the command buffers individually, take one step further and use per-slot (slot being 0 or 1 if QVK_FRAMES_IN_FLIGHT is 2) command pools. The current pool is reset in each beginFrame/beginOffscreenFrame, moving all allocated command buffers to the initial state (while other command buffers with the other pool are not affected). This may be (while impossible to tell from just guessing based on the spec) our best approach to command buffer allocation since a Vulkan implementation can likely just use some simple per pool allocator, knowing that we never want to free or reset individual command buffers, but we rather only reset the whole pool at once. The option of importing an existing VkCommandPool when creating the QRhi instance is now gone, but there was probably no point in offering that in the first place. When it comes to VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT it will not be set unless releaseCachedResources() (in Qt Quick this is hooked into QQuickWindow::releaseResources()) was called. What this does in practice is unknown, but have an option to set it now and then if the application really wants. While we are at it, rename secondaryCbs to activeSecondaryCbStack to indicate what it really is. (it's a stack as each call to beginExternal() pushes a new one, while each endExternal() pops) Change-Id: I2e5c1fad26d794e1f56c778e38f750998d706d84 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/auto/gui/rhi/qrhi/tst_qrhi.cpp')
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp3
1 files changed, 0 insertions, 3 deletions
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 477b98cc4e..74a197808b 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -379,7 +379,6 @@ void tst_QRhi::nativeHandles()
QVERIFY(vkHandles->gfxQueueFamilyIdx >= 0);
QVERIFY(vkHandles->gfxQueueIdx >= 0);
QVERIFY(vkHandles->gfxQueue);
- QVERIFY(vkHandles->cmdPool);
QVERIFY(vkHandles->vmemAllocator);
}
break;
@@ -533,7 +532,6 @@ void tst_QRhi::nativeHandlesImportVulkan()
const QRhiVulkanNativeHandles *nativeHandles = static_cast<const QRhiVulkanNativeHandles *>(rhi->nativeHandles());
QRhiVulkanNativeHandles h = *nativeHandles;
// do not pass the rarely used fields, this is useful to test if it creates its own as expected
- h.cmdPool = VK_NULL_HANDLE;
h.vmemAllocator = nullptr;
QScopedPointer<QRhi> adoptingRhi(QRhi::create(QRhi::Vulkan, &initParams.vk, QRhi::Flags(), &h));
@@ -544,7 +542,6 @@ void tst_QRhi::nativeHandlesImportVulkan()
QCOMPARE(newNativeHandles->dev, nativeHandles->dev);
QCOMPARE(newNativeHandles->gfxQueueFamilyIdx, nativeHandles->gfxQueueFamilyIdx);
QCOMPARE(newNativeHandles->gfxQueueIdx, nativeHandles->gfxQueueIdx);
- QVERIFY(newNativeHandles->cmdPool != nativeHandles->cmdPool);
QVERIFY(newNativeHandles->vmemAllocator != nativeHandles->vmemAllocator);
}