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

gl: Enable primitive restart whenever possible

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