summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2018-12-18 07:58:34 +0100
committerPaul Lemire <paul.lemire@kdab.com>2018-12-19 16:40:58 +0000
commitaaedd1f71b7a7e4410966041baba0f392644e482 (patch)
tree8248235681408de5d60a0cb57053237eec37296d
parentd85eede12eeab74ae446a2db4b12e23a846d0502 (diff)
Texture: initialize internal format to NoFormat
Format was initialized to RGBA8_UNorm on TextureProperties. This had the side effect that if you created a TextureLoader entry with no source yet set, the backend would try to load and return early since no texture data had yet been generated. Yet it would still send a notification change with the format (which was RGBA8_UNorm instead of NoFormat) back to the frontend QTextureLoader. This would prevent the QTextureLoader from later being loaded correctly with the format actually read from the image file. Also updated QTextureData/QTextureImageData/QTextureFromSourceLoader for consistency. Change-Id: I23e2287fac297b9b8901476715b1bc1e78c6342b Task-number: QTBUG-72651 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
-rw-r--r--src/render/texture/qtexture.cpp2
-rw-r--r--src/render/texture/qtexturedata.cpp2
-rw-r--r--src/render/texture/qtextureimagedata.cpp2
-rw-r--r--src/render/texture/texture_p.h2
-rw-r--r--tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp2
-rw-r--r--tests/auto/render/texture/tst_texture.cpp23
6 files changed, 28 insertions, 5 deletions
diff --git a/src/render/texture/qtexture.cpp b/src/render/texture/qtexture.cpp
index e539ce9de..029e47817 100644
--- a/src/render/texture/qtexture.cpp
+++ b/src/render/texture/qtexture.cpp
@@ -1419,7 +1419,7 @@ QTextureFromSourceGenerator::QTextureFromSourceGenerator(QTextureLoader *texture
, m_mirrored()
, m_texture(textureId)
, m_engine(engine)
- , m_format(QAbstractTexture::RGBA8_UNorm)
+ , m_format(QAbstractTexture::NoFormat)
{
Q_ASSERT(textureLoader);
diff --git a/src/render/texture/qtexturedata.cpp b/src/render/texture/qtexturedata.cpp
index b7bb75242..ac4ca80c0 100644
--- a/src/render/texture/qtexturedata.cpp
+++ b/src/render/texture/qtexturedata.cpp
@@ -57,7 +57,7 @@ class QTextureDataPrivate
{
public:
QAbstractTexture::Target m_target;
- QAbstractTexture::TextureFormat m_format;
+ QAbstractTexture::TextureFormat m_format = QAbstractTexture::NoFormat;
int m_width = 0;
int m_height = 0;
int m_depth = 0;
diff --git a/src/render/texture/qtextureimagedata.cpp b/src/render/texture/qtextureimagedata.cpp
index c31f272a8..bf43a6e16 100644
--- a/src/render/texture/qtextureimagedata.cpp
+++ b/src/render/texture/qtextureimagedata.cpp
@@ -55,7 +55,7 @@ QTextureImageDataPrivate::QTextureImageDataPrivate()
, m_mipLevels(-1)
, m_blockSize(-1)
, m_target(QOpenGLTexture::Target2D)
- , m_format(QOpenGLTexture::RGBA8_UNorm)
+ , m_format(QOpenGLTexture::NoFormat)
, m_pixelFormat(QOpenGLTexture::RGBA)
, m_pixelType(QOpenGLTexture::UInt8)
, m_isCompressed(false)
diff --git a/src/render/texture/texture_p.h b/src/render/texture/texture_p.h
index 9e385cefe..86c49f695 100644
--- a/src/render/texture/texture_p.h
+++ b/src/render/texture/texture_p.h
@@ -84,7 +84,7 @@ struct TextureProperties
int mipLevels = 1;
int samples = 1;
QAbstractTexture::Target target = QAbstractTexture::Target2D;
- QAbstractTexture::TextureFormat format = QAbstractTexture::RGBA8_UNorm;
+ QAbstractTexture::TextureFormat format = QAbstractTexture::NoFormat;
bool generateMipMaps = false;
QAbstractTexture::Status status = QAbstractTexture::None;
diff --git a/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp b/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp
index dec816a5e..ba0c9a9bf 100644
--- a/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp
+++ b/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp
@@ -55,7 +55,7 @@ private Q_SLOTS:
QCOMPARE(tid->layers(), -1);
QCOMPARE(tid->mipLevels(), -1);
QCOMPARE(tid->target(), QOpenGLTexture::Target2D);
- QCOMPARE(tid->format(), QOpenGLTexture::RGBA8_UNorm);
+ QCOMPARE(tid->format(), QOpenGLTexture::NoFormat);
QCOMPARE(tid->pixelFormat(), QOpenGLTexture::RGBA);
QCOMPARE(tid->pixelType(), QOpenGLTexture::UInt8);
QCOMPARE(tid->isCompressed(), false);
diff --git a/tests/auto/render/texture/tst_texture.cpp b/tests/auto/render/texture/tst_texture.cpp
index 9876518e2..d64533732 100644
--- a/tests/auto/render/texture/tst_texture.cpp
+++ b/tests/auto/render/texture/tst_texture.cpp
@@ -72,12 +72,35 @@ private:
void checkPropertyMirroring();
private slots:
+ void checkDefaults();
void checkFrontendPropertyNotifications();
void checkPropertyMirroring();
void checkPropertyChanges();
void checkTextureImageBookeeping();
};
+void tst_RenderTexture::checkDefaults()
+{
+ Qt3DRender::Render::Texture backend;
+
+ QCOMPARE(backend.properties().format, Qt3DRender::QAbstractTexture::NoFormat);
+ QCOMPARE(backend.properties().width, 1);
+ QCOMPARE(backend.properties().height, 1);
+ QCOMPARE(backend.properties().depth, 1);
+ QCOMPARE(backend.properties().layers, 1);
+ QCOMPARE(backend.properties().mipLevels, 1);
+ QCOMPARE(backend.properties().samples, 1);
+ QCOMPARE(backend.properties().generateMipMaps, false);
+ QCOMPARE(backend.parameters().magnificationFilter, Qt3DRender::QAbstractTexture::Nearest);
+ QCOMPARE(backend.parameters().minificationFilter, Qt3DRender::QAbstractTexture::Nearest);
+ QCOMPARE(backend.parameters().wrapModeX, Qt3DRender::QTextureWrapMode::ClampToEdge);
+ QCOMPARE(backend.parameters().wrapModeY, Qt3DRender::QTextureWrapMode::ClampToEdge);
+ QCOMPARE(backend.parameters().wrapModeZ, Qt3DRender::QTextureWrapMode::ClampToEdge);
+ QCOMPARE(backend.parameters().maximumAnisotropy, 1.0f);
+ QCOMPARE(backend.parameters().comparisonFunction, Qt3DRender::QAbstractTexture::CompareLessEqual);
+ QCOMPARE(backend.parameters().comparisonMode, Qt3DRender::QAbstractTexture::CompareNone);
+}
+
void tst_RenderTexture::checkFrontendPropertyNotifications()
{
// GIVEN