Commit 3e20433e authored by Laszlo Agocs's avatar Laszlo Agocs

gl: Enable primitive restart whenever possible

parent e521639b
...@@ -372,10 +372,11 @@ QT_BEGIN_NAMESPACE ...@@ -372,10 +372,11 @@ QT_BEGIN_NAMESPACE
\value PrimitiveRestart Indicates that restarting the assembly of \value PrimitiveRestart Indicates that restarting the assembly of
primitives when encountering an index value of 0xFFFF primitives when encountering an index value of 0xFFFF
(\l{QRhiCommandBuffer::IndexUInt16}{IndexUInt16}) or 0xFFFFFFFF (\l{QRhiCommandBuffer::IndexUInt16}{IndexUInt16}) or 0xFFFFFFFF
(\l{QRhiCommandBuffer::IndexUInt32}{IndexUInt32}) is always enabled, for (\l{QRhiCommandBuffer::IndexUInt32}{IndexUInt32}) is enabled, for certain
certain primitive topologies at least. Due to the wildly varying primitive primitive topologies at least. QRhi will try to enable this with all
restart behavior and support in the underlying graphics APIs, primitive backends, but in some cases it will not be supported. Dynamically
restart cannot be controlled with QRhi. Instead, applications must assume controlling primitive restart is not possible since with some APIs
primitive restart with a fixed index is always on. Applications must assume
that whenever this feature is reported as supported, the above mentioned that whenever this feature is reported as supported, the above mentioned
index values \c may be treated specially, depending on the topology. The index values \c may be treated specially, depending on the topology. The
only two topologies where primitive restart is guaranteed to behave only two topologies where primitive restart is guaranteed to behave
......
...@@ -157,6 +157,10 @@ QT_BEGIN_NAMESPACE ...@@ -157,6 +157,10 @@ QT_BEGIN_NAMESPACE
\brief Holds the OpenGL texture object that is backing a QRhiTexture instance. \brief Holds the OpenGL texture object that is backing a QRhiTexture instance.
*/ */
#ifndef GL_PRIMITIVE_RESTART_FIXED_INDEX
#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
#endif
static QSurfaceFormat qrhigles2_effectiveFormat() static QSurfaceFormat qrhigles2_effectiveFormat()
{ {
QSurfaceFormat fmt = QSurfaceFormat::defaultFormat(); QSurfaceFormat fmt = QSurfaceFormat::defaultFormat();
...@@ -292,6 +296,15 @@ bool QRhiGles2::create(QRhi::Flags flags) ...@@ -292,6 +296,15 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.npotTexture = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures); caps.npotTexture = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
caps.npotTextureRepeat = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); caps.npotTextureRepeat = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
const QSurfaceFormat actualFormat = ctx->format();
if (ctx->isOpenGLES())
caps.fixedIndexPrimitiveRestart = actualFormat.version() >= qMakePair(3, 0);
else
caps.fixedIndexPrimitiveRestart = actualFormat.version() >= qMakePair(4, 3);
if (caps.fixedIndexPrimitiveRestart)
f->glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize); f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize);
nativeHandlesStruct.context = ctx; nativeHandlesStruct.context = ctx;
...@@ -511,7 +524,7 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const ...@@ -511,7 +524,7 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
case QRhi::CustomInstanceStepRate: case QRhi::CustomInstanceStepRate:
return false; return false;
case QRhi::PrimitiveRestart: case QRhi::PrimitiveRestart:
return false; // say no to madness return caps.fixedIndexPrimitiveRestart;
case QRhi::GeometryShaders: case QRhi::GeometryShaders:
return false; return false;
case QRhi::TessellationShaders: case QRhi::TessellationShaders:
......
...@@ -563,6 +563,7 @@ public: ...@@ -563,6 +563,7 @@ public:
bool msaaRenderBuffer = false; bool msaaRenderBuffer = false;
bool npotTexture = true; bool npotTexture = true;
bool npotTextureRepeat = true; bool npotTextureRepeat = true;
bool fixedIndexPrimitiveRestart = false;
int maxTextureSize = 2048; int maxTextureSize = 2048;
} caps; } caps;
bool inFrame = false; bool inFrame = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment