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 --- src/gui/rhi/qrhid3d11.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui/rhi/qrhid3d11.cpp') diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 2f7974944c..97294669f7 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2937,14 +2937,14 @@ bool QD3D11Texture::build() bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) { - auto *srcTex = static_cast(src.object); - if (!srcTex || !*srcTex) + ID3D11Texture2D *srcTex = reinterpret_cast(src.object); + if (srcTex == nullptr) return false; if (!prepareBuild()) return false; - tex = *srcTex; + tex = srcTex; if (!finishBuild()) return false; @@ -2960,7 +2960,7 @@ bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) QRhiTexture::NativeTexture QD3D11Texture::nativeTexture() { - return {&tex, 0}; + return {quint64(tex), 0}; } ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) -- cgit v1.2.3