summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhimetal.mm
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-12-09 01:00:35 +0100
committerLars Knoll <lars.knoll@qt.io>2019-12-09 10:16:01 +0100
commitbef74b6c3a0a9c8649ea8eb333d80015f76863e4 (patch)
tree41cdf5b6776c90a6d04a1d6680f4d47a90593746 /src/gui/rhi/qrhimetal.mm
parentf8d2975b6a8b36bf8dd304c99783947a72081b79 (diff)
parent4c3c63d4cbb81b38e88e06b72749e7e01497b6f1 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r--src/gui/rhi/qrhimetal.mm29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index e5af1cfab1..555ed5e79f 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -2499,11 +2499,40 @@ bool QMetalTexture::buildFrom(const QRhiNativeHandles *src)
return true;
}
+bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src)
+{
+ void * const * tex = (void * const *) src.object;
+ if (!tex || !*tex)
+ return false;
+
+ if (!prepareBuild())
+ return false;
+
+ d->tex = (id<MTLTexture>) *tex;
+
+ d->owns = false;
+ nativeHandlesStruct.texture = d->tex;
+
+ QRHI_PROF;
+ QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples));
+
+ lastActiveFrameSlot = -1;
+ generation += 1;
+ QRHI_RES_RHI(QRhiMetal);
+ rhiD->registerResource(this);
+ return true;
+}
+
const QRhiNativeHandles *QMetalTexture::nativeHandles()
{
return &nativeHandlesStruct;
}
+QRhiTexture::NativeTexture QMetalTexture::nativeTexture()
+{
+ return {&nativeHandlesStruct.texture, 0};
+}
+
id<MTLTexture> QMetalTextureData::viewForLevel(int level)
{
Q_ASSERT(level >= 0 && level < int(q->mipLevelCount));