From 2cfafd51337dcebee06341127e8a26d9b70fb7cb Mon Sep 17 00:00:00 2001 From: sharkautarch <128002472+sharkautarch@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:27:32 -0500 Subject: [PATCH] allow simd constexpr vec to work on arches such as riscv glm only utilizes simd intrinsics for aarch64 and x86_64, but other platforms will now benefit from the arch-agnostic simd constructors and arithmetic operators used in the c++20 vec implementation --- glm/detail/qualifier.hpp | 12 ++++++++++-- glm/detail/setup.hpp | 2 +- glm/detail/simd_constexpr/vec.hpp | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/glm/detail/qualifier.hpp b/glm/detail/qualifier.hpp index 05492c663..07d7635ae 100644 --- a/glm/detail/qualifier.hpp +++ b/glm/detail/qualifier.hpp @@ -107,7 +107,7 @@ namespace detail }; # endif -#if (defined(__clang__) || defined(__GNUC__)) && (GLM_LANG_CXX20_FLAG & GLM_LANG) +#if ((defined(__clang__) || defined(__GNUC__)) && (GLM_LANG_CXX20_FLAG & GLM_LANG)) && GLM_SIMD_CONSTEXPR template static constexpr size_t requiredAlignment = alignof(T); @@ -127,7 +127,7 @@ namespace detail struct storage<2, T, true> { using VType = std::conditional_t< std::is_same_v, uint8_t, T>; - typedef VType type __attribute__((aligned(sizeof(VType)),vector_size(2*sizeof(VType)))); + typedef VType type __attribute__((aligned(2*sizeof(VType)),vector_size(2*sizeof(VType)))); }; template @@ -149,6 +149,14 @@ namespace detail using VType = std::conditional_t< std::is_same_v, uint8_t, T>; typedef VType type __attribute__((aligned( requiredAlignment ), vector_size(4*sizeof(VType)))); }; +# if (!(GLM_ARCH & GLM_ARCH_SIMD_BIT)) + template + struct storage<4, T, true> + { + using VType = std::conditional_t< std::is_same_v, uint8_t, T>; + typedef VType type __attribute__((aligned(4*sizeof(VType)),vector_size(sizeof(VType)))); + }; +# endif #endif # if GLM_ARCH & GLM_ARCH_SSE2_BIT diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 302225113..482c5a9f6 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -883,7 +883,7 @@ namespace detail # define GLM_FORCE_ALIGNED_GENTYPES #endif -#if GLM_HAS_ALIGNOF && (GLM_LANG & GLM_LANG_CXXMS_FLAG) && (defined(GLM_FORCE_ALIGNED_GENTYPES) || (GLM_CONFIG_SIMD == GLM_ENABLE)) +#if (GLM_HAS_ALIGNOF && (GLM_LANG & GLM_LANG_CXXMS_FLAG) && (defined(GLM_FORCE_ALIGNED_GENTYPES) || (GLM_CONFIG_SIMD == GLM_ENABLE))) || GLM_SIMD_CONSTEXPR # define GLM_CONFIG_ALIGNED_GENTYPES GLM_ENABLE #else # define GLM_CONFIG_ALIGNED_GENTYPES GLM_DISABLE diff --git a/glm/detail/simd_constexpr/vec.hpp b/glm/detail/simd_constexpr/vec.hpp index 19e2856a3..88689fad6 100644 --- a/glm/detail/simd_constexpr/vec.hpp +++ b/glm/detail/simd_constexpr/vec.hpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace glm { #ifdef __clang__