summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhimetal.mm
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-02-20 11:03:16 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-02-21 09:15:18 +0100
commit2940c375e40687f5758d173adceaee212239e2ca (patch)
tree3f75011b37d9d0e205e4d11d6a85dc38fa9b8f51 /src/gui/rhi/qrhimetal.mm
parent79b605d285d006ff7434fc813effa3479138b952 (diff)
rhi: Allow querying the native buffer objects behind a QRhiBuffer
Modeled after QRhiTexture's NativeTexture query. This becomes valuable in advanced cases of integrating external native rendering code with Qt Quick(3D), because it allows using (typically vertex and index) buffers created by Quick(3D) in the custom renderer as well, without having to duplicate the content by manually creating native buffers with the same vertex and index data. Change-Id: I659193345fa1dfe6221b898043f0b75ba649d296 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r--src/gui/rhi/qrhimetal.mm13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index b0813bfc77..48a562ef1d 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -2200,6 +2200,19 @@ bool QMetalBuffer::build()
return true;
}
+QRhiBuffer::NativeBuffer QMetalBuffer::nativeBuffer()
+{
+ if (d->slotted) {
+ NativeBuffer b;
+ Q_ASSERT(sizeof(b.objects) / sizeof(b.objects[0]) >= size_t(QMTL_FRAMES_IN_FLIGHT));
+ for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i)
+ b.objects[i] = &d->buf[i];
+ b.slotCount = QMTL_FRAMES_IN_FLIGHT;
+ return b;
+ }
+ return { { &d->buf[0] }, 1 };
+}
+
QMetalRenderBuffer::QMetalRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
int sampleCount, QRhiRenderBuffer::Flags flags)
: QRhiRenderBuffer(rhi, type, pixelSize, sampleCount, flags),