summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2019-11-29 12:41:38 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2019-12-05 10:04:46 +0100
commit913146ccd401216f71f037ea304b5e61b7a138cf (patch)
tree333ea1a5d39d8bab456de2df78a40fbc90c80e5f /tests/auto
parentf43cb31ba00a431c6d0a0b17750483a72ae03bb0 (diff)
RHI: new native texture API
The new version takes/returns a value that can be unpacked and passed to other functions without knowing which backend is in use. The old API will be removed in a later change when dependent modules have been updated Task-number: QTBUG-78570 Change-Id: I18d928ceef3cb617c0c509ecccb345551a7990af Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 302630ae15..6f88b7fab5 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -73,6 +73,8 @@ private slots:
void create();
void nativeHandles_data();
void nativeHandles();
+ void nativeTexture_data();
+ void nativeTexture();
void resourceUpdateBatchBuffer_data();
void resourceUpdateBatchBuffer();
void resourceUpdateBatchRGBATextureUpload_data();
@@ -528,6 +530,71 @@ void tst_QRhi::nativeHandles()
}
}
+void tst_QRhi::nativeTexture_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::nativeTexture()
+{
+ 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 native texture");
+
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 256)));
+ QVERIFY(tex->build());
+
+ const QRhiTexture::NativeTexture nativeTex = tex->nativeTexture();
+
+ switch (impl) {
+ case QRhi::Null:
+ break;
+#ifdef TST_VK
+ case QRhi::Vulkan:
+ {
+ auto *image = static_cast<const VkImage *>(nativeTex.object);
+ QVERIFY(image);
+ QVERIFY(*image);
+ QVERIFY(nativeTex.layout >= 1); // VK_IMAGE_LAYOUT_GENERAL
+ QVERIFY(nativeTex.layout <= 8); // VK_IMAGE_LAYOUT_PREINITIALIZED
+ }
+ break;
+#endif
+#ifdef TST_GL
+ case QRhi::OpenGLES2:
+ {
+ auto *textureId = static_cast<const uint *>(nativeTex.object);
+ QVERIFY(textureId);
+ QVERIFY(*textureId);
+ }
+ break;
+#endif
+#ifdef TST_D3D11
+ case QRhi::D3D11:
+ {
+ auto *texture = static_cast<void * const *>(nativeTex.object);
+ QVERIFY(texture);
+ QVERIFY(*texture);
+ }
+ break;
+#endif
+#ifdef TST_MTL
+ case QRhi::Metal:
+ {
+ void * const * texture = (void * const *)nativeTex.object;
+ QVERIFY(texture);
+ QVERIFY(*texture);
+ }
+ break;
+#endif
+ default:
+ Q_ASSERT(false);
+ }
+}
+
static bool submitResourceUpdates(QRhi *rhi, QRhiResourceUpdateBatch *batch)
{
QRhiCommandBuffer *cb = nullptr;