Skip to content

Commit

Permalink
Fixed SIMD implementation #1222
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Feb 9, 2024
1 parent 90f2b02 commit b101e8f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion glm/simd/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 mul0 = glm_vec4_mul(_mm_set1_ps(2.0f), clp0);
glm_vec4 const sub2 = glm_vec4_sub(_mm_set1_ps(3.0f), mul0);
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ target_link_libraries(main PRIVATE glm::glm)

## 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:
- Enables only warnings as errors while building unit tests
Expand All @@ -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 `GTX_color_space` missing <glm/ext/scalar_constants.hpp> include #1233 #1238
- 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
#### Features:
Expand Down
37 changes: 37 additions & 0 deletions test/core/core_func_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,42 @@ 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_
{
static int test()
Expand Down Expand Up @@ -1367,6 +1403,7 @@ int main()
Error += floatBitsToUint::test();
Error += mix_::test();
Error += step_::test();
Error += smoothstep_::test();
Error += max_::test();
Error += min_::test();
Error += clamp_::test();
Expand Down

0 comments on commit b101e8f

Please sign in to comment.