Fixed SIMD implementation #1222

This commit is contained in:
Christophe 2024-02-08 21:31:06 +01:00 committed by Christophe
parent 90f2b025b1
commit b101e8f3de
3 changed files with 40 additions and 2 deletions

View File

@ -215,7 +215,7 @@ GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_smoothstep(glm_vec4 edge0, glm_vec4 edge1,
{ {
glm_vec4 const sub0 = glm_vec4_sub(x, edge0); glm_vec4 const sub0 = glm_vec4_sub(x, edge0);
glm_vec4 const sub1 = glm_vec4_sub(edge1, edge0); glm_vec4 const sub1 = glm_vec4_sub(edge1, edge0);
glm_vec4 const div0 = glm_vec4_sub(sub0, sub1); glm_vec4 const div0 = glm_vec4_div(sub0, sub1);
glm_vec4 const clp0 = glm_vec4_clamp(div0, _mm_setzero_ps(), _mm_set1_ps(1.0f)); glm_vec4 const clp0 = glm_vec4_clamp(div0, _mm_setzero_ps(), _mm_set1_ps(1.0f));
glm_vec4 const mul0 = glm_vec4_mul(_mm_set1_ps(2.0f), clp0); glm_vec4 const mul0 = glm_vec4_mul(_mm_set1_ps(2.0f), clp0);
glm_vec4 const sub2 = glm_vec4_sub(_mm_set1_ps(3.0f), mul0); glm_vec4 const sub2 = glm_vec4_sub(_mm_set1_ps(3.0f), mul0);

View File

@ -105,7 +105,7 @@ target_link_libraries(main PRIVATE glm::glm)
## Release notes ## Release notes
### [GLM 1.0.1](https://github.com/g-truc/glm) - 2024-XX-XX ### [GLM 1.0.1](https://github.com/g-truc/glm) - 2024-02-XX
#### Improvements: #### Improvements:
- Enables only warnings as errors while building unit tests - Enables only warnings as errors while building unit tests
@ -115,6 +115,7 @@ target_link_libraries(main PRIVATE glm::glm)
- Fixed C++ language auto detection build, disable C++98 warnings with Clang #1235, #1231 - Fixed C++ language auto detection build, disable C++98 warnings with Clang #1235, #1231
- Fixed `GTX_color_space` missing <glm/ext/scalar_constants.hpp> include #1233 #1238 - Fixed `GTX_color_space` missing <glm/ext/scalar_constants.hpp> include #1233 #1238
- Fixed `EXT_matrix_transform` `shear` implementation #1140 #1182 - Fixed `EXT_matrix_transform` `shear` implementation #1140 #1182
- Fixed `smoothstep` SIMD implementation #1222
### [GLM 1.0.0](https://github.com/g-truc/glm/releases/tag/1.0.0) - 2024-01-24 ### [GLM 1.0.0](https://github.com/g-truc/glm/releases/tag/1.0.0) - 2024-01-24
#### Features: #### Features:

View File

@ -657,6 +657,42 @@ namespace step_
} }
}//namespace step_ }//namespace step_
namespace smoothstep_
{
static int test()
{
int Error = 0;
float const Edge = 2.0f;
// scalar
{
float const A = glm::smoothstep(0.0f, Edge, 1.0f);
Error += glm::equal(A, 0.5f, glm::epsilon<float>()) ? 0 : 1;
float const B = glm::smoothstep(0.0f, Edge, 1.0f);
Error += glm::equal(B, 0.5f, glm::epsilon<float>()) ? 0 : 1;
float const C = glm::smoothstep(0.0f, Edge, 1.0f);
Error += glm::equal(C, 0.5f, glm::epsilon<float>()) ? 0 : 1;
}
// vec4 and float
{
glm::vec4 Result = glm::smoothstep(0.0f, Edge, glm::vec4(1.0f));
Error += glm::all(glm::equal(Result, glm::vec4(0.5f), glm::epsilon<float>())) ? 0 : 1;
}
// vec4 and vec4
{
glm::vec4 Result = glm::smoothstep(glm::vec4(0.0f), glm::vec4(Edge), glm::vec4(1.0f));
Error += glm::all(glm::equal(Result, glm::vec4(0.5f), glm::epsilon<float>())) ? 0 : 1;
}
return Error;
}
}//namespace smoothstep_
namespace round_ namespace round_
{ {
static int test() static int test()
@ -1367,6 +1403,7 @@ int main()
Error += floatBitsToUint::test(); Error += floatBitsToUint::test();
Error += mix_::test(); Error += mix_::test();
Error += step_::test(); Error += step_::test();
Error += smoothstep_::test();
Error += max_::test(); Error += max_::test();
Error += min_::test(); Error += min_::test();
Error += clamp_::test(); Error += clamp_::test();