aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-08-07 11:34:56 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-08-17 16:26:20 +0200
commit46ed97609721318a5ac443e8ff5b17bd359ef305 (patch)
tree2c30c5351b54e76fd96b3765f7e336c00b88116b /src
parent527687a866d1a155314c1b6d4b8a09533cf8211a (diff)
Rescale on rhi path too when NPoT textures not supported
QRhi will not do this for us. Also handle mipmap filtering correctly in this regard. This will fix rendering on WebAssembly. Change-Id: I93a77b7c42bb43c59dfb7748f9fdbd7aa55f39bb Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture.cpp13
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp
index 4c2b452b45..72313db836 100644
--- a/src/quick/scenegraph/util/qsgplaintexture.cpp
+++ b/src/quick/scenegraph/util/qsgplaintexture.cpp
@@ -378,6 +378,19 @@ void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch
q->m_texture_size = tmp.size();
}
+ if ((q->mipmapFiltering() != QSGTexture::None
+ || q->horizontalWrapMode() != QSGTexture::ClampToEdge
+ || q->verticalWrapMode() != QSGTexture::ClampToEdge)
+ && !rhi->isFeatureSupported(QRhi::NPOTTextureRepeat))
+ {
+ const int w = qNextPowerOfTwo(tmp.width() - 1);
+ const int h = qNextPowerOfTwo(tmp.height() - 1);
+ if (tmp.width() != w || tmp.height() != h) {
+ tmp = tmp.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ q->m_texture_size = tmp.size();
+ }
+ }
+
bool needsRebuild = q->m_texture && q->m_texture->pixelSize() != q->m_texture_size;
if (mipmappingChanged) {
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index a154ae269a..df4e5cfde2 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -164,6 +164,7 @@ void QSGOpaqueTextureMaterialRhiShader::updateSampledImage(const RenderState &st
if (isNpot) {
t->setHorizontalWrapMode(QSGTexture::ClampToEdge);
t->setVerticalWrapMode(QSGTexture::ClampToEdge);
+ t->setMipmapFiltering(QSGTexture::None);
}
}