Add TriangleFan pipeline topology

Triangle fan drawing is only supported on some platforms. The feature
flag QRhi::TriangleFanTopology is set accordingly.

In general, TriangleStrip topology will be more efficient on most GPUs.
However, if polygon data is already stored as triangle fans, the CPU
savings may be more significant.

Change-Id: I9704fad751d2119eac8791074f58942dd9315601
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Paul Olav Tvete 2019-10-01 15:19:37 +02:00
parent 5bc972a411
commit 2e068c7f2a
6 changed files with 20 additions and 2 deletions

View File

@ -563,7 +563,10 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
\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 TriangleFanTopology Indicates that QRhiGraphicsPipeline::setTopology()
supports QRhiGraphicsPipeline::TriangleFan.
*/
/*!
\enum QRhi::BeginFrameFlag
@ -3123,6 +3126,7 @@ QDebug operator<<(QDebug dbg, const QRhiShaderResourceBindings &srb)
\value Triangles (default)
\value TriangleStrip
\value TriangleFan (only available if QRhi::TriangleFanTopology is supported)
\value Lines
\value LineStrip
\value Points

View File

@ -1017,6 +1017,7 @@ public:
enum Topology {
Triangles,
TriangleStrip,
TriangleFan,
Lines,
LineStrip,
Points
@ -1426,7 +1427,8 @@ public:
WideLines,
VertexShaderPointSize,
BaseVertex,
BaseInstance
BaseInstance,
TriangleFanTopology
};
enum BeginFrameFlag {

View File

@ -469,6 +469,8 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::BaseInstance:
return true;
case QRhi::TriangleFanTopology:
return false;
default:
Q_UNREACHABLE();
return false;

View File

@ -732,6 +732,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return caps.baseVertex;
case QRhi::BaseInstance:
return false; // not in ES 3.2, so won't bother
case QRhi::TriangleFanTopology:
return true;
default:
Q_UNREACHABLE();
return false;
@ -1539,6 +1541,8 @@ static inline GLenum toGlTopology(QRhiGraphicsPipeline::Topology t)
return GL_TRIANGLES;
case QRhiGraphicsPipeline::TriangleStrip:
return GL_TRIANGLE_STRIP;
case QRhiGraphicsPipeline::TriangleFan:
return GL_TRIANGLE_FAN;
case QRhiGraphicsPipeline::Lines:
return GL_LINES;
case QRhiGraphicsPipeline::LineStrip:

View File

@ -550,6 +550,8 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::BaseInstance:
return true;
case QRhi::TriangleFanTopology:
return false;
default:
Q_UNREACHABLE();
return false;

View File

@ -3727,6 +3727,8 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::BaseInstance:
return true;
case QRhi::TriangleFanTopology:
return true;
default:
Q_UNREACHABLE();
return false;
@ -4572,6 +4574,8 @@ static inline VkPrimitiveTopology toVkTopology(QRhiGraphicsPipeline::Topology t)
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
case QRhiGraphicsPipeline::TriangleStrip:
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
case QRhiGraphicsPipeline::TriangleFan:
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN;
case QRhiGraphicsPipeline::Lines:
return VK_PRIMITIVE_TOPOLOGY_LINE_LIST;
case QRhiGraphicsPipeline::LineStrip: