summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhimetal.mm
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-05-13 07:32:19 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-05-22 10:32:10 +0200
commit3ec0df4b5f9bf82918e0b783f547d2bc560f5ccf (patch)
treebd96d60c2723b5400c56dd1f6e5ca7e027d5de97 /src/gui/rhi/qrhimetal.mm
parent547d5e1f55102093a9906e4b0c347c7efa073eac (diff)
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 <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r--src/gui/rhi/qrhimetal.mm8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index c5afdf63eb..5d94b481a6 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -2592,14 +2592,14 @@ bool QMetalTexture::build()
bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src)
{
- void * const * tex = (void * const *) src.object;
- if (!tex || !*tex)
+ id<MTLTexture> tex = id<MTLTexture>(src.object);
+ if (tex == 0)
return false;
if (!prepareBuild())
return false;
- d->tex = (id<MTLTexture>) *tex;
+ d->tex = tex;
d->owns = false;
@@ -2615,7 +2615,7 @@ bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src)
QRhiTexture::NativeTexture QMetalTexture::nativeTexture()
{
- return {&d->tex, 0};
+ return {quint64(d->tex), 0};
}
id<MTLTexture> QMetalTextureData::viewForLevel(int level)