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 @@
#include "Types.hpp"
#include <math.h>
#include <cmath>
#if defined(_MSC_VER)
#include <intrin.h>
#endif
namespace sw
{
inline float abs(float x)
{
return fabsf(x);
}
using std::abs;
#undef min
#undef max
......
......@@ -37,9 +37,6 @@
#include <GL/GL.h>
#include <GL/glext.h>
#undef near
#undef far
namespace gl
{
Context::Context(const Context *shareContext)
......
......@@ -33,6 +33,8 @@
#include <limits>
using std::abs;
static bool validImageSize(GLint level, GLsizei width, GLsizei height)
{
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)
if(params[3] == 0.0f) // Directional 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));
}
else
......
......@@ -15,8 +15,7 @@
#define LIBGL_MATHUTIL_H_
#include "common/debug.h"
#include <math.h>
#include "Common/Math.hpp"
namespace gl
{
......
......@@ -30,10 +30,7 @@
#include <EGL/eglext.h>
#include <algorithm>
#undef near
#undef far
using std::abs;
namespace es1
{
......@@ -1942,7 +1939,7 @@ void Context::applyState(GLenum drawMode)
else // Directional light
{
// 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)));
}
}
......
......@@ -15,8 +15,7 @@
#define LIBGLES_CM_MATHUTIL_H_
#include "common/debug.h"
#include <math.h>
#include "Common/Math.hpp"
namespace es1
{
......
......@@ -37,9 +37,6 @@
#include <EGL/eglext.h>
#undef near
#undef far
namespace es2
{
Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion)
......
......@@ -15,8 +15,7 @@
#define LIBGLESV2_MATHUTIL_H_
#include "common/debug.h"
#include <math.h>
#include "Common/Math.hpp"
namespace es2
{
......@@ -51,12 +50,12 @@ inline T clamp(T x, MIN min, MAX max)
return x < min ? min : (x > max ? max : x);
}
template<class T>
inline void swap(T &a, T &b)
{
T t = a;
a = b;
b = t;
template<class T>
inline void swap(T &a, T &b)
{
T t = a;
a = b;
b = t;
}
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