Cleanup. Assume static linking.

pull/312/head
Ignacio 4 years ago
parent 860b639492
commit 1a6e70c9a0

@ -67,18 +67,15 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4], bool d3d9/*= false*/) co
// color_array[1].u = c.u; // color_array[1].u = c.u;
if( col0.u > col1.u ) { if( col0.u > col1.u ) {
int bias = 0;
if (d3d9) bias = 1;
// Four-color block: derive the other two colors. // Four-color block: derive the other two colors.
color_array[2].r = (2 * color_array[0].r + color_array[1].r + bias) / 3; color_array[2].r = (2 * color_array[0].r + color_array[1].r + d3d9) / 3;
color_array[2].g = (2 * color_array[0].g + color_array[1].g + bias) / 3; color_array[2].g = (2 * color_array[0].g + color_array[1].g + d3d9) / 3;
color_array[2].b = (2 * color_array[0].b + color_array[1].b + bias) / 3; color_array[2].b = (2 * color_array[0].b + color_array[1].b + d3d9) / 3;
color_array[2].a = 0xFF; color_array[2].a = 0xFF;
color_array[3].r = (2 * color_array[1].r + color_array[0].r + bias) / 3; color_array[3].r = (2 * color_array[1].r + color_array[0].r + d3d9) / 3;
color_array[3].g = (2 * color_array[1].g + color_array[0].g + bias) / 3; color_array[3].g = (2 * color_array[1].g + color_array[0].g + d3d9) / 3;
color_array[3].b = (2 * color_array[1].b + color_array[0].b + bias) / 3; color_array[3].b = (2 * color_array[1].b + color_array[0].b + d3d9) / 3;
color_array[3].a = 0xFF; color_array[3].a = 0xFF;
return 4; return 4;

@ -35,7 +35,9 @@
#include "Filter.h" #include "Filter.h"
#include "nvmath/nvmath.h"
#include "nvmath/Vector.h" // Vector4 #include "nvmath/Vector.h" // Vector4
#include "nvcore/Utils.h" // swap #include "nvcore/Utils.h" // swap
#include <string.h> // memset #include <string.h> // memset

@ -15,15 +15,7 @@ SET(MATH_SRCS
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
# targets ADD_LIBRARY(nvmath ${MATH_SRCS})
ADD_DEFINITIONS(-DNVMATH_EXPORTS)
IF(NVMATH_SHARED)
ADD_DEFINITIONS(-DNVMATH_SHARED=1)
ADD_LIBRARY(nvmath SHARED ${MATH_SRCS})
ELSE(NVMATH_SHARED)
ADD_LIBRARY(nvmath ${MATH_SRCS})
ENDIF(NVMATH_SHARED)
TARGET_LINK_LIBRARIES(nvmath ${LIBS} nvcore) TARGET_LINK_LIBRARIES(nvmath ${LIBS} nvcore)

@ -10,7 +10,7 @@ namespace nv
{ {
/// 64 bit color stored as BGRA. /// 64 bit color stored as BGRA.
class NVMATH_CLASS Color64 class Color64
{ {
public: public:
Color64() { } Color64() { }
@ -46,7 +46,7 @@ namespace nv
}; };
/// 32 bit color stored as BGRA. /// 32 bit color stored as BGRA.
class NVMATH_CLASS Color32 class Color32
{ {
public: public:
Color32() { } Color32() { }
@ -96,7 +96,7 @@ namespace nv
/// 16 bit 565 BGR color. /// 16 bit 565 BGR color.
struct NVMATH_CLASS Color16 struct Color16
{ {
Color16() { } Color16() { }
Color16(const Color16 & c) : u(c.u) { } Color16(const Color16 & c) : u(c.u) { }
@ -120,7 +120,7 @@ namespace nv
}; };
/// 16 bit 4444 BGRA color. /// 16 bit 4444 BGRA color.
class NVMATH_CLASS Color16_4444 class Color16_4444
{ {
public: public:
Color16_4444() { } Color16_4444() { }

@ -1,6 +1,7 @@
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com> // This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
#pragma once #pragma once
#include "nvmath.h" // NV_EPSILON
#include "Vector.h" #include "Vector.h"
#include "Plane.h" #include "Plane.h"

@ -1,8 +1,6 @@
// This code is in the public domain -- castanyo@yahoo.es // This code is in the public domain -- castanyo@yahoo.es
#pragma once #pragma once
#ifndef NV_MATH_MATRIX_H
#define NV_MATH_MATRIX_H
#include "Vector.h" #include "Vector.h"
@ -15,7 +13,7 @@ namespace nv
enum identity_t { identity }; enum identity_t { identity };
// 2x2 matrix. // 2x2 matrix.
class NVMATH_CLASS Matrix2 class Matrix2
{ {
public: public:
Matrix2(); Matrix2();
@ -55,7 +53,7 @@ namespace nv
// 3x3 matrix. // 3x3 matrix.
class NVMATH_CLASS Matrix3 class Matrix3
{ {
public: public:
Matrix3(); Matrix3();
@ -96,7 +94,7 @@ namespace nv
// 4x4 matrix. // 4x4 matrix.
class NVMATH_CLASS Matrix class Matrix
{ {
public: public:
typedef Matrix const & Arg; typedef Matrix const & Arg;
@ -150,5 +148,3 @@ namespace nv
extern Matrix inverse(const Matrix & m); extern Matrix inverse(const Matrix & m);
} // nv namespace } // nv namespace
#endif // NV_MATH_MATRIX_H

@ -1,10 +1,9 @@
// This code is in the public domain -- castanyo@yahoo.es // This code is in the public domain -- castanyo@yahoo.es
#pragma once #pragma once
#ifndef NV_MATH_MATRIX_INL
#define NV_MATH_MATRIX_INL
#include "Matrix.h" #include "Matrix.h"
#include "nvmath.h"
namespace nv namespace nv
{ {
@ -1462,6 +1461,3 @@ public:
}; };
#endif #endif
#endif // NV_MATH_MATRIX_INL

@ -1,17 +1,14 @@
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com> // This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
#pragma once #pragma once
#ifndef NV_MATH_PLANE_H
#define NV_MATH_PLANE_H
#include "nvmath.h"
#include "Vector.h" #include "Vector.h"
namespace nv namespace nv
{ {
class Matrix; class Matrix;
class NVMATH_CLASS Plane class Plane
{ {
public: public:
Plane(); Plane();
@ -38,5 +35,3 @@ namespace nv
} // nv namespace } // nv namespace
#endif // NV_MATH_PLANE_H

@ -1,6 +1,7 @@
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com> // This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
#pragma once #pragma once
#include "nvmath.h"
#include "Vector.h" // Vector3, Vector4 #include "Vector.h" // Vector3, Vector4
#if NV_USE_ALTIVEC #if NV_USE_ALTIVEC

@ -87,12 +87,12 @@ namespace nv {
return Vector3( c[0], c[1], c[2] ); return Vector3( c[0], c[1], c[2] );
} }
NV_SIMD_INLINE Vector4 toVector4() const /*NV_SIMD_INLINE Vector4 toVector4() const
{ {
NV_ALIGN_16 float c[4]; NV_ALIGN_16 float c[4];
_mm_store_ps( c, vec ); _mm_store_ps( c, vec );
return Vector4( c[0], c[1], c[2], c[3] ); return Vector4( c[0], c[1], c[2], c[3] );
} }*/
#define SSE_SPLAT( a ) ((a) | ((a) << 2) | ((a) << 4) | ((a) << 6)) #define SSE_SPLAT( a ) ((a) | ((a) << 2) | ((a) << 4) | ((a) << 6))
NV_SIMD_NATIVE SimdVector splatX() const { return SimdVector( _mm_shuffle_ps( vec, vec, SSE_SPLAT( 0 ) ) ); } NV_SIMD_NATIVE SimdVector splatX() const { return SimdVector( _mm_shuffle_ps( vec, vec, SSE_SPLAT( 0 ) ) ); }

@ -14,11 +14,11 @@ namespace nv
class Vector3; class Vector3;
class Matrix; class Matrix;
NVMATH_API float legendrePolynomial( int l, int m, float x ) NV_CONST; float legendrePolynomial( int l, int m, float x ) NV_CONST;
NVMATH_API float shBasis( int l, int m, float theta, float phi ) NV_CONST; float shBasis( int l, int m, float theta, float phi ) NV_CONST;
NVMATH_API float shBasis( int l, int m, const Vector3 & v ) NV_CONST; float shBasis( int l, int m, const Vector3 & v ) NV_CONST;
NVMATH_API float hshBasis( int l, int m, float theta, float phi ) NV_CONST; float hshBasis( int l, int m, float theta, float phi ) NV_CONST;
NVMATH_API float hshBasis( int l, int m, const Vector3 & v ) NV_CONST; float hshBasis( int l, int m, const Vector3 & v ) NV_CONST;
class Sh; class Sh;
float dot(const Sh & a, const Sh & b) NV_CONST; float dot(const Sh & a, const Sh & b) NV_CONST;
@ -395,10 +395,10 @@ namespace nv
}*/ }*/
NVMATH_API void multiply( const ShMatrix &A, const ShMatrix &B ); void multiply( const ShMatrix &A, const ShMatrix &B );
NVMATH_API void rotation( const Matrix & m ); void rotation( const Matrix & m );
NVMATH_API void rotation( int axis, float angles ); void rotation( int axis, float angles );
NVMATH_API void print(); void print();
private: private:

@ -1,14 +1,12 @@
// This code is in the public domain -- castanyo@yahoo.es // This code is in the public domain -- castanyo@yahoo.es
#pragma once #pragma once
#ifndef NV_MATH_VECTOR_H
#define NV_MATH_VECTOR_H
#include "nvmath.h" #include "nvcore/nvcore.h"
namespace nv namespace nv
{ {
class NVMATH_CLASS Vector2 class Vector2
{ {
public: public:
typedef Vector2 const & Arg; typedef Vector2 const & Arg;
@ -33,9 +31,6 @@ namespace nv
void operator*=(float s); void operator*=(float s);
void operator*=(Vector2::Arg v); void operator*=(Vector2::Arg v);
friend bool operator==(Vector2::Arg a, Vector2::Arg b);
friend bool operator!=(Vector2::Arg a, Vector2::Arg b);
union { union {
struct { struct {
float x, y; float x, y;
@ -44,7 +39,7 @@ namespace nv
}; };
}; };
class NVMATH_CLASS Vector3 class Vector3
{ {
public: public:
typedef Vector3 const & Arg; typedef Vector3 const & Arg;
@ -75,9 +70,6 @@ namespace nv
void operator*=(Vector3::Arg v); void operator*=(Vector3::Arg v);
void operator/=(Vector3::Arg v); void operator/=(Vector3::Arg v);
friend bool operator==(Vector3::Arg a, Vector3::Arg b);
friend bool operator!=(Vector3::Arg a, Vector3::Arg b);
union { union {
struct { struct {
float x, y, z; float x, y, z;
@ -86,7 +78,7 @@ namespace nv
}; };
}; };
class NVMATH_CLASS Vector4 class Vector4
{ {
public: public:
typedef Vector4 const & Arg; typedef Vector4 const & Arg;
@ -121,9 +113,6 @@ namespace nv
void operator*=(Vector4::Arg v); void operator*=(Vector4::Arg v);
void operator/=(Vector4::Arg v); void operator/=(Vector4::Arg v);
friend bool operator==(Vector4::Arg a, Vector4::Arg b);
friend bool operator!=(Vector4::Arg a, Vector4::Arg b);
union { union {
struct { struct {
float x, y, z, w; float x, y, z, w;
@ -146,4 +135,3 @@ template <typename T> T to(const nv::Vector2 & v) { NV_COMPILER_CHECK(sizeof(T)
template <typename T> T to(const nv::Vector3 & v) { NV_COMPILER_CHECK(sizeof(T) == sizeof(nv::Vector3)); return T(v.x, v.y, v.z); } template <typename T> T to(const nv::Vector3 & v) { NV_COMPILER_CHECK(sizeof(T) == sizeof(nv::Vector3)); return T(v.x, v.y, v.z); }
template <typename T> T to(const nv::Vector4 & v) { NV_COMPILER_CHECK(sizeof(T) == sizeof(nv::Vector4)); return T(v.x, v.y, v.z, v.w); } template <typename T> T to(const nv::Vector4 & v) { NV_COMPILER_CHECK(sizeof(T) == sizeof(nv::Vector4)); return T(v.x, v.y, v.z, v.w); }
#endif // NV_MATH_VECTOR_H

@ -1,26 +1,15 @@
// This code is in the public domain -- castanyo@yahoo.es // This code is in the public domain -- castanyo@yahoo.es
#pragma once #pragma once
#ifndef NV_MATH_VECTOR_INL
#define NV_MATH_VECTOR_INL
#include "Vector.h" #include "Vector.h"
#include "nvmath.h"
#include "nvcore/Utils.h" // min, max #include "nvcore/Utils.h" // min, max
#include "nvcore/Hash.h" // hash #include "nvcore/Hash.h" // hash
namespace nv namespace nv
{ {
// Helpers to convert vector types. Assume T has x,y members and 2 argument constructor.
//template <typename T> T to(Vector2::Arg v) { return T(v.x, v.y); }
// Helpers to convert vector types. Assume T has x,y,z members and 3 argument constructor.
//template <typename T> T to(Vector3::Arg v) { return T(v.x, v.y, v.z); }
// Helpers to convert vector types. Assume T has x,y,z members and 3 argument constructor.
//template <typename T> T to(Vector4::Arg v) { return T(v.x, v.y, v.z, v.w); }
// Vector2 // Vector2
inline Vector2::Vector2() {} inline Vector2::Vector2() {}
inline Vector2::Vector2(float f) : x(f), y(f) {} inline Vector2::Vector2(float f) : x(f), y(f) {}
@ -537,7 +526,8 @@ namespace nv
inline Vector3 operator/(Vector3::Arg v, float s) inline Vector3 operator/(Vector3::Arg v, float s)
{ {
return scale(v, 1.0f/s); //return scale(v, 1.0f/s);
return Vector3(v.x / s, v.y / s, v.z / s);
} }
/*inline Vector3 add_scaled(Vector3::Arg a, Vector3::Arg b, float s) /*inline Vector3 add_scaled(Vector3::Arg a, Vector3::Arg b, float s)
@ -915,5 +905,3 @@ namespace nv
#endif //NV_OS_IOS #endif //NV_OS_IOS
} // nv namespace } // nv namespace
#endif // NV_MATH_VECTOR_INL

@ -1,11 +1,13 @@
// This code is in the public domain -- castano@gmail.com // This code is in the public domain -- castano@gmail.com
#pragma once #pragma once
#ifndef NV_MATH_FTOI_H
#define NV_MATH_FTOI_H
#include "nvmath/nvmath.h" #include "nvmath/nvmath.h"
#if NV_USE_SSE
#include <xmmintrin.h>
#endif
#include <math.h> #include <math.h>
namespace nv namespace nv
@ -246,5 +248,3 @@ namespace nv
} // nv } // nv
#endif // NV_MATH_FTOI_H

@ -1,8 +1,6 @@
// This code is in the public domain -- castanyo@yahoo.es // This code is in the public domain -- castanyo@yahoo.es
#pragma once #pragma once
#ifndef NV_MATH_H
#define NV_MATH_H
#include "nvcore/nvcore.h" #include "nvcore/nvcore.h"
#include "nvcore/Debug.h" // nvDebugCheck #include "nvcore/Debug.h" // nvDebugCheck
@ -14,21 +12,6 @@
#include <float.h> // finite, isnan #include <float.h> // finite, isnan
#endif #endif
// Function linkage
#if NVMATH_SHARED
#ifdef NVMATH_EXPORTS
#define NVMATH_API DLL_EXPORT
#define NVMATH_CLASS DLL_EXPORT_CLASS
#else
#define NVMATH_API DLL_IMPORT
#define NVMATH_CLASS DLL_IMPORT
#endif
#else // NVMATH_SHARED
#define NVMATH_API
#define NVMATH_CLASS
#endif // NVMATH_SHARED
// Set some reasonable defaults. // Set some reasonable defaults.
#ifndef NV_USE_ALTIVEC #ifndef NV_USE_ALTIVEC
# define NV_USE_ALTIVEC NV_CPU_PPC # define NV_USE_ALTIVEC NV_CPU_PPC
@ -53,10 +36,6 @@
# endif # endif
#endif #endif
#if NV_USE_SSE
#include <xmmintrin.h>
#endif
// Internally set NV_USE_SIMD when either altivec or sse is available. // Internally set NV_USE_SIMD when either altivec or sse is available.
#if NV_USE_ALTIVEC && NV_USE_SSE #if NV_USE_ALTIVEC && NV_USE_SSE
# error "Cannot enable both altivec and sse!" # error "Cannot enable both altivec and sse!"
@ -331,5 +310,3 @@ namespace nv
} // nv } // nv
#endif // NV_MATH_H

Loading…
Cancel
Save