SIMD sqrt optimizations including lowp

This commit is contained in:
Christophe Riccio
2016-05-29 02:57:53 +02:00
parent 449c7ccedf
commit 20cf68679c
6 changed files with 68 additions and 55 deletions

View File

@@ -1,33 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/core/func_exponential.cpp
/// @date 2011-01-15 / 2011-09-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/common.hpp>
#include <glm/exponential.hpp>
@@ -103,6 +75,18 @@ int test_sqrt()
{
int Error(0);
# if GLM_ARCH & GLM_ARCH_SSE2_BIT
for(float f = 0.1f; f < 30.0f; f += 0.1f)
{
float q = _mm_cvtss_f32(_mm_sqrt_ps(_mm_set1_ps(f)));
float r = _mm_cvtss_f32(glm_f32v4_sqrt_lowp(_mm_set1_ps(f)));
float s = std::sqrt(f);
Error += glm::abs(q - s) < 0.01f ? 0 : 1;
Error += glm::abs(r - s) < 0.01f ? 0 : 1;
assert(!Error);
}
# endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
float A = glm::sqrt(10.f);
glm::vec1 B = glm::sqrt(glm::vec1(10.f));
glm::vec2 C = glm::sqrt(glm::vec2(10.f));