Commit e521639b authored by Laszlo Agocs's avatar Laszlo Agocs

Expose NPOTTextureRepeat feature flag

To help dealing with ancient GLES 2.0 implementations.
parent ca24bfd6
......@@ -161,6 +161,11 @@ void Window::customInit()
qDebug("isFeatureSupported(Instancing): %d", m_r->isFeatureSupported(QRhi::Instancing));
qDebug("isFeatureSupported(CustomInstanceStepRate): %d", m_r->isFeatureSupported(QRhi::CustomInstanceStepRate));
qDebug("isFeatureSupported(PrimitiveRestart): %d", m_r->isFeatureSupported(QRhi::PrimitiveRestart));
qDebug("isFeatureSupported(GeometryShaders): %d", m_r->isFeatureSupported(QRhi::GeometryShaders));
qDebug("isFeatureSupported(TessellationShaders): %d", m_r->isFeatureSupported(QRhi::TessellationShaders));
qDebug("isFeatureSupported(NonDynamicUniformBuffers): %d", m_r->isFeatureSupported(QRhi::NonDynamicUniformBuffers));
qDebug("isFeatureSupported(NonFourAlignedEffectiveIndexBufferOffset): %d", m_r->isFeatureSupported(QRhi::NonFourAlignedEffectiveIndexBufferOffset));
qDebug("isFeatureSupported(NPOTTextureRepeat): %d", m_r->isFeatureSupported(QRhi::NPOTTextureRepeat));
qDebug("Min 2D texture width/height: %d", m_r->resourceSizeLimit(QRhi::TextureSizeMin));
qDebug("Max 2D texture width/height: %d", m_r->resourceSizeLimit(QRhi::TextureSizeMax));
}
......
......@@ -400,6 +400,9 @@ QT_BEGIN_NAMESPACE
that are not 4 byte aligned are supported. When not supported, attempting
to issue a \l{QRhiCommandBuffer::drawIndexed()}{drawIndexed()} with a
non-aligned effective offset may lead to unspecified behavior.
\value NPOTTextureRepeat Indicates that the \l{QRhiSampler::Repeat}{Repeat}
mode is supported for textures with a non-power-of-two size.
*/
/*!
......
......@@ -1247,7 +1247,8 @@ public:
GeometryShaders,
TessellationShaders,
NonDynamicUniformBuffers,
NonFourAlignedEffectiveIndexBufferOffset
NonFourAlignedEffectiveIndexBufferOffset,
NPOTTextureRepeat
};
enum BeginFrameFlag {
......
......@@ -399,6 +399,8 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
return false; // because UpdateSubresource cannot deal with this
case QRhi::NonFourAlignedEffectiveIndexBufferOffset:
return true;
case QRhi::NPOTTextureRepeat:
return true;
default:
Q_UNREACHABLE();
return false;
......
......@@ -289,6 +289,9 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.msaaRenderBuffer = f->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
&& f->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
caps.npotTexture = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
caps.npotTextureRepeat = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize);
nativeHandlesStruct.context = ctx;
......@@ -517,6 +520,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::NonFourAlignedEffectiveIndexBufferOffset:
return true;
case QRhi::NPOTTextureRepeat:
return caps.npotTextureRepeat;
default:
Q_UNREACHABLE();
return false;
......@@ -2078,11 +2083,8 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
return false;
QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
if (!rhiD->f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)
&& (!isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height())))
{
if (!rhiD->caps.npotTexture && (!isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height())))
size = QSize(qNextPowerOfTwo(size.width()), qNextPowerOfTwo(size.height()));
}
const bool isCube = m_flags.testFlag(CubeMap);
const bool hasMipMaps = m_flags.testFlag(MipMapped);
......
......@@ -561,6 +561,8 @@ public:
// Multisample fb and blit are supported (GLES 3.0 or OpenGL 3.x). Not
// the same as multisample textures!
bool msaaRenderBuffer = false;
bool npotTexture = true;
bool npotTextureRepeat = true;
int maxTextureSize = 2048;
} caps;
bool inFrame = false;
......
......@@ -515,6 +515,8 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::NonFourAlignedEffectiveIndexBufferOffset:
return false;
case QRhi::NPOTTextureRepeat:
return true;
default:
Q_UNREACHABLE();
return false;
......
......@@ -3039,6 +3039,8 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::NonFourAlignedEffectiveIndexBufferOffset:
return true;
case QRhi::NPOTTextureRepeat:
return true;
default:
Q_UNREACHABLE();
return 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