diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-11-23 12:37:00 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-01-19 19:18:52 -0800 |
commit | 00cb8afafb2867b348aa529c0702252d12d1b4d6 (patch) | |
tree | e173cbc730f713f44aaeaf399383617493549329 /tests | |
parent | 15e4fc5daeeec5eeb0c1ccb0ce6f76b5b284e2c7 (diff) |
3DCore: rip away the configure option and static choice of SIMD
Instead, simply use whatever is available from the compiler.
This also does away with the separation between Matrix4x4_SSE and
Matrix4x4_AVX2. The two classes store the data the same way and are
source-compatible; they just operate differently. This also allows for
an AVX2-enabled Qt3DRenderer to link to and run with a non-AVX Qt3DCore.
Change-Id: I76216ced393445a4ae2dfffd172a512266b2414d
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
12 files changed, 16 insertions, 672 deletions
diff --git a/tests/auto/core/CMakeLists.txt b/tests/auto/core/CMakeLists.txt index edd2e9766..28d859fcd 100644 --- a/tests/auto/core/CMakeLists.txt +++ b/tests/auto/core/CMakeLists.txt @@ -29,11 +29,9 @@ if(QT_FEATURE_private_tests) add_subdirectory(aspectcommanddebugger) add_subdirectory(qscheduler) endif() -if(QT_FEATURE_private_tests AND QT_FEATURE_qt3d_simd_sse2) +if(QT_FEATURE_private_tests AND NOT (CMAKE_OSX_ARCHITECTURES MATCHES ";") AND + (TEST_architecture_arch STREQUAL i386 OR TEST_architecture_arch STREQUAL x86_64)) add_subdirectory(vector4d_sse) add_subdirectory(vector3d_sse) add_subdirectory(matrix4x4_sse) endif() -if(QT_FEATURE_private_tests AND QT_FEATURE_qt3d_simd_avx2) - add_subdirectory(matrix4x4_avx2) -endif() diff --git a/tests/auto/core/matrix4x4_avx2/CMakeLists.txt b/tests/auto/core/matrix4x4_avx2/CMakeLists.txt deleted file mode 100644 index 378c1da25..000000000 --- a/tests/auto/core/matrix4x4_avx2/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -# Generated from matrix4x4_avx2.pro. - -##################################################################### -## tst_matrix4x4_avx2 Test: -##################################################################### - -qt_internal_add_test(tst_matrix4x4_avx2 - SOURCES - tst_matrix4x4_avx2.cpp - LIBRARIES - Qt::3DCore - Qt::3DCorePrivate - Qt::3DRenderPrivate - Qt::Gui -) diff --git a/tests/auto/core/matrix4x4_avx2/matrix4x4_avx2.pro b/tests/auto/core/matrix4x4_avx2/matrix4x4_avx2.pro deleted file mode 100644 index 4db8a1975..000000000 --- a/tests/auto/core/matrix4x4_avx2/matrix4x4_avx2.pro +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = tst_matrix4x4_avx2 -CONFIG += testcase -QT += testlib 3dcore 3dcore-private 3drender-private - -QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_AVX2 - -SOURCES += tst_matrix4x4_avx2.cpp - diff --git a/tests/auto/core/matrix4x4_avx2/tst_matrix4x4_avx2.cpp b/tests/auto/core/matrix4x4_avx2/tst_matrix4x4_avx2.cpp deleted file mode 100644 index cc5071aa9..000000000 --- a/tests/auto/core/matrix4x4_avx2/tst_matrix4x4_avx2.cpp +++ /dev/null @@ -1,507 +0,0 @@ -// Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#include <QtTest/QtTest> -#include <Qt3DCore/private/matrix4x4_avx2_p.h> -#include <Qt3DCore/private/aligned_malloc_p.h> - -using namespace Qt3DCore; - -class tst_Matrix4x4_AVX2: public QObject -{ - Q_OBJECT -public: - void *operator new(size_t, void *ptr) { return ptr; } - void operator delete(void *, void *) {} - QT3D_ALIGNED_MALLOC_AND_FREE() - -private Q_SLOTS: - - void defaultConstruction() - { - // GIVEN - Matrix4x4_AVX2 mat4; - - // THEN - QCOMPARE(mat4.m11(), 1.0f); - QCOMPARE(mat4.m12(), 0.0f); - QCOMPARE(mat4.m13(), 0.0f); - QCOMPARE(mat4.m14(), 0.0f); - - QCOMPARE(mat4.m21(), 0.0f); - QCOMPARE(mat4.m22(), 1.0f); - QCOMPARE(mat4.m23(), 0.0f); - QCOMPARE(mat4.m24(), 0.0f); - - QCOMPARE(mat4.m31(), 0.0f); - QCOMPARE(mat4.m32(), 0.0f); - QCOMPARE(mat4.m33(), 1.0f); - QCOMPARE(mat4.m34(), 0.0f); - - QCOMPARE(mat4.m41(), 0.0f); - QCOMPARE(mat4.m42(), 0.0f); - QCOMPARE(mat4.m43(), 0.0f); - QCOMPARE(mat4.m44(), 1.0f); - - } - - void checkExplicitConstruction() - { - // GIVEN - Matrix4x4_AVX2 mat4(11.0f, 12.0f, 13.0f, 14.0f, - 21.0f, 22.0f, 23.0f, 24.0f, - 31.0f, 32.0f, 33.0f, 34.0f, - 41.0f, 42.0f, 43.0f, 44.0f); - - // THEN - QCOMPARE(mat4.m11(), 11.0f); - QCOMPARE(mat4.m12(), 12.0f); - QCOMPARE(mat4.m13(), 13.0f); - QCOMPARE(mat4.m14(), 14.0f); - - QCOMPARE(mat4.m21(), 21.0f); - QCOMPARE(mat4.m22(), 22.0f); - QCOMPARE(mat4.m23(), 23.0f); - QCOMPARE(mat4.m24(), 24.0f); - - QCOMPARE(mat4.m31(), 31.0f); - QCOMPARE(mat4.m32(), 32.0f); - QCOMPARE(mat4.m33(), 33.0f); - QCOMPARE(mat4.m34(), 34.0f); - - QCOMPARE(mat4.m41(), 41.0f); - QCOMPARE(mat4.m42(), 42.0f); - QCOMPARE(mat4.m43(), 43.0f); - QCOMPARE(mat4.m44(), 44.0f); - } - - void checkTransposed() - { - // GIVEN - Matrix4x4_AVX2 mat4(11.0f, 12.0f, 13.0f, 14.0f, - 21.0f, 22.0f, 23.0f, 24.0f, - 31.0f, 32.0f, 33.0f, 34.0f, - 41.0f, 42.0f, 43.0f, 44.0f); - - // WHEN - mat4 = mat4.transposed(); - - // THEN - QCOMPARE(mat4.m11(), 11.0f); - QCOMPARE(mat4.m12(), 21.0f); - QCOMPARE(mat4.m13(), 31.0f); - QCOMPARE(mat4.m14(), 41.0f); - - QCOMPARE(mat4.m21(), 12.0f); - QCOMPARE(mat4.m22(), 22.0f); - QCOMPARE(mat4.m23(), 32.0f); - QCOMPARE(mat4.m24(), 42.0f); - - QCOMPARE(mat4.m31(), 13.0f); - QCOMPARE(mat4.m32(), 23.0f); - QCOMPARE(mat4.m33(), 33.0f); - QCOMPARE(mat4.m34(), 43.0f); - - QCOMPARE(mat4.m41(), 14.0f); - QCOMPARE(mat4.m42(), 24.0f); - QCOMPARE(mat4.m43(), 34.0f); - QCOMPARE(mat4.m44(), 44.0f); - } - - void checkMultiplication() - { - { - // GIVEN - QMatrix4x4 mat1; - QMatrix4x4 mat2; - - mat1.rotate(45.0f, QVector3D(1.0f, 0.0f, 0.0f)); - mat2.translate(5.0f, 12.0f, 11.0f); - - const Matrix4x4_AVX2 mat1fast(mat1); - const Matrix4x4_AVX2 mat2fast(mat2); - - // WHEN - const Matrix4x4_AVX2 ret = mat1fast * mat2fast; - - // THEN - QCOMPARE(ret.toQMatrix4x4(), mat1 * mat2); - } - { - // GIVEN - QMatrix4x4 mat1; - QMatrix4x4 mat2; - - mat1.rotate(45.0f, QVector3D(1.0f, 0.0f, 0.0f)); - mat2.translate(5.0f, 12.0f, 11.0f); - - const Matrix4x4_AVX2 mat1fast(mat1); - const Matrix4x4_AVX2 mat2fast(mat2); - - // WHEN - const Matrix4x4_AVX2 ret = mat2fast * mat1fast; - - // THEN - QCOMPARE(ret.toQMatrix4x4(), mat2 * mat1); - } - } - - void checkAddition() - { - { - // GIVEN - QMatrix4x4 mat1; - QMatrix4x4 mat2; - - mat1.rotate(45.0f, QVector3D(1.0f, 0.0f, 0.0f)); - mat2.translate(5.0f, 12.0f, 11.0f); - - const Matrix4x4_AVX2 mat1fast(mat1); - const Matrix4x4_AVX2 mat2fast(mat2); - - // WHEN - const Matrix4x4_AVX2 ret = mat1fast + mat2fast; - - // THEN - QCOMPARE(ret.toQMatrix4x4(), mat1 + mat2); - } - { - // GIVEN - QMatrix4x4 mat1; - QMatrix4x4 mat2; - - mat1.rotate(45.0f, QVector3D(1.0f, 0.0f, 0.0f)); - mat2.translate(5.0f, 12.0f, 11.0f); - - const Matrix4x4_AVX2 mat1fast(mat1); - const Matrix4x4_AVX2 mat2fast(mat2); - - // WHEN - const Matrix4x4_AVX2 ret = mat2fast + mat1fast; - - // THEN - QCOMPARE(ret.toQMatrix4x4(), mat2 + mat1); - } - } - - void checkSubstraction() - { - { - // GIVEN - QMatrix4x4 mat1; - QMatrix4x4 mat2; - - mat1.rotate(45.0f, QVector3D(1.0f, 0.0f, 0.0f)); - mat2.translate(5.0f, 12.0f, 11.0f); - - const Matrix4x4_AVX2 mat1fast(mat1); - const Matrix4x4_AVX2 mat2fast(mat2); - - // WHEN - const Matrix4x4_AVX2 ret = mat1fast - mat2fast; - - // THEN - QCOMPARE(ret.toQMatrix4x4(), mat1 - mat2); - } - { - // GIVEN - QMatrix4x4 mat1; - QMatrix4x4 mat2; - - mat1.rotate(45.0f, QVector3D(1.0f, 0.0f, 0.0f)); - mat2.translate(5.0f, 12.0f, 11.0f); - - const Matrix4x4_AVX2 mat1fast(mat1); - const Matrix4x4_AVX2 mat2fast(mat2); - - // WHEN - const Matrix4x4_AVX2 ret = mat2fast - mat1fast; - - // THEN - QCOMPARE(ret.toQMatrix4x4(), mat2 - mat1); - } - } - - void checkEquality() - { - { - // GIVEN - Matrix4x4_AVX2 c1; - Matrix4x4_AVX2 c2; - - // THEN - QVERIFY(c1 == c2); - } - { - QMatrix4x4 tmp; - tmp.translate(5.0f, 8.0f, 14.0f); - - // GIVEN - Matrix4x4_AVX2 c1(tmp); - Matrix4x4_AVX2 c2(tmp); - - // THEN - QVERIFY(c1 == c2); - } - { - QMatrix4x4 tmp; - tmp.translate(5.0f, 8.0f, 14.0f); - - // GIVEN - Matrix4x4_AVX2 c1; - Matrix4x4_AVX2 c2(tmp); - - // THEN - QVERIFY(!(c1 == c2)); - } - } - - void checkInequality() - { - { - // GIVEN - Matrix4x4_AVX2 c1; - Matrix4x4_AVX2 c2; - - // THEN - QVERIFY(!(c1 != c2)); - } - { - // GIVEN - QMatrix4x4 tmp; - tmp.translate(5.0f, 8.0f, 14.0f); - - Matrix4x4_AVX2 c1(tmp); - tmp.translate(3.0f, 9.0f, -4.0f); - Matrix4x4_AVX2 c2(tmp); - - // THEN - QVERIFY(c1 != c2); - } - } - - void checkMatrixVector4DMultiplication() - { - - // GIVEN - QMatrix4x4 tmpMat; - QVector4D tmpVec4(1.0f, 2.0f, 3.0f, 4.0f); - tmpMat.translate(5.0f, 8.0f, 14.0f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector4D vec4(tmpVec4); - - // WHEN - const Vector4D resultingVec = mat * vec4; - - // THEN - QCOMPARE(resultingVec.toQVector4D(), tmpMat * tmpVec4); - } - - void checkVector4DMatrixMultiplication() - { - - // GIVEN - QMatrix4x4 tmpMat; - QVector4D tmpVec4(1.0f, 2.0f, 3.0f, 4.0f); - tmpMat.translate(5.0f, 8.0f, 14.0f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector4D vec4(tmpVec4); - - // WHEN - const Vector4D resultingVec = vec4 * mat; - - // THEN - QCOMPARE(resultingVec.toQVector4D(), tmpVec4 * tmpMat); - } - - void checkMatrixVector3DMultiplication() - { - - // GIVEN - QMatrix4x4 tmpMat; - QVector3D tmpVec3(1.0f, 2.0f, 3.0f); - tmpMat.translate(5.0f, 8.0f, 14.0f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector3D vec3(tmpVec3); - - // WHEN - const Vector3D resultingVec = mat * vec3; - - // THEN - QCOMPARE(resultingVec.toQVector3D(), tmpMat * tmpVec3); - } - - void checkVector3DMatrixMultiplication() - { - - // GIVEN - QMatrix4x4 tmpMat; - QVector3D tmpVec3(1.0f, 2.0f, 3.0f); - tmpMat.translate(5.0f, 8.0f, 14.0f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector3D vec3(tmpVec3); - - // WHEN - const Vector3D resultingVec = vec3 * mat; - - // THEN - QCOMPARE(resultingVec.toQVector3D(), tmpVec3 * tmpMat); - } - - void checkRows() - { - // GIVEN - const Matrix4x4_AVX2 mat4(11.0f, 12.0f, 13.0f, 14.0f, - 21.0f, 22.0f, 23.0f, 24.0f, - 31.0f, 32.0f, 33.0f, 34.0f, - 41.0f, 42.0f, 43.0f, 44.0f); - - { - // WHEN - const Vector4D row = mat4.row(0); - - // THEN - QCOMPARE(row.x(), 11.0f); - QCOMPARE(row.y(), 12.0f); - QCOMPARE(row.z(), 13.0f); - QCOMPARE(row.w(), 14.0f); - } - { - // WHEN - const Vector4D row = mat4.row(1); - - // THEN - QCOMPARE(row.x(), 21.0f); - QCOMPARE(row.y(), 22.0f); - QCOMPARE(row.z(), 23.0f); - QCOMPARE(row.w(), 24.0f); - } - { - // WHEN - const Vector4D row = mat4.row(2); - - // THEN - QCOMPARE(row.x(), 31.0f); - QCOMPARE(row.y(), 32.0f); - QCOMPARE(row.z(), 33.0f); - QCOMPARE(row.w(), 34.0f); - } - { - // WHEN - const Vector4D row = mat4.row(3); - - // THEN - QCOMPARE(row.x(), 41.0f); - QCOMPARE(row.y(), 42.0f); - QCOMPARE(row.z(), 43.0f); - QCOMPARE(row.w(), 44.0f); - } - } - - void checkColumns() - { - // GIVEN - const Matrix4x4_AVX2 mat4(11.0f, 12.0f, 13.0f, 14.0f, - 21.0f, 22.0f, 23.0f, 24.0f, - 31.0f, 32.0f, 33.0f, 34.0f, - 41.0f, 42.0f, 43.0f, 44.0f); - - { - // WHEN - const Vector4D row = mat4.column(0); - - // THEN - QCOMPARE(row.x(), 11.0f); - QCOMPARE(row.y(), 21.0f); - QCOMPARE(row.z(), 31.0f); - QCOMPARE(row.w(), 41.0f); - } - { - // WHEN - const Vector4D row = mat4.column(1); - - // THEN - QCOMPARE(row.x(), 12.0f); - QCOMPARE(row.y(), 22.0f); - QCOMPARE(row.z(), 32.0f); - QCOMPARE(row.w(), 42.0f); - } - { - // WHEN - const Vector4D row = mat4.column(2); - - // THEN - QCOMPARE(row.x(), 13.0f); - QCOMPARE(row.y(), 23.0f); - QCOMPARE(row.z(), 33.0f); - QCOMPARE(row.w(), 43.0f); - } - { - // WHEN - const Vector4D row = mat4.column(3); - - // THEN - QCOMPARE(row.x(), 14.0f); - QCOMPARE(row.y(), 24.0f); - QCOMPARE(row.z(), 34.0f); - QCOMPARE(row.w(), 44.0f); - } - } - - void checkVectorMapVector() - { - { - // GIVEN - QMatrix4x4 tmpMat; - QVector3D tmpVec3(1.0f, 0.0f, 0.0f); - tmpMat.rotate(90.f, 0.f, 1.f, 0.f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector3D vec3(tmpVec3); - - // WHEN - const Vector3D resultingVec = mat.mapVector(vec3); - - // THEN - QCOMPARE(resultingVec.toQVector3D(), tmpMat.mapVector(tmpVec3)); - } - { - // GIVEN - QMatrix4x4 tmpMat; - QVector3D tmpVec3(0.0f, 0.0f, -1.0f); - tmpMat.rotate(90.f, 0.f, 1.f, 0.f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector3D vec3(tmpVec3); - - // WHEN - const Vector3D resultingVec = mat.mapVector(vec3); - - // THEN - QCOMPARE(resultingVec.toQVector3D(), tmpMat.mapVector(tmpVec3)); - } - { - // GIVEN - QMatrix4x4 tmpMat; - QVector3D tmpVec3(3.0f, -3.0f, -1.0f); - tmpMat.rotate(90.f, 0.33f, 0.33f, 0.33f); - - Matrix4x4_AVX2 mat(tmpMat); - Vector3D vec3(tmpVec3); - - // WHEN - const Vector3D resultingVec = mat.mapVector(vec3); - - // THEN - QCOMPARE(resultingVec.toQVector3D(), tmpMat.mapVector(tmpVec3)); - } - } -}; - -QTEST_MAIN(tst_Matrix4x4_AVX2) - -#include "tst_matrix4x4_avx2.moc" diff --git a/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp b/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp index 575cb5ad1..24880430c 100644 --- a/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp +++ b/tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp @@ -11,6 +11,7 @@ class tst_Matrix4x4_SSE: public QObject { Q_OBJECT +#ifdef __SSE2__ private Q_SLOTS: void defaultConstruction() @@ -496,6 +497,7 @@ private Q_SLOTS: QCOMPARE(resultingVec.toQVector3D(), tmpMat.mapVector(tmpVec3)); } } +#endif // __SSE2__ }; QTEST_MAIN(tst_Matrix4x4_SSE) diff --git a/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp b/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp index 7f89a4ef9..8e0bd856d 100644 --- a/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp +++ b/tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp @@ -9,6 +9,7 @@ using namespace Qt3DCore; class tst_Vector3D_SSE: public QObject { Q_OBJECT +#ifdef __SSE2__ private Q_SLOTS: void defaultConstruction() { @@ -787,6 +788,7 @@ private Q_SLOTS: QVERIFY(!v0.isNull()); } } +#endif // __SSE2__ }; QTEST_APPLESS_MAIN(tst_Vector3D_SSE) diff --git a/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp b/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp index 79d673640..2cce8d141 100644 --- a/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp +++ b/tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp @@ -10,6 +10,7 @@ using namespace Qt3DCore; class tst_Vector4D_SSE: public QObject { Q_OBJECT +#ifdef __SSE2__ private Q_SLOTS: void defaultConstruction() { @@ -890,6 +891,7 @@ private Q_SLOTS: QVERIFY(!v0.isNull()); } } +#endif }; QTEST_APPLESS_MAIN(tst_Vector4D_SSE) diff --git a/tests/auto/render/CMakeLists.txt b/tests/auto/render/CMakeLists.txt index c5c68a081..9285364f2 100644 --- a/tests/auto/render/CMakeLists.txt +++ b/tests/auto/render/CMakeLists.txt @@ -108,8 +108,6 @@ if(QT_FEATURE_private_tests) add_subdirectory(uniform) add_subdirectory(vsyncframeadvanceservice) add_subdirectory(waitfence) -endif() -if(QT_FEATURE_private_tests AND NOT QT_FEATURE_qt3d_simd_avx2) add_subdirectory(qray3d) add_subdirectory(raycasting) add_subdirectory(triangleboundingvolume) @@ -143,9 +141,7 @@ if(QT_FEATURE_private_tests AND QT_FEATURE_qt3d_input AND QT_FEATURE_qt3d_opengl add_subdirectory(qscene2d) add_subdirectory(scene2d) endif() -if(QT_FEATURE_private_tests AND QT_FEATURE_qt3d_opengl_renderer AND QT_FEATURE_qt3d_simd_avx2) - add_subdirectory(alignedresourcesmanagers-avx) -endif() -if(QT_FEATURE_private_tests AND QT_FEATURE_qt3d_opengl_renderer AND QT_FEATURE_qt3d_simd_sse2 AND NOT QT_FEATURE_qt3d_simd_avx2) +if(QT_FEATURE_private_tests AND NOT (CMAKE_OSX_ARCHITECTURES MATCHES ";") AND + (TEST_architecture_arch STREQUAL i386 OR TEST_architecture_arch STREQUAL x86_64)) add_subdirectory(alignedresourcesmanagers-sse) endif() diff --git a/tests/auto/render/alignedresourcesmanagers-avx/CMakeLists.txt b/tests/auto/render/alignedresourcesmanagers-avx/CMakeLists.txt deleted file mode 100644 index 01fd43629..000000000 --- a/tests/auto/render/alignedresourcesmanagers-avx/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -# Generated from alignedresourcesmanagers-avx.pro. - -##################################################################### -## tst_alignedresourcesmanagers-avx Test: -##################################################################### - -qt_internal_add_test(tst_alignedresourcesmanagers-avx - SOURCES - tst_alignedresourcesmanagers-avx.cpp - LIBRARIES - Qt::3DCore - Qt::3DCorePrivate - Qt::3DRender - Qt::3DRenderPrivate - Qt::Gui -) - -#### Keys ignored in scope 1:.:.:alignedresourcesmanagers-avx.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/auto/render/alignedresourcesmanagers-avx/alignedresourcesmanagers-avx.pro b/tests/auto/render/alignedresourcesmanagers-avx/alignedresourcesmanagers-avx.pro deleted file mode 100644 index 28ec7337d..000000000 --- a/tests/auto/render/alignedresourcesmanagers-avx/alignedresourcesmanagers-avx.pro +++ /dev/null @@ -1,9 +0,0 @@ -TARGET = tst_alignedresourcesmanagers-avx -CONFIG += testcase simd -TEMPLATE = app - -SOURCES += tst_alignedresourcesmanagers-avx.cpp - -QT += testlib 3dcore 3dcore-private 3drender 3drender-private - -QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_AVX2 diff --git a/tests/auto/render/alignedresourcesmanagers-avx/tst_alignedresourcesmanagers-avx.cpp b/tests/auto/render/alignedresourcesmanagers-avx/tst_alignedresourcesmanagers-avx.cpp deleted file mode 100644 index 83ab2e406..000000000 --- a/tests/auto/render/alignedresourcesmanagers-avx/tst_alignedresourcesmanagers-avx.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2017 Paul Lemire <paul.lemire350@gmail.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#include <QtTest/QtTest> -#include <Qt3DCore/qnodeid.h> -#include <Qt3DCore/private/matrix4x4_avx2_p.h> -#include <Qt3DCore/private/qresourcemanager_p.h> -#include <Qt3DRender/private/cameralens_p.h> - -using namespace Qt3DCore; - -using HMatrix = Qt3DCore::QHandle<Matrix4x4_AVX2>; -using HCameraLens = Qt3DCore::QHandle<Qt3DRender::Render::CameraLens>; - -class MatrixManager : public Qt3DCore::QResourceManager< - Matrix4x4_AVX2, - Qt3DCore::QNodeId, - Qt3DCore::NonLockingPolicy> -{ -public: - MatrixManager() {} -}; - -class CameraLensManager : public Qt3DCore::QResourceManager< - Qt3DRender::Render::CameraLens, - Qt3DCore::QNodeId, - Qt3DCore::NonLockingPolicy> -{ -public: - CameraLensManager() {} -}; - - -class tst_AlignedResourcesManagersAVX: public QObject -{ - Q_OBJECT - -private Q_SLOTS: - - void checkAllocationAndAlignmentMatrix4x4() - { - // GIVEN - MatrixManager manager; - - // WHEN - for (uint i = 0; i < std::numeric_limits<ushort>::max(); ++i) - manager.getOrCreateResource(Qt3DCore::QNodeId::createId()); - - // THEN - // Shouldn't crash - - const std::vector<HMatrix> &activeHandles = manager.activeHandles(); - for (const HMatrix handle : activeHandles) { - // WHEN - Matrix4x4_AVX2 *mat = manager.data(handle); - // THEN - QCOMPARE(int((uintptr_t)mat % 32), 0); - } - - // WHEN - for (uint i = 2; i < std::numeric_limits<ushort>::max(); ++i) { - Matrix4x4_AVX2 *mat1 = manager.data(activeHandles.at(i - 2)); - Matrix4x4_AVX2 *mat2 = manager.data(activeHandles.at(i - 1)); - Matrix4x4_AVX2 *mat3 = manager.data(activeHandles.at(i)); - - // WHEN - *mat3 = (*mat2 * *mat1); - - // THEN - // Shouldn't crash - } - } - - void checkAllocationAndAlignmentCameraLens() - { - // GIVEN - CameraLensManager manager; - - // WHEN - for (uint i = 0; i < std::numeric_limits<ushort>::max(); ++i) - manager.getOrCreateResource(Qt3DCore::QNodeId::createId()); - - // THEN - // Shouldn't crash - - const std::vector<HCameraLens> &activeHandles = manager.activeHandles(); - for (const HCameraLens handle : activeHandles) { - // WHEN - Qt3DRender::Render::CameraLens *lens = manager.data(handle); - // THEN - QCOMPARE(int((uintptr_t)lens % 32), 0); - } - } -}; - -QTEST_MAIN(tst_AlignedResourcesManagersAVX) - -#include "tst_alignedresourcesmanagers-avx.moc" diff --git a/tests/auto/render/alignedresourcesmanagers-sse/tst_alignedresourcesmanagers-sse.cpp b/tests/auto/render/alignedresourcesmanagers-sse/tst_alignedresourcesmanagers-sse.cpp index b6d699fd5..04ccd904d 100644 --- a/tests/auto/render/alignedresourcesmanagers-sse/tst_alignedresourcesmanagers-sse.cpp +++ b/tests/auto/render/alignedresourcesmanagers-sse/tst_alignedresourcesmanagers-sse.cpp @@ -35,6 +35,7 @@ class tst_AlignedResourcesManagersSSE: public QObject { Q_OBJECT +#ifdef __SSE2__ private Q_SLOTS: void checkAllocationAndAlignmentMatrix4x4() @@ -88,9 +89,14 @@ private Q_SLOTS: // WHEN Qt3DRender::Render::CameraLens *lens = manager.data(handle); // THEN +# ifdef __AVX2__ + QCOMPARE(int((uintptr_t)lens % 32), 0); +# else QCOMPARE(int((uintptr_t)lens % 16), 0); +# endif } } +#endif // __SSE2__ }; QTEST_MAIN(tst_AlignedResourcesManagersSSE) |