From 3ec0df4b5f9bf82918e0b783f547d2bc560f5ccf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 13 May 2020 07:32:19 +0200 Subject: RHI: Store texture handle as 64-bit int When storing a void* pointer to the texture handle, we had to ensure that the variable would exist until the build phase, which is error prone and caused errors in QQuickWidget because we copied the texture ID from the FBO into a local variable before passing it into QQuickWindow::setRenderTarget(). The reason for using a void* was that we cannot know the width of the handles in the different backends, but we do know that they are 64-bit at maximum, so instead of storing potentially dangling pointers, we just make it a 64-bit integer and cast it back and forth in the backends. Task-number: QTBUG-78638 Change-Id: I7951e24351ddb209045ab6197d81eb1290b4da67 Reviewed-by: Laszlo Agocs --- tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp index d3524a39b7..41057a15ab 100644 --- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp +++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp @@ -519,9 +519,8 @@ void tst_QRhi::nativeTexture() #ifdef TST_VK case QRhi::Vulkan: { - auto *image = static_cast(nativeTex.object); + auto image = VkImage(nativeTex.object); QVERIFY(image); - QVERIFY(*image); QVERIFY(nativeTex.layout >= 1); // VK_IMAGE_LAYOUT_GENERAL QVERIFY(nativeTex.layout <= 8); // VK_IMAGE_LAYOUT_PREINITIALIZED } @@ -530,27 +529,24 @@ void tst_QRhi::nativeTexture() #ifdef TST_GL case QRhi::OpenGLES2: { - auto *textureId = static_cast(nativeTex.object); + auto textureId = uint(nativeTex.object); QVERIFY(textureId); - QVERIFY(*textureId); } break; #endif #ifdef TST_D3D11 case QRhi::D3D11: { - auto *texture = static_cast(nativeTex.object); + auto *texture = reinterpret_cast(nativeTex.object); QVERIFY(texture); - QVERIFY(*texture); } break; #endif #ifdef TST_MTL case QRhi::Metal: { - void * const * texture = (void * const *)nativeTex.object; + auto texture = (void *)nativeTex.object; QVERIFY(texture); - QVERIFY(*texture); } break; #endif -- cgit v1.2.3