mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 19:34:36 +00:00
Improved simd cast and added duplicated values function with smind instructions
This commit is contained in:
parent
510d9bbccf
commit
8387847c42
@ -134,6 +134,11 @@ namespace glm
|
|||||||
{
|
{
|
||||||
typedef detail::fmat4x4SIMD simdMat4;
|
typedef detail::fmat4x4SIMD simdMat4;
|
||||||
|
|
||||||
|
//! Convert a simdMat4 to a mat4.
|
||||||
|
//! (From GLM_GTX_simd_mat4 extension)
|
||||||
|
detail::tmat4x4<float> mat4_cast(
|
||||||
|
detail::fmat4x4SIMD const & x);
|
||||||
|
|
||||||
//! Multiply matrix x by matrix y component-wise, i.e.,
|
//! Multiply matrix x by matrix y component-wise, i.e.,
|
||||||
//! result[i][j] is the scalar product of x[i][j] and y[i][j].
|
//! result[i][j] is the scalar product of x[i][j] and y[i][j].
|
||||||
//! (From GLM_GTX_simd_mat4 extension).
|
//! (From GLM_GTX_simd_mat4 extension).
|
||||||
|
@ -237,6 +237,19 @@ namespace detail
|
|||||||
namespace gtx{
|
namespace gtx{
|
||||||
namespace simd_mat4
|
namespace simd_mat4
|
||||||
{
|
{
|
||||||
|
inline detail::tmat4x4<float> mat4_cast
|
||||||
|
(
|
||||||
|
detail::fmat4x4SIMD const & x
|
||||||
|
)
|
||||||
|
{
|
||||||
|
detail::tmat4x4<float> Result;
|
||||||
|
_mm_store_ps(&Result[0][0], x.Data[0].Data);
|
||||||
|
_mm_store_ps(&Result[1][0], x.Data[1].Data);
|
||||||
|
_mm_store_ps(&Result[2][0], x.Data[2].Data);
|
||||||
|
_mm_store_ps(&Result[3][0], x.Data[3].Data);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
inline detail::fmat4x4SIMD simdMatrixCompMult
|
inline detail::fmat4x4SIMD simdMatrixCompMult
|
||||||
(
|
(
|
||||||
detail::fmat4x4SIMD const & x,
|
detail::fmat4x4SIMD const & x,
|
||||||
|
@ -51,10 +51,6 @@ namespace glm
|
|||||||
fvec4SIMD(__m128 const & Data);
|
fvec4SIMD(__m128 const & Data);
|
||||||
fvec4SIMD(fvec4SIMD const & v);
|
fvec4SIMD(fvec4SIMD const & v);
|
||||||
|
|
||||||
fvec4SIMD(tvec4<float> const & v);
|
|
||||||
//operator detail::tvec4<float>();
|
|
||||||
//operator detail::tvec4<float> const();
|
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Explicit basic constructors
|
// Explicit basic constructors
|
||||||
|
|
||||||
@ -67,6 +63,8 @@ namespace glm
|
|||||||
float const & y,
|
float const & y,
|
||||||
float const & z,
|
float const & z,
|
||||||
float const & w);
|
float const & w);
|
||||||
|
explicit fvec4SIMD(
|
||||||
|
tvec4<float> const & v);
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
//// Convertion vector constructors
|
//// Convertion vector constructors
|
||||||
@ -129,18 +127,35 @@ namespace glm
|
|||||||
float simdLength(
|
float simdLength(
|
||||||
detail::fvec4SIMD const & x);
|
detail::fvec4SIMD const & x);
|
||||||
|
|
||||||
|
//! Returns the length of x, i.e., sqrt(x * x).
|
||||||
|
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||||
|
detail::fvec4SIMD simdLength4(
|
||||||
|
detail::fvec4SIMD const & x);
|
||||||
|
|
||||||
//! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
|
//! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
|
||||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||||
float simdDistance(
|
float simdDistance(
|
||||||
detail::fvec4SIMD const & p0,
|
detail::fvec4SIMD const & p0,
|
||||||
detail::fvec4SIMD const & p1);
|
detail::fvec4SIMD const & p1);
|
||||||
|
|
||||||
|
//! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
|
||||||
|
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||||
|
detail::fvec4SIMD simdDistance4(
|
||||||
|
detail::fvec4SIMD const & p0,
|
||||||
|
detail::fvec4SIMD const & p1);
|
||||||
|
|
||||||
//! Returns the dot product of x and y, i.e., result = x * y.
|
//! Returns the dot product of x and y, i.e., result = x * y.
|
||||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||||
float simdDot(
|
float simdDot(
|
||||||
detail::fvec4SIMD const & x,
|
detail::fvec4SIMD const & x,
|
||||||
detail::fvec4SIMD const & y);
|
detail::fvec4SIMD const & y);
|
||||||
|
|
||||||
|
//! Returns the dot product of x and y, i.e., result = x * y.
|
||||||
|
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||||
|
detail::fvec4SIMD simdDot4(
|
||||||
|
detail::fvec4SIMD const & x,
|
||||||
|
detail::fvec4SIMD const & y);
|
||||||
|
|
||||||
//! Returns the cross product of x and y.
|
//! Returns the cross product of x and y.
|
||||||
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
//! (From GLM_GTX_simd_vec4 extension, geometry functions)
|
||||||
detail::fvec4SIMD simdCross(
|
detail::fvec4SIMD simdCross(
|
||||||
|
@ -35,20 +35,6 @@ namespace glm
|
|||||||
Data(_mm_set_ps(v.w, v.z, v.y, v.x))
|
Data(_mm_set_ps(v.w, v.z, v.y, v.x))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline fvec4SIMD::operator detail::tvec4<float>()
|
|
||||||
{
|
|
||||||
detail::tvec4<float> Result;
|
|
||||||
_mm_store_ps(&Result[0], this->Data);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//inline fvec4SIMD::operator detail::tvec4<float> const()
|
|
||||||
//{
|
|
||||||
// detail::tvec4<float> Result;
|
|
||||||
// _mm_store_ps(&Result[0], this->Data);
|
|
||||||
// return Result;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Explicit basic constructors
|
// Explicit basic constructors
|
||||||
|
|
||||||
@ -304,6 +290,14 @@ namespace glm
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline detail::fvec4SIMD simdLength4
|
||||||
|
(
|
||||||
|
detail::fvec4SIMD const & x
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return detail::sse_len_ps(x.Data);
|
||||||
|
}
|
||||||
|
|
||||||
inline float simdDistance
|
inline float simdDistance
|
||||||
(
|
(
|
||||||
detail::fvec4SIMD const & p0,
|
detail::fvec4SIMD const & p0,
|
||||||
@ -315,6 +309,15 @@ namespace glm
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline detail::fvec4SIMD simdDistance4
|
||||||
|
(
|
||||||
|
detail::fvec4SIMD const & p0,
|
||||||
|
detail::fvec4SIMD const & p1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return detail::sse_dst_ps(p0.Data, p1.Data);
|
||||||
|
}
|
||||||
|
|
||||||
inline float simdDot
|
inline float simdDot
|
||||||
(
|
(
|
||||||
detail::fvec4SIMD const & x,
|
detail::fvec4SIMD const & x,
|
||||||
@ -326,6 +329,15 @@ namespace glm
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline detail::fvec4SIMD simdDot4
|
||||||
|
(
|
||||||
|
detail::fvec4SIMD const & x,
|
||||||
|
detail::fvec4SIMD const & y
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return detail::sse_dot_ss(x.Data, y.Data);
|
||||||
|
}
|
||||||
|
|
||||||
inline detail::fvec4SIMD simdCross
|
inline detail::fvec4SIMD simdCross
|
||||||
(
|
(
|
||||||
detail::fvec4SIMD const & x,
|
detail::fvec4SIMD const & x,
|
||||||
|
@ -17,8 +17,8 @@ int main()
|
|||||||
glm::simdVec4 B1(0.4f, 0.5f, 0.6f, 0.7f);
|
glm::simdVec4 B1(0.4f, 0.5f, 0.6f, 0.7f);
|
||||||
glm::simdVec4 C1 = A1 + B1;
|
glm::simdVec4 C1 = A1 + B1;
|
||||||
glm::simdVec4 D1 = A1.swizzle<glm::X, glm::Z, glm::Y, glm::W>();
|
glm::simdVec4 D1 = A1.swizzle<glm::X, glm::Z, glm::Y, glm::W>();
|
||||||
glm::simdVec4 E1 = glm::vec4(1.0f);
|
glm::simdVec4 E1(glm::vec4(1.0f));
|
||||||
glm::vec4 F1 = E1;
|
glm::vec4 F1 = glm::vec4_cast(E1);
|
||||||
//glm::vec4 G1(E1);
|
//glm::vec4 G1(E1);
|
||||||
|
|
||||||
//printf("A1(%2.3f, %2.3f, %2.3f, %2.3f)\n", A1.x, A1.y, A1.z, A1.w);
|
//printf("A1(%2.3f, %2.3f, %2.3f, %2.3f)\n", A1.x, A1.y, A1.z, A1.w);
|
||||||
|
Loading…
Reference in New Issue
Block a user