Skip to content

Commit

Permalink
MSVC fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Aug 13, 2024
1 parent 676202f commit 7dea7bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 44 deletions.
5 changes: 3 additions & 2 deletions math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ struct transform3 {
///
/// @param m is the rotation matrix
/// @param v is the vector to be rotated
ALGEBRA_HOST_DEVICE
inline constexpr auto rotate(const matrix44 &m, const vector3 &v) const {
template <typename vector3_type>
ALGEBRA_HOST_DEVICE inline constexpr auto rotate(
const matrix44 &m, const vector3_type &v) const {

return m.x * v[0] + m.y * v[1] + m.z * v[2];
}
Expand Down
51 changes: 12 additions & 39 deletions storage/common/include/algebra/storage/matrix44.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,13 @@ struct matrix44 {
/// Functor used to access elements of matrix44
struct element_getter {

/// Get const access to a matrix element
template <template <typename, std::size_t> class array_t, typename value_t,
std::size_t N>
ALGEBRA_HOST inline decltype(auto) operator()(
const matrix44<array_t, value_t, N> &m, std::size_t row,
std::size_t col) const {

// Make sure that the indices are valid.
assert(row < 4u);
assert(col < 4u);

// Return the selected element.
switch (col) {
case 0u:
return m.x[row];
case 1u:
return m.y[row];
case 2u:
return m.z[row];
case 3u:
return m.t[row];
default:
#ifndef _MSC_VER
__builtin_unreachable();
#else
return m.x[0];
#endif
}
}

/// Get non-const access to a matrix element
template <template <typename, std::size_t> class array_t, typename value_t,
std::size_t N>
ALGEBRA_HOST inline decltype(auto) operator()(
matrix44<array_t, value_t, N> &m, std::size_t row,
std::size_t col) const {
template <typename matrix44_t,
std::enable_if_t<
detail::is_storage_vector_v<typename matrix44_t::vector_type>,
bool> = true>
ALGEBRA_HOST inline decltype(auto) operator()(matrix44_t &m, std::size_t row,
std::size_t col) const {

// Make sure that the indices are valid.
assert(row < 4u);
Expand All @@ -158,10 +129,12 @@ struct element_getter {
}

/// Get const access to a matrix element
template <template <typename, std::size_t> class array_t, typename value_t>
ALGEBRA_HOST inline decltype(auto) operator()(const array_t<value_t, 16> &m,
unsigned int row,
unsigned int col) const {
template <typename matrix44_t,
std::enable_if_t<
!detail::is_storage_vector_v<typename matrix44_t::vector_type>,
bool> = true>
ALGEBRA_HOST inline decltype(auto) operator()(matrix44_t &m, std::size_t row,
std::size_t col) const {
// Make sure that the indices are valid.
assert(row < 4);
assert(col < 4);
Expand Down
4 changes: 2 additions & 2 deletions storage/vc_soa/include/algebra/storage/vc_soa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ template <typename T>
using value_type = Vc::Vector<T>;
/// Vector type used in the Vc SoA storage model
template <typename T, std::size_t N>
using vector_type = storage::vector<N, value_type<T>, std::array>;
using vector_type = storage::vector<N, value_type<T>, storage_type>;
/// Matrix type used in the Vc SoA storage model
template <typename T, size_type ROWS, size_type COLS>
using matrix_type = storage::vector<ROWS * COLS, value_type<T>, std::array>;
using matrix_type = storage::vector<ROWS * COLS, value_type<T>, storage_type>;

/// 2-element "vector" type, using @c Vc::Vector in every element
template <typename T>
Expand Down
1 change: 0 additions & 1 deletion tests/vc_soa/vc_soa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ TEST(test_vc_host, vc_soa_transform3) {
// Value type is Vc::Vector<float>
using value_t = typename vector3::value_type;
using transform3 = vc_soa::transform3<scalar_t>;
using transform3 = vc_soa::transform3<scalar_t>;

transform3 idty{};

Expand Down

0 comments on commit 7dea7bd

Please sign in to comment.