diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-06-10 12:08:54 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-07-05 13:04:09 +0200 |
commit | 6ec339c4844125ba2f1330d07c520437ae73ec0b (patch) | |
tree | 0a451d7557303a2bd93f4d401e06decd1f2b7e4c /tests | |
parent | a09e518f6589fff7789ad7224badf24593240711 (diff) |
rhi: Keep track of pipeline creation times
Make our QRhiMemAllocStats struct a bit more generic, drop the memory
allocation part in the naming, and use the same getter and struct for
reporting some important timings. (we are free to rename for now, there
are no users in other modules yet)
The time spent in graphics (or compute) pipeline creation has a special
relevance in particular with the modern APIs (as it is the single
biggest potentially time consuming blocking operation), but also highly
interesting with others like D3D11 simply because that's where we do the
expensive source-to-intermediate compilation is HLSL source is provided.
In order to see the effects of the various caching mechanisms (of which
there can be confusingly many, on multiple levels), the ability to see
how much time we spent on pipeline creation e.g. until we render the
first view of an application can be pretty essential.
Task-number: QTBUG-103802
Change-Id: I85dd056a39db7e6b25fb1f9d02e4c94298d22b41
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp index 799cc0743d..1c15c81eb8 100644 --- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp +++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp @@ -52,6 +52,8 @@ private slots: void rhiTestDataOpenGL(); void create_data(); void create(); + void stats_data(); + void stats(); void nativeHandles_data(); void nativeHandles(); void nativeHandlesImportVulkan(); @@ -400,6 +402,38 @@ void tst_QRhi::create() } } +void tst_QRhi::stats_data() +{ + rhiTestData(); +} + +void tst_QRhi::stats() +{ + QFETCH(QRhi::Implementation, impl); + QFETCH(QRhiInitParams *, initParams); + + QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr)); + if (!rhi) + QSKIP("QRhi could not be created, skipping testing statistics getter"); + + QRhiStats stats = rhi->statistics(); + qDebug() << stats; + QCOMPARE(stats.totalPipelineCreationTime, 0); + + if (impl == QRhi::Vulkan) { + QScopedPointer<QRhiBuffer> buf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, 32768)); + QVERIFY(buf->create()); + QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(1024, 1024))); + QVERIFY(tex->create()); + + stats = rhi->statistics(); + qDebug() << stats; + QVERIFY(stats.allocCount > 0); + QVERIFY(stats.blockCount > 0); + QVERIFY(stats.usedBytes > 0); + } +} + void tst_QRhi::nativeHandles_data() { rhiTestData(); |