summaryrefslogtreecommitdiff
path: root/src/gui/rhi/qrhimetal.mm
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 /src/gui/rhi/qrhimetal.mm
parentf43cb31ba00a431c6d0a0b17750483a72ae03bb0 (diff)
downloadqtbase-913146ccd401216f71f037ea304b5e61b7a138cf.tar.gz
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 '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));