diff options
-rw-r--r-- | src/gui/rhi/qrhi.cpp | 13 | ||||
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 34 | ||||
-rw-r--r-- | src/gui/rhi/qrhimetal_p_p.h | 1 |
3 files changed, 34 insertions, 14 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 88fb19e5f3..bcc1684f5e 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -574,13 +574,18 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general") require the point size to be set in the shader explicitly whenever drawing points, even when the size is 1, as they do not automatically default to 1. - \value BaseVertex Indicates that \l{QRhiCommandBuffer::drawIndexed()}{drawIndexed()} - supports the \c vertexOffset argument. When reported as not supported, the - vertexOffset value in an indexed draw is ignored. + \value BaseVertex Indicates that + \l{QRhiCommandBuffer::drawIndexed()}{drawIndexed()} supports the \c + vertexOffset argument. When reported as not supported, the vertexOffset + value in an indexed draw is ignored. In practice this feature will be + unsupported with OpenGL and OpenGL ES versions lower than 3.2, and with + Metal on older iOS devices, including the iOS Simulator. \value BaseInstance Indicates that instanced draw commands support the \c firstInstance argument. When reported as not supported, the firstInstance - value is ignored and the instance ID starts from 0. + value is ignored and the instance ID starts from 0. In practice this feature + will be unsupported with OpenGL, and with Metal on older iOS devices, + including the iOS Simulator. \value TriangleFanTopology Indicates that QRhiGraphicsPipeline::setTopology() supports QRhiGraphicsPipeline::TriangleFan. diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 3da25b7ac4..c817d8bae3 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -414,11 +414,13 @@ bool QRhiMetal::create(QRhi::Flags flags) #if defined(Q_OS_MACOS) caps.maxTextureSize = 16384; + caps.baseVertexAndInstance = true; #elif defined(Q_OS_TVOS) if ([d->dev supportsFeatureSet: MTLFeatureSet(30003)]) // MTLFeatureSet_tvOS_GPUFamily2_v1 caps.maxTextureSize = 16384; else caps.maxTextureSize = 8192; + caps.baseVertexAndInstance = false; #elif defined(Q_OS_IOS) // welcome to feature set hell if ([d->dev supportsFeatureSet: MTLFeatureSet(16)] // MTLFeatureSet_iOS_GPUFamily5_v1 @@ -426,12 +428,15 @@ bool QRhiMetal::create(QRhi::Flags flags) || [d->dev supportsFeatureSet: MTLFeatureSet(4)]) // MTLFeatureSet_iOS_GPUFamily3_v1 { caps.maxTextureSize = 16384; + caps.baseVertexAndInstance = true; } else if ([d->dev supportsFeatureSet: MTLFeatureSet(3)] // MTLFeatureSet_iOS_GPUFamily2_v2 || [d->dev supportsFeatureSet: MTLFeatureSet(2)]) // MTLFeatureSet_iOS_GPUFamily1_v2 { caps.maxTextureSize = 8192; + caps.baseVertexAndInstance = false; } else { caps.maxTextureSize = 4096; + caps.baseVertexAndInstance = false; } #endif @@ -573,9 +578,9 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const case QRhi::VertexShaderPointSize: return true; case QRhi::BaseVertex: - return true; + return caps.baseVertexAndInstance; case QRhi::BaseInstance: - return true; + return caps.baseVertexAndInstance; case QRhi::TriangleFanTopology: return false; case QRhi::ReadBackNonUniformBuffer: @@ -1333,14 +1338,23 @@ void QRhiMetal::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, QMetalBuffer *ibufD = QRHI_RES(QMetalBuffer, cbD->currentIndexBuffer); id<MTLBuffer> mtlbuf = ibufD->d->buf[ibufD->d->slotted ? currentFrameSlot : 0]; - [cbD->d->currentRenderPassEncoder drawIndexedPrimitives: QRHI_RES(QMetalGraphicsPipeline, cbD->currentGraphicsPipeline)->d->primitiveType - indexCount: indexCount - indexType: cbD->currentIndexFormat == QRhiCommandBuffer::IndexUInt16 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 - indexBuffer: mtlbuf - indexBufferOffset: indexOffset - instanceCount: instanceCount - baseVertex: vertexOffset - baseInstance: firstInstance]; + if (caps.baseVertexAndInstance) { + [cbD->d->currentRenderPassEncoder drawIndexedPrimitives: QRHI_RES(QMetalGraphicsPipeline, cbD->currentGraphicsPipeline)->d->primitiveType + indexCount: indexCount + indexType: cbD->currentIndexFormat == QRhiCommandBuffer::IndexUInt16 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 + indexBuffer: mtlbuf + indexBufferOffset: indexOffset + instanceCount: instanceCount + baseVertex: vertexOffset + baseInstance: firstInstance]; + } else { + [cbD->d->currentRenderPassEncoder drawIndexedPrimitives: QRHI_RES(QMetalGraphicsPipeline, cbD->currentGraphicsPipeline)->d->primitiveType + indexCount: indexCount + indexType: cbD->currentIndexFormat == QRhiCommandBuffer::IndexUInt16 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 + indexBuffer: mtlbuf + indexBufferOffset: indexOffset + instanceCount: instanceCount]; + } } void QRhiMetal::debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 3a22b76b22..eed9afc9f1 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -476,6 +476,7 @@ public: struct { int maxTextureSize = 4096; + bool baseVertexAndInstance = true; } caps; QRhiMetalData *d = nullptr; |