Commit 5524f05f by Nicolas Capens

Fix missing abs() declaration.

Change-Id: I7e4ceea2a45e8767881094de8b69b4d3aadab158 Reviewed-on: https://swiftshader-review.googlesource.com/4354Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 1629c2b0
...@@ -14,17 +14,14 @@ ...@@ -14,17 +14,14 @@
#include "Types.hpp" #include "Types.hpp"
#include <math.h> #include <cmath>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#include <intrin.h> #include <intrin.h>
#endif #endif
namespace sw namespace sw
{ {
inline float abs(float x) using std::abs;
{
return fabsf(x);
}
#undef min #undef min
#undef max #undef max
......
...@@ -37,9 +37,6 @@ ...@@ -37,9 +37,6 @@
#include <GL/GL.h> #include <GL/GL.h>
#include <GL/glext.h> #include <GL/glext.h>
#undef near
#undef far
namespace gl namespace gl
{ {
Context::Context(const Context *shareContext) Context::Context(const Context *shareContext)
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <limits> #include <limits>
using std::abs;
static bool validImageSize(GLint level, GLsizei width, GLsizei height) static bool validImageSize(GLint level, GLsizei width, GLsizei height)
{ {
if(level < 0 || level >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0) if(level < 0 || level >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0)
...@@ -6560,7 +6562,7 @@ void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params) ...@@ -6560,7 +6562,7 @@ void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
if(params[3] == 0.0f) // Directional light if(params[3] == 0.0f) // Directional light
{ {
// Create a very far out point light // Create a very far out point light
float max = std::max(std::max(abs(params[0]), abs(params[1])), abs(params[2])); float max = sw::max(abs(params[0]), abs(params[1]), abs(params[2]));
device->setLightPosition(light - GL_LIGHT0, sw::Point(params[0] / max * 1e10f, params[1] / max * 1e10f, params[2] / max * 1e10f)); device->setLightPosition(light - GL_LIGHT0, sw::Point(params[0] / max * 1e10f, params[1] / max * 1e10f, params[2] / max * 1e10f));
} }
else else
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#define LIBGL_MATHUTIL_H_ #define LIBGL_MATHUTIL_H_
#include "common/debug.h" #include "common/debug.h"
#include "Common/Math.hpp"
#include <math.h>
namespace gl namespace gl
{ {
......
...@@ -30,10 +30,7 @@ ...@@ -30,10 +30,7 @@
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <algorithm> using std::abs;
#undef near
#undef far
namespace es1 namespace es1
{ {
...@@ -1942,7 +1939,7 @@ void Context::applyState(GLenum drawMode) ...@@ -1942,7 +1939,7 @@ void Context::applyState(GLenum drawMode)
else // Directional light else // Directional light
{ {
// Hack: set the position far way // Hack: set the position far way
float max = std::max(std::max(abs(light[i].position.x), abs(light[i].position.y)), abs(light[i].position.z)); float max = sw::max(abs(light[i].position.x), abs(light[i].position.y), abs(light[i].position.z));
device->setLightPosition(i, sw::Point(1e10f * (light[i].position.x / max), 1e10f * (light[i].position.y / max), 1e10f * (light[i].position.z / max))); device->setLightPosition(i, sw::Point(1e10f * (light[i].position.x / max), 1e10f * (light[i].position.y / max), 1e10f * (light[i].position.z / max)));
} }
} }
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#define LIBGLES_CM_MATHUTIL_H_ #define LIBGLES_CM_MATHUTIL_H_
#include "common/debug.h" #include "common/debug.h"
#include "Common/Math.hpp"
#include <math.h>
namespace es1 namespace es1
{ {
......
...@@ -37,9 +37,6 @@ ...@@ -37,9 +37,6 @@
#include <EGL/eglext.h> #include <EGL/eglext.h>
#undef near
#undef far
namespace es2 namespace es2
{ {
Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion) Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion)
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#define LIBGLESV2_MATHUTIL_H_ #define LIBGLESV2_MATHUTIL_H_
#include "common/debug.h" #include "common/debug.h"
#include "Common/Math.hpp"
#include <math.h>
namespace es2 namespace es2
{ {
...@@ -51,12 +50,12 @@ inline T clamp(T x, MIN min, MAX max) ...@@ -51,12 +50,12 @@ inline T clamp(T x, MIN min, MAX max)
return x < min ? min : (x > max ? max : x); return x < min ? min : (x > max ? max : x);
} }
template<class T> template<class T>
inline void swap(T &a, T &b) inline void swap(T &a, T &b)
{ {
T t = a; T t = a;
a = b; a = b;
b = t; b = t;
} }
inline float clamp01(float x) inline float clamp01(float x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment