From 634ac2a3c1a7bae9eef6476c37cd68209c28ae4f Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Tue, 12 Jan 2016 10:49:20 -0200 Subject: Support for DDS textures This commit adds support for DDS textures. It also adds QTextureLoader, a generic texture provider without a texture target. The actual texture target will be based on the properties of the texture loaded from its "source" property. Change-Id: If89cce7a55b3d82355f2da35588a091b7188f36c Reviewed-by: Sean Harmer --- .../render/ddstextures/data/16x16x1-1-bc1-dx10.dds | Bin 0 -> 332 bytes .../ddstextures/data/16x16x1-1-bc1-nomips-dx10.dds | Bin 0 -> 276 bytes .../ddstextures/data/16x16x1-1-bc1-nomips.dds | Bin 0 -> 256 bytes .../auto/render/ddstextures/data/16x16x1-1-bc1.dds | Bin 0 -> 312 bytes .../render/ddstextures/data/16x16x1-1-bc3-dx10.dds | Bin 0 -> 516 bytes .../ddstextures/data/16x16x1-1-bc3-nomips-dx10.dds | Bin 0 -> 404 bytes .../ddstextures/data/16x16x1-1-bc3-nomips.dds | Bin 0 -> 384 bytes .../auto/render/ddstextures/data/16x16x1-1-bc3.dds | Bin 0 -> 496 bytes .../ddstextures/data/16x16x1-1-lumi-nomips.dds | Bin 0 -> 384 bytes .../render/ddstextures/data/16x16x1-1-lumi.dds | Bin 0 -> 469 bytes .../ddstextures/data/16x16x1-1-rgb-nomips.dds | Bin 0 -> 1152 bytes .../auto/render/ddstextures/data/16x16x1-1-rgb.dds | Bin 0 -> 1492 bytes .../render/ddstextures/data/16x16x1-6-bc1-dx10.dds | Bin 0 -> 1252 bytes .../ddstextures/data/16x16x1-6-bc1-nomips-dx10.dds | Bin 0 -> 916 bytes .../ddstextures/data/16x16x1-6-bc1-nomips.dds | Bin 0 -> 896 bytes .../auto/render/ddstextures/data/16x16x1-6-bc1.dds | Bin 0 -> 1232 bytes .../render/ddstextures/data/16x16x1-6-bc3-dx10.dds | Bin 0 -> 2356 bytes .../ddstextures/data/16x16x1-6-bc3-nomips-dx10.dds | Bin 0 -> 1684 bytes .../ddstextures/data/16x16x1-6-bc3-nomips.dds | Bin 0 -> 1664 bytes .../auto/render/ddstextures/data/16x16x1-6-bc3.dds | Bin 0 -> 2336 bytes .../ddstextures/data/16x16x1-6-lumi-nomips.dds | Bin 0 -> 1664 bytes .../render/ddstextures/data/16x16x1-6-lumi.dds | Bin 0 -> 2174 bytes .../ddstextures/data/16x16x1-6-rgb-nomips.dds | Bin 0 -> 6272 bytes .../auto/render/ddstextures/data/16x16x1-6-rgb.dds | Bin 0 -> 8312 bytes tests/auto/render/ddstextures/ddstextures.pro | 37 ++++++++ tests/auto/render/ddstextures/tst_ddstextures.cpp | 101 +++++++++++++++++++++ 26 files changed, 138 insertions(+) create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc1-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc1.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc3-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-bc3.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-lumi-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-lumi.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-rgb-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-1-rgb.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc1-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc1.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc3-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips-dx10.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-bc3.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-lumi-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-lumi.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-rgb-nomips.dds create mode 100644 tests/auto/render/ddstextures/data/16x16x1-6-rgb.dds create mode 100644 tests/auto/render/ddstextures/ddstextures.pro create mode 100644 tests/auto/render/ddstextures/tst_ddstextures.cpp (limited to 'tests/auto/render/ddstextures') diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc1-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc1-dx10.dds new file mode 100644 index 000000000..feacae8d1 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc1-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips-dx10.dds new file mode 100644 index 000000000..40da98cde Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips.dds new file mode 100644 index 000000000..1dd3e1e91 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc1-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc1.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc1.dds new file mode 100644 index 000000000..e31f410d2 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc1.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc3-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc3-dx10.dds new file mode 100644 index 000000000..76c820f31 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc3-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips-dx10.dds new file mode 100644 index 000000000..0a2964f12 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips.dds new file mode 100644 index 000000000..c8c94d85f Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc3-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-bc3.dds b/tests/auto/render/ddstextures/data/16x16x1-1-bc3.dds new file mode 100644 index 000000000..4a08d324a Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-bc3.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-lumi-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-1-lumi-nomips.dds new file mode 100644 index 000000000..8fdd5e3e1 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-lumi-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-lumi.dds b/tests/auto/render/ddstextures/data/16x16x1-1-lumi.dds new file mode 100644 index 000000000..82ab57958 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-lumi.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-rgb-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-1-rgb-nomips.dds new file mode 100644 index 000000000..94d06c2c4 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-rgb-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-1-rgb.dds b/tests/auto/render/ddstextures/data/16x16x1-1-rgb.dds new file mode 100644 index 000000000..45635dd97 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-1-rgb.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc1-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc1-dx10.dds new file mode 100644 index 000000000..209b796f0 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc1-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips-dx10.dds new file mode 100644 index 000000000..e79e29ab5 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips.dds new file mode 100644 index 000000000..de6796d9f Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc1-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc1.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc1.dds new file mode 100644 index 000000000..92b95ae73 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc1.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc3-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc3-dx10.dds new file mode 100644 index 000000000..f56fa09fd Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc3-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips-dx10.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips-dx10.dds new file mode 100644 index 000000000..31e137553 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips-dx10.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips.dds new file mode 100644 index 000000000..644274601 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc3-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-bc3.dds b/tests/auto/render/ddstextures/data/16x16x1-6-bc3.dds new file mode 100644 index 000000000..144515bb0 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-bc3.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-lumi-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-6-lumi-nomips.dds new file mode 100644 index 000000000..baa884a36 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-lumi-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-lumi.dds b/tests/auto/render/ddstextures/data/16x16x1-6-lumi.dds new file mode 100644 index 000000000..1a4e6f46f Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-lumi.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-rgb-nomips.dds b/tests/auto/render/ddstextures/data/16x16x1-6-rgb-nomips.dds new file mode 100644 index 000000000..318a0bd35 Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-rgb-nomips.dds differ diff --git a/tests/auto/render/ddstextures/data/16x16x1-6-rgb.dds b/tests/auto/render/ddstextures/data/16x16x1-6-rgb.dds new file mode 100644 index 000000000..1f3c8f9cf Binary files /dev/null and b/tests/auto/render/ddstextures/data/16x16x1-6-rgb.dds differ diff --git a/tests/auto/render/ddstextures/ddstextures.pro b/tests/auto/render/ddstextures/ddstextures.pro new file mode 100644 index 000000000..e81fd80d8 --- /dev/null +++ b/tests/auto/render/ddstextures/ddstextures.pro @@ -0,0 +1,37 @@ +TEMPLATE = app + +TARGET = tst_ddstextures + +CONFIG += testcase + +SOURCES += tst_ddstextures.cpp + +OTHER_FILES = \ + data/16x16x1-1-bc1.dds \ + data/16x16x1-1-bc1-dx10.dds \ + data/16x16x1-1-bc1-nomips.dds \ + data/16x16x1-1-bc1-nomips-dx10.dds \ + data/16x16x1-1-bc3.dds \ + data/16x16x1-1-bc3-dx10.dds \ + data/16x16x1-1-bc3-nomips.dds \ + data/16x16x1-1-bc3-nomips-dx10.dds \ + data/16x16x1-1-lumi.dds \ + data/16x16x1-1-lumi-nomips.dds \ + data/16x16x1-1-rgb.dds \ + data/16x16x1-1-rgb-nomips.dds \ + data/16x16x1-6-bc1.dds \ + data/16x16x1-6-bc1-dx10.dds \ + data/16x16x1-6-bc1-nomips.dds \ + data/16x16x1-6-bc1-nomips-dx10.dds \ + data/16x16x1-6-bc3.dds \ + data/16x16x1-6-bc3-dx10.dds \ + data/16x16x1-6-bc3-nomips.dds \ + data/16x16x1-6-bc3-nomips-dx10.dds \ + data/16x16x1-6-lumi.dds \ + data/16x16x1-6-lumi-nomips.dds \ + data/16x16x1-6-rgb.dds \ + data/16x16x1-6-rgb-nomips.dds + +TESTDATA = data/* + +QT += core-private 3dcore 3dcore-private 3drender 3drender-private testlib diff --git a/tests/auto/render/ddstextures/tst_ddstextures.cpp b/tests/auto/render/ddstextures/tst_ddstextures.cpp new file mode 100644 index 000000000..55e9f7f5f --- /dev/null +++ b/tests/auto/render/ddstextures/tst_ddstextures.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_DdsTextures : public QObject +{ + Q_OBJECT + +private slots: + void ddsImageData(); +}; + +void tst_DdsTextures::ddsImageData() +{ + const struct TextureInfo { + const char *source; + int width; + int height; + int depth; + int faces; + int mipmapLevels; + QOpenGLTexture::TextureFormat format; + } textures[] = { + { "data/16x16x1-1-lumi-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::R8_UNorm }, + { "data/16x16x1-1-lumi.dds", 16, 16, 1, 1, 5, QOpenGLTexture::R8_UNorm }, + { "data/16x16x1-1-rgb-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA8_UNorm }, + { "data/16x16x1-1-rgb.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA8_UNorm }, + { "data/16x16x1-1-bc1-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-1-bc1.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-1-bc3-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-1-bc3.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-1-bc1-nomips-dx10.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-1-bc1-dx10.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-1-bc3-nomips-dx10.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-1-bc3-dx10.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-6-lumi-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::R8_UNorm }, + { "data/16x16x1-6-lumi.dds", 16, 16, 1, 6, 5, QOpenGLTexture::R8_UNorm }, + { "data/16x16x1-6-rgb-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA8_UNorm }, + { "data/16x16x1-6-rgb.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA8_UNorm }, + { "data/16x16x1-6-bc1-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-6-bc1.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-6-bc3-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-6-bc3.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-6-bc1-nomips-dx10.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-6-bc1-dx10.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT1 }, + { "data/16x16x1-6-bc3-nomips-dx10.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT5 }, + { "data/16x16x1-6-bc3-dx10.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT5 }, + }; + + for (unsigned i = 0; i < sizeof(textures)/sizeof(*textures); i++) { + const TextureInfo *texture = &textures[i]; + + Qt3DRender::QTexImageData data; + + QVERIFY(data.setCompressedFile(texture->source)); + QCOMPARE(data.width(), texture->width); + QCOMPARE(data.height(), texture->height); + QCOMPARE(data.faces(), texture->faces); + QCOMPARE(data.mipLevels(), texture->mipmapLevels); + QCOMPARE(data.format(), texture->format); + } +} + +QTEST_APPLESS_MAIN(tst_DdsTextures) + +#include "tst_ddstextures.moc" -- cgit v1.2.3