rhi: Add a feature flag for non-fill polygon modes

It's one thing that this is not part of OpenGL ES, but it is optional
even with Vulkan, with some mobile GPUs not offering the feature at all.

Change-Id: I4e2c6642eccb0793e69074b4b6eeb2b7cef3516e
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
bb10
Laszlo Agocs 2022-04-21 12:43:39 +02:00
parent 7fa2a1a479
commit 4f2b4e0e5e
8 changed files with 25 additions and 3 deletions

View File

@ -744,6 +744,12 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
it does not map well to all graphics APIs, and it is only meant to provide
support for special cases anyhow. In practice the feature can be expected to
be supported with Direct3D 11 and Vulkan.
\value NonFillPolygonMode Indicates that setting a PolygonMode other than
the default Fill is supported for QRhiGraphicsPipeline. A common use case
for changing the mode to Line is to get wireframe rendering. This however
is not available as a core OpenGL ES feature, and is optional with Vulkan
as well as some mobile GPUs may not offer the feature.
*/
/*!
@ -4324,7 +4330,10 @@ QDebug operator<<(QDebug dbg, const QRhiShaderResourceBindings &srb)
the fill mode used when rasterizing polygons. Polygons may be drawn as
solids (Fill), or as a wire mesh (Line).
\note OpenGL ES does not support Polygon Mode
Support for non-fill polygon modes is optional and is indicated by the
QRhi::NonFillPolygonMode feature. With OpenGL ES and some Vulkan
implementations the feature will likely be reported as unspported, which
then means values other than Fill cannot be used.
\value Fill The interior of the polygon is filled (default)
\value Line Boundary edges of the polygon are drawn as line segments.

View File

@ -1697,7 +1697,8 @@ public:
TextureArrays,
Tessellation,
GeometryShader,
TextureArrayRange
TextureArrayRange,
NonFillPolygonMode
};
enum BeginFrameFlag {

View File

@ -576,6 +576,8 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
return false;
case QRhi::TextureArrayRange:
return true;
case QRhi::NonFillPolygonMode:
return true;
default:
Q_UNREACHABLE();
return false;

View File

@ -1281,6 +1281,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return caps.geometryShader;
case QRhi::TextureArrayRange:
return false;
case QRhi::NonFillPolygonMode:
return !caps.gles;
default:
Q_UNREACHABLE();
return false;

View File

@ -635,6 +635,8 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
return false;
case QRhi::TextureArrayRange:
return false;
case QRhi::NonFillPolygonMode:
return true;
default:
Q_UNREACHABLE();
return false;

View File

@ -702,6 +702,8 @@ bool QRhiVulkan::create(QRhi::Flags flags)
caps.tessellation = physDevFeatures.tessellationShader;
caps.geometryShader = physDevFeatures.geometryShader;
caps.nonFillPolygonMode = physDevFeatures.fillModeNonSolid;
if (!importedAllocator) {
VmaVulkanFunctions afuncs;
afuncs.vkGetPhysicalDeviceProperties = wrap_vkGetPhysicalDeviceProperties;
@ -4330,6 +4332,8 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
return caps.geometryShader;
case QRhi::TextureArrayRange:
return true;
case QRhi::NonFillPolygonMode:
return caps.nonFillPolygonMode;
default:
Q_UNREACHABLE();
return false;

View File

@ -892,6 +892,7 @@ public:
bool tessellation = false;
bool vulkan11OrHigher = false;
bool geometryShader = false;
bool nonFillPolygonMode = false;
} caps;
VkPipelineCache pipelineCache = VK_NULL_HANDLE;

View File

@ -407,7 +407,8 @@ void tst_QRhi::create()
QRhi::TextureArrays,
QRhi::Tessellation,
QRhi::GeometryShader,
QRhi::TextureArrayRange
QRhi::TextureArrayRange,
QRhi::NonFillPolygonMode
};
for (size_t i = 0; i <sizeof(features) / sizeof(QRhi::Feature); ++i)
rhi->isFeatureSupported(features[i]);