summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-11-23 12:37:00 -0800
committerSamuli Piippo <samuli.piippo@qt.io>2023-03-07 18:17:39 +0000
commite47931cfa4053d72345f741887982b3d1fcd4805 (patch)
tree9fcbdfcf0b49198d703e7b38a7803e677300e121
parentaf615d26a8d115bf60ee0e28df5410379454238a (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. Fixes: QTBUG-110762 Change-Id: I76216ced393445a4ae2dfffd172a512266b2414d Reviewed-by: Paul Lemire <paul.lemire@kdab.com> (cherry picked from commit 00cb8afafb2867b348aa529c0702252d12d1b4d6) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
-rw-r--r--config_help.txt1
-rw-r--r--src/core/CMakeLists.txt83
-rw-r--r--src/core/aligned_malloc_p.h6
-rw-r--r--src/core/configure.cmake17
-rw-r--r--src/core/resources/qresourcemanager.cpp8
-rw-r--r--src/core/transforms/matrix4x4_avx2.cpp28
-rw-r--r--src/core/transforms/matrix4x4_avx2_p.h74
-rw-r--r--src/core/transforms/matrix4x4_p.h15
-rw-r--r--src/core/transforms/matrix4x4_sse.cpp4
-rw-r--r--src/core/transforms/matrix4x4_sse_p.h6
-rw-r--r--src/core/transforms/vector3d_p.h6
-rw-r--r--src/core/transforms/vector3d_sse.cpp49
-rw-r--r--src/core/transforms/vector3d_sse_p.h17
-rw-r--r--src/core/transforms/vector4d_p.h6
-rw-r--r--src/core/transforms/vector4d_sse.cpp4
-rw-r--r--src/core/transforms/vector4d_sse_p.h12
-rw-r--r--src/render/backend/uniform_p.h2
-rw-r--r--tests/auto/core/CMakeLists.txt6
-rw-r--r--tests/auto/core/matrix4x4_avx2/matrix4x4_avx2.pro8
-rw-r--r--tests/auto/core/matrix4x4_sse/tst_matrix4x4_sse.cpp2
-rw-r--r--tests/auto/core/vector3d_sse/tst_vector3d_sse.cpp2
-rw-r--r--tests/auto/core/vector4d_sse/tst_vector4d_sse.cpp2
-rw-r--r--tests/auto/render/CMakeLists.txt8
-rw-r--r--tests/auto/render/alignedresourcesmanagers-avx/alignedresourcesmanagers-avx.pro9
-rw-r--r--tests/auto/render/alignedresourcesmanagers-avx/tst_alignedresourcesmanagers-avx.cpp98
-rw-r--r--tests/auto/render/alignedresourcesmanagers-sse/tst_alignedresourcesmanagers-sse.cpp6
26 files changed, 94 insertions, 385 deletions
diff --git a/config_help.txt b/config_help.txt
index 50fd93229..8f055023d 100644
--- a/config_help.txt
+++ b/config_help.txt
@@ -3,7 +3,6 @@ Qt3D options:
-assimp .............. Select used assimp library [system/qt/no]
-qt3d-profile-jobs ... Enable jobs profiling [no]
-qt3d-profile-gl ..... Enable OpenGL profiling [no]
- -qt3d-simd ........... Select level of SIMD support [no/sse2/avx2]
-qt3d-render ......... Enable the Qt3D Render aspect [yes]
-qt3d-input .......... Enable the Qt3D Input aspect [yes]
-qt3d-logic .......... Enable the Qt3D Logic aspect [yes]
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 453fcba78..7fbaf3b1d 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -6,6 +6,7 @@
qt_internal_add_module(3DCore
SOURCES
+ aligned_malloc_p.h
aspect/qcoreaspect.cpp aspect/qcoreaspect.h aspect/qcoreaspect_p.h
aspect/qcoresettings.cpp aspect/qcoresettings.h aspect/qcoresettings_p.h
aspect/coresettings.cpp aspect/coresettings_p.h
@@ -50,6 +51,7 @@ qt_internal_add_module(3DCore
qurlhelper.cpp qurlhelper_p.h
resources/qhandle_p.h
resources/qloadgltf_p.h
+ resources/qresourcemanager.cpp resources/qresourcemanager_p.h
services/nullservices_p.h
services/qabstractframeadvanceservice.cpp services/qabstractframeadvanceservice_p.h
services/qabstractframeadvanceservice_p_p.h
@@ -106,78 +108,17 @@ qt_internal_extend_target(3DCore CONDITION gcov
"-ftest-coverage"
)
-function(qt3d_add_simd_part target)
- qt_parse_all_arguments(arg "qt3d_add_simd_part" "" ""
- "NAME;SIMD;${__default_private_args};COMPILE_FLAGS" ${ARGN})
- if ("x${arg_SIMD}" STREQUAL x)
- message(FATAL_ERROR "qt3d_add_simd_part needs a SIMD type to be set.")
- endif()
-
- set(condition "QT_FEATURE_${arg_SIMD}")
- if("${arg_SIMD}" STREQUAL arch_haswell)
- set(condition "TEST_subarch_avx2 AND TEST_subarch_bmi AND TEST_subarch_bmi2 AND TEST_subarch_f16c AND TEST_subarch_fma AND TEST_subarch_lzcnt AND TEST_subarch_popcnt")
- endif()
-
- qt_evaluate_config_expression(result ${condition})
- if(${result})
- if(QT_CMAKE_DEBUG_EXTEND_TARGET)
- message("qt3d_add_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated")
- endif()
- string(TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags)
-
- foreach(source IN LISTS arg_SOURCES)
- set_property(SOURCE "${source}" APPEND
- PROPERTY COMPILE_OPTIONS
- ${${simd_flags}}
- ${arg_COMPILE_FLAGS}
- )
- endforeach()
- set_source_files_properties(${arg_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
- target_sources(${target} PRIVATE ${arg_SOURCES})
- target_compile_options("${target}Private" INTERFACE ${${simd_flags}} ${arg_COMPILE_FLAGS})
- target_compile_definitions("${target}Private" INTERFACE ${simd_flags})
- else()
- if(QT_CMAKE_DEBUG_EXTEND_TARGET)
- message("qt3d_add_simd_part(${target} SIMD ${arg_SIMD} ...): Skipped")
- endif()
- endif()
-endfunction()
-
-if(QT_FEATURE_qt3d_simd_sse2)
- qt3d_add_simd_part(3DCore SIMD sse2
- SOURCES
- transforms/matrix4x4_sse.cpp transforms/matrix4x4_sse_p.h
- )
-endif()
-
-if(QT_FEATURE_qt3d_simd_sse2 AND NOT QT_FEATURE_qt3d_simd_avx2)
- qt3d_add_simd_part(3DCore SIMD sse2
- SOURCES
- transforms/vector3d_sse.cpp transforms/vector3d_sse_p.h
- transforms/vector4d_sse.cpp transforms/vector4d_sse_p.h
- aligned_malloc_p.h
- vector_helper_p.h
- resources/qresourcemanager.cpp resources/qresourcemanager_p.h
- )
-endif()
-
-if(QT_FEATURE_qt3d_simd_avx2)
- qt3d_add_simd_part(3DCore SIMD arch_haswell
- SOURCES
- transforms/matrix4x4_avx2.cpp transforms/matrix4x4_avx2_p.h
- transforms/vector3d_sse.cpp transforms/vector3d_sse_p.h
- transforms/vector4d_sse.cpp transforms/vector4d_sse_p.h
- aligned_malloc_p.h
- resources/qresourcemanager.cpp resources/qresourcemanager_p.h
- )
-endif()
-
-qt_internal_extend_target(3DCore
- CONDITION
- NOT QT_FEATURE_qt3d_simd_sse2 AND NOT QT_FEATURE_qt3d_simd_avx2
+qt_internal_extend_target(3DCore CONDITION
+ CONDITION ( TEST_architecture_arch STREQUAL i386 ) OR
+ ( TEST_architecture_arch STREQUAL x86_64 ) OR
+ ( CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" ) OR
+ ( CMAKE_OSX_ARCHITECTURES MATCHES "x86_64h" ) OR
+ ( CMAKE_OSX_ARCHITECTURES MATCHES "i386" )
SOURCES
- aligned_malloc_p.h
- resources/qresourcemanager.cpp resources/qresourcemanager_p.h
+ transforms/matrix4x4_avx2_p.h
+ transforms/matrix4x4_sse.cpp transforms/matrix4x4_sse_p.h
+ transforms/vector3d_sse.cpp transforms/vector3d_sse_p.h
+ transforms/vector4d_sse.cpp transforms/vector4d_sse_p.h
)
qt_internal_add_docs(3DCore
diff --git a/src/core/aligned_malloc_p.h b/src/core/aligned_malloc_p.h
index 750eea730..fa2b5c38f 100644
--- a/src/core/aligned_malloc_p.h
+++ b/src/core/aligned_malloc_p.h
@@ -18,15 +18,15 @@
#include <QtCore/private/qsimd_p.h>
#include <Qt3DCore/private/qt3dcore-config_p.h>
-#if QT_CONFIG(qt3d_simd_avx2) && defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
+#if defined(__AVX2__)
# define QT3D_ALIGNED_MALLOC(s) _mm_malloc(s, 32)
-#elif QT_CONFIG(qt3d_simd_sse2) && defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
+#elif defined(__SSE2__)
# define QT3D_ALIGNED_MALLOC(s) _mm_malloc(s, 16)
#else
#define QT3D_ALIGNED_MALLOC(s) malloc(s)
#endif
-#if (QT_CONFIG(qt3d_simd_avx2) && defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)) || (QT_CONFIG(qt3d_simd_sse2) && defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2))
+#if defined(__SSE2__)
# define QT3D_ALIGNED_FREE(ptr) _mm_free(ptr)
#else
# define QT3D_ALIGNED_FREE(ptr) free(ptr)
diff --git a/src/core/configure.cmake b/src/core/configure.cmake
index be9b63cc5..c70c0f72c 100644
--- a/src/core/configure.cmake
+++ b/src/core/configure.cmake
@@ -65,26 +65,9 @@ qt_feature("qt3d-animation" PUBLIC
PURPOSE "Use the 3D Animation Aspect library"
CONDITION QT_FEATURE_qt3d_render
)
-qt_feature("qt3d-simd-sse2" PRIVATE
- LABEL "Use SSE2 instructions"
- PURPOSE "Use SSE2 SIMD instructions to accelerate matrix operations"
- AUTODETECT QT_FEATURE_sse2
- ENABLE INPUT_qt3d_simd STREQUAL 'sse2' OR INPUT_qt3d_simd STREQUAL 'avx2'
- DISABLE INPUT_qt3d_simd STREQUAL 'no' OR ( TEST_architecture_arch STREQUAL i386 )
-)
-qt_feature("qt3d-simd-avx2" PRIVATE
- LABEL "Use AVX2 instructions"
- PURPOSE "Use AVX2 SIMD instructions to accelerate matrix operations"
- AUTODETECT TEST_arch_${TEST_architecture_arch}_subarch_avx2
- CONDITION QT_FEATURE_avx2
- ENABLE INPUT_qt3d_simd STREQUAL 'avx2'
- DISABLE INPUT_qt3d_simd STREQUAL 'sse2' OR INPUT_qt3d_simd STREQUAL 'no' OR ( TEST_architecture_arch STREQUAL i386 )
-)
qt_configure_add_summary_section(NAME "Qt 3D")
qt_configure_add_summary_entry(ARGS "qt3d-assimp")
qt_configure_add_summary_entry(ARGS "qt3d-system-assimp")
-qt_configure_add_summary_entry(ARGS "qt3d-simd-sse2")
-qt_configure_add_summary_entry(ARGS "qt3d-simd-avx2")
qt_configure_add_summary_section(NAME "Aspects")
qt_configure_add_summary_entry(ARGS "qt3d-render")
qt_configure_add_summary_entry(ARGS "qt3d-input")
diff --git a/src/core/resources/qresourcemanager.cpp b/src/core/resources/qresourcemanager.cpp
index 4dc113ef9..410b223fb 100644
--- a/src/core/resources/qresourcemanager.cpp
+++ b/src/core/resources/qresourcemanager.cpp
@@ -57,9 +57,9 @@ namespace Qt3DCore {
void *AlignedAllocator::allocate(uint size)
{
-#if QT_CONFIG(qt3d_simd_avx2) && defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
+#if defined(__AVX2__)
return _mm_malloc(size, 32);
-#elif QT_CONFIG(qt3d_simd_sse2) && defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
+#elif defined(__SSE2__)
return _mm_malloc(size, 16);
#else
return malloc(size);
@@ -68,9 +68,7 @@ void *AlignedAllocator::allocate(uint size)
void AlignedAllocator::release(void *p)
{
-#if QT_CONFIG(qt3d_simd_avx2) && defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
- _mm_free(p);
-#elif QT_CONFIG(qt3d_simd_sse2) && defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
+#if defined(__SSE2__)
_mm_free(p);
#else
free(p);
diff --git a/src/core/transforms/matrix4x4_avx2.cpp b/src/core/transforms/matrix4x4_avx2.cpp
deleted file mode 100644
index a14b2bd8c..000000000
--- a/src/core/transforms/matrix4x4_avx2.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2016 Paul Lemire <paul.lemire350@gmail.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
-#include "matrix4x4_avx2_p.h"
-
-#ifdef QT_COMPILER_SUPPORTS_AVX2
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DCore {
-
-QDebug operator<<(QDebug dbg, const Matrix4x4_AVX2 &m)
-{
- dbg.nospace() << "Matrix4x4_AVX2(" << Qt::endl
- << qSetFieldWidth(10)
- << m.m11() << m.m12() << m.m13() << m.m14() << Qt::endl
- << m.m21() << m.m22() << m.m23() << m.m24() << Qt::endl
- << m.m31() << m.m32() << m.m33() << m.m34() << Qt::endl
- << m.m41() << m.m42() << m.m43() << m.m44() << Qt::endl
- << qSetFieldWidth(0) << ')';
- return dbg;
-}
-
-} // Qt3DCore
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/core/transforms/matrix4x4_avx2_p.h b/src/core/transforms/matrix4x4_avx2_p.h
index 7e8c20f9e..ea7330623 100644
--- a/src/core/transforms/matrix4x4_avx2_p.h
+++ b/src/core/transforms/matrix4x4_avx2_p.h
@@ -20,7 +20,7 @@
#include <private/qsimd_p.h>
#include <QMatrix4x4>
-#ifdef QT_COMPILER_SUPPORTS_AVX2
+#ifdef __AVX2__
// Some GCC versions don't have _mm256_set_m128 available
// Work around that
@@ -33,22 +33,22 @@ QT_BEGIN_NAMESPACE
namespace Qt3DCore {
-class Matrix4x4_AVX2
+class Matrix4x4_SSE
{
public:
- Q_ALWAYS_INLINE Matrix4x4_AVX2() { setToIdentity(); }
- explicit Q_ALWAYS_INLINE Matrix4x4_AVX2(Qt::Initialization) {}
+ Q_ALWAYS_INLINE Matrix4x4_SSE() { setToIdentity(); }
+ explicit Q_ALWAYS_INLINE Matrix4x4_SSE(Qt::Initialization) {}
// Assumes data is 32 bytes aligned (and in column major order)
- explicit Q_ALWAYS_INLINE Matrix4x4_AVX2(float *data)
+ explicit Q_ALWAYS_INLINE Matrix4x4_SSE(float *data)
{
m_col12 = _mm256_load_ps(data);
m_col34 = _mm256_load_ps(data + 8);
}
// QMatrix4x4::constData returns in column major order
- explicit Q_ALWAYS_INLINE Matrix4x4_AVX2(const QMatrix4x4 &mat)
+ explicit Q_ALWAYS_INLINE Matrix4x4_SSE(const QMatrix4x4 &mat)
{
// data may not be properly aligned, using unaligned loads
const float *data = mat.constData();
@@ -57,7 +57,7 @@ public:
}
// In (row major) but we store in column major order
- explicit Q_ALWAYS_INLINE Matrix4x4_AVX2(float m11, float m12, float m13, float m14,
+ explicit Q_ALWAYS_INLINE Matrix4x4_SSE(float m11, float m12, float m13, float m14,
float m21, float m22, float m23, float m24,
float m31, float m32, float m33, float m34,
float m41, float m42, float m43, float m44)
@@ -96,7 +96,7 @@ public:
// Using a static identity matrix and assigning it is 27 instructions
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 operator*(const Matrix4x4_AVX2 &other) const
+ Q_ALWAYS_INLINE Matrix4x4_SSE operator*(const Matrix4x4_SSE &other) const
{
// Shuffling: (Latency 1)
// (8 bits -> first two pairs used to select from the first vector, second pairs from second vector)
@@ -182,58 +182,58 @@ public:
tmp2 = _mm256_add_ps(_mm256_mul_ps(_mm256_shuffle_ps(otherCol34, otherCol34, 0xaa), _mm256_broadcast_ps(&col3)), tmp2);
tmp2 = _mm256_add_ps(_mm256_mul_ps(_mm256_shuffle_ps(otherCol34, otherCol34, 0xff), _mm256_broadcast_ps(&col4)), tmp2);
- Matrix4x4_AVX2 c(Qt::Uninitialized);
+ Matrix4x4_SSE c(Qt::Uninitialized);
c.m_col12 = tmp;
c.m_col34 = tmp2;
return c;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 operator-(const Matrix4x4_AVX2 &other) const
+ Q_ALWAYS_INLINE Matrix4x4_SSE operator-(const Matrix4x4_SSE &other) const
{
- Matrix4x4_AVX2 c(Qt::Uninitialized);
+ Matrix4x4_SSE c(Qt::Uninitialized);
c.m_col12 = _mm256_sub_ps(m_col12, other.m_col12);
c.m_col34 = _mm256_sub_ps(m_col34, other.m_col34);
return c;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 operator+(const Matrix4x4_AVX2 &other) const
+ Q_ALWAYS_INLINE Matrix4x4_SSE operator+(const Matrix4x4_SSE &other) const
{
- Matrix4x4_AVX2 c(Qt::Uninitialized);
+ Matrix4x4_SSE c(Qt::Uninitialized);
c.m_col12 = _mm256_add_ps(m_col12, other.m_col12);
c.m_col34 = _mm256_add_ps(m_col34, other.m_col34);
return c;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 &operator*=(const Matrix4x4_AVX2 &other)
+ Q_ALWAYS_INLINE Matrix4x4_SSE &operator*=(const Matrix4x4_SSE &other)
{
*this = *this * other;
return *this;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 &operator-=(const Matrix4x4_AVX2 &other)
+ Q_ALWAYS_INLINE Matrix4x4_SSE &operator-=(const Matrix4x4_SSE &other)
{
*this = *this - other;
return *this;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 &operator+=(const Matrix4x4_AVX2 &other)
+ Q_ALWAYS_INLINE Matrix4x4_SSE &operator+=(const Matrix4x4_SSE &other)
{
*this = *this + other;
return *this;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 transposed() const
+ Q_ALWAYS_INLINE Matrix4x4_SSE transposed() const
{
- Matrix4x4_AVX2 c(Qt::Uninitialized);
+ Matrix4x4_SSE c(Qt::Uninitialized);
const __m128 col1 = _mm256_extractf128_ps(m_col12, 0);
const __m128 col2 = _mm256_extractf128_ps(m_col12, 1);
const __m128 col3 = _mm256_extractf128_ps(m_col34, 0);
const __m128 col4 = _mm256_extractf128_ps(m_col34, 1);
// ~117 instructions
- // Matrix4x4_AVX2 c = *this;
+ // Matrix4x4_SSE c = *this;
// _MM_TRANSPOSE4_PS(c.m_col1, c.m_col2, c.m_col3, c.m_col4);
// ~131 instructions - AVX2
@@ -279,14 +279,14 @@ public:
return c;
}
- Q_ALWAYS_INLINE Matrix4x4_AVX2 inverted() const
+ Q_ALWAYS_INLINE Matrix4x4_SSE inverted() const
{
// TO DO: Optimize
const QMatrix4x4 mat = toQMatrix4x4();
- return Matrix4x4_AVX2(mat.inverted());
+ return Matrix4x4_SSE(mat.inverted());
}
- Q_ALWAYS_INLINE bool operator==(const Matrix4x4_AVX2 &other) const
+ Q_ALWAYS_INLINE bool operator==(const Matrix4x4_SSE &other) const
{
// cmp returns (-1, -1, -1, -1, -1, -1, -1, -1) if the two m256 are equals
// movemask takes the most significant bits (8x 1 in this case) which equals 0xff
@@ -295,7 +295,7 @@ public:
}
- Q_ALWAYS_INLINE bool operator!=(const Matrix4x4_AVX2 &other) const
+ Q_ALWAYS_INLINE bool operator!=(const Matrix4x4_SSE &other) const
{
return !(*this == other);
}
@@ -450,13 +450,13 @@ public:
Vector3D_SSE::dotProduct(row3, vector));
}
- friend Vector4D operator*(const Vector4D &vector, const Matrix4x4_AVX2 &matrix);
- friend Vector4D operator*(const Matrix4x4_AVX2 &matrix, const Vector4D &vector);
+ friend Vector4D operator*(const Vector4D &vector, const Matrix4x4_SSE &matrix);
+ friend Vector4D operator*(const Matrix4x4_SSE &matrix, const Vector4D &vector);
- friend Vector3D operator*(const Vector3D &vector, const Matrix4x4_AVX2 &matrix);
- friend Vector3D operator*(const Matrix4x4_AVX2 &matrix, const Vector3D &vector);
+ friend Vector3D operator*(const Vector3D &vector, const Matrix4x4_SSE &matrix);
+ friend Vector3D operator*(const Matrix4x4_SSE &matrix, const Vector3D &vector);
- friend Q_3DCORE_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Matrix4x4_AVX2 &m);
+ friend Q_3DCORE_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Matrix4x4_SSE &m);
private:
// column major order
@@ -476,7 +476,7 @@ private:
__m256 m_col34;
};
-Q_ALWAYS_INLINE Vector4D operator*(const Vector4D &vector, const Matrix4x4_AVX2 &matrix)
+Q_ALWAYS_INLINE Vector4D operator*(const Vector4D &vector, const Matrix4x4_SSE &matrix)
{
const __m256 vecMultiplier = _mm256_broadcast_ps(&vector.m_xyzw);
// a1 a2 a3 a4 b1 b2 b3 b4, c1 c2 c3 c4 d1 d2 d3 d4
@@ -495,13 +495,13 @@ Q_ALWAYS_INLINE Vector4D operator*(const Vector4D &vector, const Matrix4x4_AVX2
return v;
}
-Q_ALWAYS_INLINE Vector4D operator*(const Matrix4x4_AVX2 &matrix, const Vector4D &vector)
+Q_ALWAYS_INLINE Vector4D operator*(const Matrix4x4_SSE &matrix, const Vector4D &vector)
{
- const Matrix4x4_AVX2 transposed = matrix.transposed();
+ const Matrix4x4_SSE transposed = matrix.transposed();
return vector * transposed;
}
-Q_ALWAYS_INLINE Vector3D operator*(const Vector3D &vector, const Matrix4x4_AVX2 &matrix)
+Q_ALWAYS_INLINE Vector3D operator*(const Vector3D &vector, const Matrix4x4_SSE &matrix)
{
const __m128 vec4 = _mm_set_ps(1.0f, vector.z(), vector.y(), vector.x());
const __m256 vecMultiplier = _mm256_broadcast_ps(&vec4);
@@ -524,20 +524,20 @@ Q_ALWAYS_INLINE Vector3D operator*(const Vector3D &vector, const Matrix4x4_AVX2
return v;
}
-Q_ALWAYS_INLINE Vector3D operator*(const Matrix4x4_AVX2 &matrix, const Vector3D &vector)
+Q_ALWAYS_INLINE Vector3D operator*(const Matrix4x4_SSE &matrix, const Vector3D &vector)
{
- const Matrix4x4_AVX2 transposed = matrix.transposed();
+ const Matrix4x4_SSE transposed = matrix.transposed();
return vector * transposed;
}
} // Qt3DCore
-Q_DECLARE_TYPEINFO(Qt3DCore::Matrix4x4_AVX2, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(Qt3DCore::Matrix4x4_SSE, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(Qt3DCore::Matrix4x4_AVX2)
+Q_DECLARE_METATYPE(Qt3DCore::Matrix4x4_SSE)
-#endif // QT_COMPILER_SUPPORTS_AVX
+#endif // __AVX2__
#endif // QT3DCORE_MATRIX4X4_AVX2_P_H
diff --git a/src/core/transforms/matrix4x4_p.h b/src/core/transforms/matrix4x4_p.h
index ac3d02aad..3591597fb 100644
--- a/src/core/transforms/matrix4x4_p.h
+++ b/src/core/transforms/matrix4x4_p.h
@@ -16,20 +16,9 @@
//
#include <private/qsimd_p.h>
-#include <Qt3DCore/private/qt3dcore-config_p.h>
-
-// We check if sse or avx config option was enabled as it could
-// be disabled even though a given platform supports SSE2 or AVX2 instructions
-#if QT_CONFIG(qt3d_simd_avx2) && defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
-
-#include <Qt3DCore/private/matrix4x4_avx2_p.h>
-
-QT_BEGIN_NAMESPACE
-using Matrix4x4 = Qt3DCore::Matrix4x4_AVX2;
-QT_END_NAMESPACE
-
-#elif QT_CONFIG(qt3d_simd_sse2) && defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
+// Check if we can use the optimized version of QMatrix4x4
+#if defined(__SSE2__)
#include <Qt3DCore/private/matrix4x4_sse_p.h>
diff --git a/src/core/transforms/matrix4x4_sse.cpp b/src/core/transforms/matrix4x4_sse.cpp
index 0ec0f3131..83ffeb4d2 100644
--- a/src/core/transforms/matrix4x4_sse.cpp
+++ b/src/core/transforms/matrix4x4_sse.cpp
@@ -3,7 +3,7 @@
#include "matrix4x4_sse_p.h"
-#ifdef QT_COMPILER_SUPPORTS_SSE2
+#ifdef __SSE2__
QT_BEGIN_NAMESPACE
@@ -25,4 +25,4 @@ QDebug operator<<(QDebug dbg, const Matrix4x4_SSE &m)
QT_END_NAMESPACE
-#endif // QT_COMPILER_SUPPORTS_SSE2
+#endif // __SSE2__
diff --git a/src/core/transforms/matrix4x4_sse_p.h b/src/core/transforms/matrix4x4_sse_p.h
index 4197d2020..4f4a3cb54 100644
--- a/src/core/transforms/matrix4x4_sse_p.h
+++ b/src/core/transforms/matrix4x4_sse_p.h
@@ -20,7 +20,9 @@
#include <private/qsimd_p.h>
#include <QMatrix4x4>
-#ifdef QT_COMPILER_SUPPORTS_SSE2
+#if defined(__AVX2__)
+#include "matrix4x4_avx2_p.h"
+#elif defined(__SSE2__)
QT_BEGIN_NAMESPACE
@@ -466,6 +468,6 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(Qt3DCore::Matrix4x4_SSE)
-#endif // QT_COMPILER_SUPPORTS_SSE2
+#endif // __SSE2__
#endif // QT3DCORE_MATRIX4X4_SSE_P_H
diff --git a/src/core/transforms/vector3d_p.h b/src/core/transforms/vector3d_p.h
index e204613ca..a9815a2a8 100644
--- a/src/core/transforms/vector3d_p.h
+++ b/src/core/transforms/vector3d_p.h
@@ -16,11 +16,9 @@
//
#include <private/qsimd_p.h>
-#include <Qt3DCore/private/qt3dcore-config_p.h>
-// We check if sse config option was enabled as it could
-// be disabled even though a given platform supports SSE2 instructions
-#if QT_CONFIG(qt3d_simd_sse2) && (defined(__AVX2__) || defined(__SSE2__)) && defined(QT_COMPILER_SUPPORTS_SSE2)
+// Check if we can use the optimized version of QVector3D
+#if defined(__SSE2__)
#include <Qt3DCore/private/vector3d_sse_p.h>
diff --git a/src/core/transforms/vector3d_sse.cpp b/src/core/transforms/vector3d_sse.cpp
index b588fefd5..28590580f 100644
--- a/src/core/transforms/vector3d_sse.cpp
+++ b/src/core/transforms/vector3d_sse.cpp
@@ -1,19 +1,15 @@
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#include "vector3d_sse_p.h"
+
#include <private/qsimd_p.h>
-#if defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
-#include "matrix4x4_avx2_p.h"
-#else
#include "matrix4x4_sse_p.h"
-#endif
-
-#include "vector3d_sse_p.h"
#include "vector4d_sse_p.h"
#include <QDebug>
-#ifdef QT_COMPILER_SUPPORTS_SSE2
+#ifdef __SSE2__
QT_BEGIN_NAMESPACE
@@ -30,41 +26,6 @@ Vector3D_SSE::Vector3D_SSE(const Vector4D_SSE &v)
m_xyzw = _mm_mul_ps(v.m_xyzw, _mm_set_ps(0.0f, 1.0f, 1.0f, 1.0f));
}
-#if defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
-
-Vector3D_SSE Vector3D_SSE::unproject(const Matrix4x4_AVX2 &modelView, const Matrix4x4_AVX2 &projection, const QRect &viewport) const
-{
- const Matrix4x4_AVX2 inverse = (projection * modelView).inverted();
-
- Vector4D_SSE tmp(*this, 1.0f);
- tmp.setX((tmp.x() - float(viewport.x())) / float(viewport.width()));
- tmp.setY((tmp.y() - float(viewport.y())) / float(viewport.height()));
- tmp = tmp * 2.0f - Vector4D_SSE(1.0f, 1.0f, 1.0f, 1.0f);
-
- Vector4D_SSE obj = inverse * tmp;
- if (qFuzzyIsNull(obj.w()))
- obj.setW(1.0f);
- obj /= obj.w();
- return Vector3D_SSE(obj);
-}
-
-Vector3D_SSE Vector3D_SSE::project(const Matrix4x4_AVX2 &modelView, const Matrix4x4_AVX2 &projection, const QRect &viewport) const
-{
- Vector4D_SSE tmp(*this, 1.0f);
- tmp = projection * modelView * tmp;
- if (qFuzzyIsNull(tmp.w()))
- tmp.setW(1.0f);
- tmp /= tmp.w();
-
- tmp = tmp * 0.5f + Vector4D_SSE(0.5f, 0.5f, 0.5f, 0.5f);
- tmp.setX(tmp.x() * viewport.width() + viewport.x());
- tmp.setY(tmp.y() * viewport.height() + viewport.y());
-
- return Vector3D_SSE(tmp);
-}
-
-#else
-
Vector3D_SSE Vector3D_SSE::unproject(const Matrix4x4_SSE &modelView, const Matrix4x4_SSE &projection, const QRect &viewport) const
{
const Matrix4x4_SSE inverse = (projection * modelView).inverted();
@@ -96,10 +57,8 @@ Vector3D_SSE Vector3D_SSE::project(const Matrix4x4_SSE &modelView, const Matrix4
return Vector3D_SSE(tmp);
}
-#endif
-
} // Qt3DCore
QT_END_NAMESPACE
-#endif // QT_COMPILER_SUPPORTS_SSE2
+#endif // __SSE2__
diff --git a/src/core/transforms/vector3d_sse_p.h b/src/core/transforms/vector3d_sse_p.h
index 7dc5ea17f..2812b5d1a 100644
--- a/src/core/transforms/vector3d_sse_p.h
+++ b/src/core/transforms/vector3d_sse_p.h
@@ -22,14 +22,13 @@
#include <QDebug>
#include <math.h>
-#ifdef QT_COMPILER_SUPPORTS_SSE2
+#ifdef __SSE2__
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
class Matrix4x4_SSE;
-class Matrix4x4_AVX2;
class Vector4D_SSE;
class Vector3D_SSE
@@ -142,13 +141,8 @@ public:
return ((_mm_movemask_ps(_mm_cmpeq_ps(m_xyzw, _mm_set_ps1(0.0f))) & 0x7) == 0x7);
}
-#if defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
- Q_3DCORE_PRIVATE_EXPORT Vector3D_SSE unproject(const Matrix4x4_AVX2 &modelView, const Matrix4x4_AVX2 &projection, const QRect &viewport) const;
- Q_3DCORE_PRIVATE_EXPORT Vector3D_SSE project(const Matrix4x4_AVX2 &modelView, const Matrix4x4_AVX2 &projection, const QRect &viewport) const;
-#else
Q_3DCORE_PRIVATE_EXPORT Vector3D_SSE unproject(const Matrix4x4_SSE &modelView, const Matrix4x4_SSE &projection, const QRect &viewport) const;
Q_3DCORE_PRIVATE_EXPORT Vector3D_SSE project(const Matrix4x4_SSE &modelView, const Matrix4x4_SSE &projection, const QRect &viewport) const;
-#endif
Q_ALWAYS_INLINE float x() const { return _mm_cvtss_f32(m_xyzw); }
@@ -311,13 +305,6 @@ public:
}
friend class Vector4D_SSE;
-
-#if defined(__AVX2__) && defined(QT_COMPILER_SUPPORTS_AVX2)
- friend class Matrix4x4_AVX2;
- friend Vector3D_SSE operator*(const Vector3D_SSE &vector, const Matrix4x4_AVX2 &matrix);
- friend Vector3D_SSE operator*(const Matrix4x4_AVX2 &matrix, const Vector3D_SSE &vector);
-#endif
-
friend class Matrix4x4_SSE;
friend Vector3D_SSE operator*(const Vector3D_SSE &vector, const Matrix4x4_SSE &matrix);
friend Vector3D_SSE operator*(const Matrix4x4_SSE &matrix, const Vector3D_SSE &vector);
@@ -360,6 +347,6 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(Qt3DCore::Vector3D_SSE)
-#endif // QT_COMPILER_SUPPORTS_SSE2
+#endif // __SSE2__
#endif // QT3DCORE_VECTOR3D_SSE_P_H
diff --git a/src/core/transforms/vector4d_p.h b/src/core/transforms/vector4d_p.h
index 242c4cdce..57391b790 100644
--- a/src/core/transforms/vector4d_p.h
+++ b/src/core/transforms/vector4d_p.h
@@ -16,11 +16,9 @@
//
#include <private/qsimd_p.h>
-#include <Qt3DCore/private/qt3dcore-config_p.h>
-// We check if sse config option was enabled as it could
-// be disabled even though a given platform supports SSE2 instructions
-#if QT_CONFIG(qt3d_simd_sse2) && (defined(__AVX2__) || defined(__SSE2__)) && defined(QT_COMPILER_SUPPORTS_SSE2)
+// Check if we can use the optimized version of QVector3D
+#if defined(__SSE2__)
#include <Qt3DCore/private/vector4d_sse_p.h>
diff --git a/src/core/transforms/vector4d_sse.cpp b/src/core/transforms/vector4d_sse.cpp
index c422425c3..09f9106df 100644
--- a/src/core/transforms/vector4d_sse.cpp
+++ b/src/core/transforms/vector4d_sse.cpp
@@ -4,7 +4,7 @@
#include "vector4d_sse_p.h"
#include <QDebug>
-#ifdef QT_COMPILER_SUPPORTS_SSE2
+#ifdef __SSE2__
QT_BEGIN_NAMESPACE
@@ -20,4 +20,4 @@ QDebug operator<<(QDebug dbg, const Vector4D_SSE &v)
QT_END_NAMESPACE
-#endif // QT_COMPILER_SUPPORTS_SSE2
+#endif // __SSE2__
diff --git a/src/core/transforms/vector4d_sse_p.h b/src/core/transforms/vector4d_sse_p.h
index bca377307..d0044c20e 100644
--- a/src/core/transforms/vector4d_sse_p.h
+++ b/src/core/transforms/vector4d_sse_p.h
@@ -18,14 +18,13 @@
#include <Qt3DCore/private/vector3d_p.h>
#include <QtGui/qvector4d.h>
-#ifdef QT_COMPILER_SUPPORTS_SSE2
+#ifdef __SSE2__
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
class Matrix4x4_SSE;
-class Matrix4x4_AVX2;
class Vector4D_SSE
{
@@ -307,13 +306,6 @@ public:
}
friend class Matrix4x4_SSE;
-
-#ifdef __AVX2__
- friend class Matrix4x4_AVX2;
- friend Vector4D_SSE operator*(const Vector4D_SSE &vector, const Matrix4x4_AVX2 &matrix);
- friend Vector4D_SSE operator*(const Matrix4x4_AVX2 &matrix, const Vector4D_SSE &vector);
-#endif
-
friend class Vector3D_SSE;
friend Vector4D_SSE operator*(const Vector4D_SSE &vector, const Matrix4x4_SSE &matrix);
friend Vector4D_SSE operator*(const Matrix4x4_SSE &matrix, const Vector4D_SSE &vector);
@@ -357,6 +349,6 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(Qt3DCore::Vector4D_SSE)
-#endif // QT_COMPILER_SUPPORTS_SSE2
+#endif // __SSE2__
#endif // QT3DCORE_VECTOR4D_SSE_P_H
diff --git a/src/render/backend/uniform_p.h b/src/render/backend/uniform_p.h
index 30fbcc51f..b585ce39d 100644
--- a/src/render/backend/uniform_p.h
+++ b/src/render/backend/uniform_p.h
@@ -111,7 +111,7 @@ public:
}
// We don t want the QMatrix4x4 builder to use sizeof since QMatrix4x4 contains a type flag
-#if defined(__SSE2__) || defined(__AVX2__)
+#if defined(__SSE2__)
UniformValue(const Matrix4x4 &mat44)
: m_data(sizeof(Matrix4x4) / sizeof(float))
{
diff --git a/tests/auto/core/CMakeLists.txt b/tests/auto/core/CMakeLists.txt
index 5971ba67d..642d632d1 100644
--- a/tests/auto/core/CMakeLists.txt
+++ b/tests/auto/core/CMakeLists.txt
@@ -26,11 +26,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/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_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 3a1075139..87ce99741 100644
--- a/tests/auto/render/CMakeLists.txt
+++ b/tests/auto/render/CMakeLists.txt
@@ -105,8 +105,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)
@@ -140,9 +138,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/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)