Panagiotis Christopoulos Charitos 13 лет назад
Родитель
Сommit
fae03a0d49

+ 2 - 1
include/anki/core/Logger.h

@@ -18,6 +18,7 @@ namespace anki {
 class Logger
 {
 public:
+	/// Logger message type
 	enum LoggerMessageType
 	{
 		LMT_NORMAL,
@@ -25,7 +26,7 @@ public:
 		LMT_WARNING
 	};
 
-	/// XXX
+	/// Used as parammeter when emitting the signal
 	struct Info
 	{
 		const char* file;

+ 7 - 7
include/anki/gl/BufferObject.h

@@ -8,7 +8,7 @@
 
 namespace anki {
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 /// @{
 	
 /// A wrapper for OpenGL buffer objects (vertex arrays, texture buffers etc)
@@ -41,7 +41,7 @@ public:
 		create(target, sizeInBytes, dataPtr, usage);
 	}
 
-	/// It deletes the BO from the GL context
+	/// It deletes the BO
 	~BufferObject();
 	/// @}
 
@@ -70,7 +70,7 @@ public:
 		ANKI_ASSERT(isCreated());
 		return sizeInBytes;
 	}
-	/// @]
+	/// @}
 
 	/// Bind BO
 	void bind() const
@@ -123,7 +123,7 @@ public:
 	/// @param[in] size The size in bytes we want to write
 	void write(void* buff, U32 offset, U32 size);
 
-	/// Map buffer
+	/// Map part of the buffer
 	void* map(U32 offset, U32 length, GLuint flags);
 
 	/// Map the entire buffer
@@ -135,8 +135,8 @@ public:
 	/// Unmap buffer
 	void unmap();
 
-	/// If created is run successfully this returns true
-	bool isCreated() const
+	/// If create() is run successfully this returns true
+	Bool isCreated() const
 	{
 		return glId != 0;
 	}
@@ -147,7 +147,7 @@ public:
 		ANKI_ASSERT(target == GL_TRANSFORM_FEEDBACK_BUFFER 
 			|| target == GL_UNIFORM_BUFFER);
 		bind();
-		ANKI_GL_CALL(glBindBufferBase(target, binding, glId));
+		glBindBufferBase(target, binding, glId);
 	}
 
 private:

+ 4 - 0
include/anki/gl/ContextNonSharable.h

@@ -7,6 +7,9 @@
 
 namespace anki {
 
+/// @addtogroup OpenGL
+/// @{
+
 /// Defines an non sharable GL object. Used to avoid idiotic mistakes and more
 /// specifically using the object from other than contexts
 class ContextNonSharable
@@ -68,6 +71,7 @@ private:
 	std::thread::id creationThreadId;
 #endif
 };
+/// @}
 
 } // end namespace anki
 

+ 1 - 1
include/anki/gl/Fbo.h

@@ -11,7 +11,7 @@ namespace anki {
 
 class Texture;
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 /// @{
 
 /// Frame buffer object. The class is actually a wrapper to avoid common 

+ 5 - 0
include/anki/gl/GlException.h

@@ -5,6 +5,9 @@
 
 namespace anki {
 
+/// @addtogroup OpenGL
+/// @{
+
 /// The function throws an exception if there is an OpenGL error. Use it with
 /// the ANKI_CHECK_GL_ERROR macro
 void glConditionalThrowException(const char* file, int line, const char* func);
@@ -16,6 +19,8 @@ void glConditionalThrowException(const char* file, int line, const char* func);
 #	define ANKI_CHECK_GL_ERROR() ((void)0)
 #endif
 
+/// @}
+
 } // end namespace
 
 #endif

+ 1 - 1
include/anki/gl/GlState.h

@@ -14,7 +14,7 @@ class Vao;
 class Fbo;
 class ShaderProgram;
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 /// @{
 
 /// Common stuff for all states

+ 0 - 5
include/anki/gl/Ogl.h

@@ -16,9 +16,4 @@
 
 #include "anki/gl/ContextNonSharable.h"
 
-#define ANKI_GL_CALL(func__) \
-	do { \
-		func__; \
-	} while(0)
-
 #endif

+ 1 - 1
include/anki/gl/Query.h

@@ -6,7 +6,7 @@
 
 namespace anki {
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 ///
 
 /// Query object

+ 1 - 1
include/anki/gl/ShaderProgram.h

@@ -18,7 +18,7 @@ class ShaderProgram;
 class ShaderProgramUniformBlock;
 class Texture;
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 /// @{
 
 /// Shader program variable. The type is attribute or uniform

+ 1 - 1
include/anki/gl/Texture.h

@@ -14,7 +14,7 @@ namespace anki {
 
 class Texture;
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 /// @{
 
 /// The absolute limit of textures

+ 1 - 2
include/anki/gl/Ubo.h

@@ -6,7 +6,7 @@
 
 namespace anki {
 
-/// @addtogroup gl
+/// @addtogroup OpenGL
 /// @{
 	
 /// Uniform buffer object
@@ -18,7 +18,6 @@ public:
 		BufferObject::create(GL_UNIFORM_BUFFER, size, data, GL_DYNAMIC_DRAW);
 	}
 };
-
 /// @}
 
 } // end namespace anki

+ 4 - 0
include/anki/gl/Vao.h

@@ -12,6 +12,9 @@ namespace anki {
 class ShaderProgramAttributeVariable;
 class Vbo;
 
+/// @addtogroup OpenGL
+/// @{
+
 /// Vertex array object. Non-copyable to avoid instantiating it in the stack
 class Vao: public NonCopyable, public ContextNonSharable
 {
@@ -172,6 +175,7 @@ private:
 		return (GLuint)x;
 	}
 };
+/// @}
 
 } // end namespace anki
 

+ 4 - 0
include/anki/gl/Vbo.h

@@ -5,6 +5,9 @@
 
 namespace anki {
 
+/// @addtogroup OpenGL
+/// @{
+
 /// This is a wrapper for Vertex Buffer Objects to prevent us from making
 /// idiotic errors
 class Vbo: public BufferObject
@@ -40,6 +43,7 @@ public:
 		BufferObject::create(target, sizeInBytes, dataPtr, usage);
 	}
 };
+/// @}
 
 } // end namespace
 

+ 2 - 2
include/anki/math/Mat4.h

@@ -39,7 +39,7 @@ public:
 	const F32& operator()(const U i, const U j) const;
 	F32& operator[](const U i);
 	const F32& operator[](const U i) const;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128& getMm(const U i);
 	const __m128& getMm(const U i) const;
 #endif
@@ -127,7 +127,7 @@ private:
 		Array<Array<F32, 4>, 4> arr2;
 		F32 carr1[16]; ///< For gdb
 		F32 carr2[4][4]; ///< For gdb
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 		Array<__m128, 4> arrMm;
 #endif
 	};

+ 23 - 23
include/anki/math/Mat4.inl.h

@@ -9,7 +9,7 @@ namespace anki {
 // Copy
 inline Mat4::Mat4(const Mat4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		arrMm[i] = b.arrMm[i];
@@ -25,7 +25,7 @@ inline Mat4::Mat4(const Mat4& b)
 // F32
 inline Mat4::Mat4(const F32 f)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		arrMm[i] = _mm_set1_ps(f);
@@ -193,7 +193,7 @@ inline const F32& Mat4::operator[](const U i) const
 	return arr1[i];
 }
 
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 inline const __m128& Mat4::getMm(const U i) const
 {
 	return arrMm[i];
@@ -212,7 +212,7 @@ inline __m128& Mat4::getMm(const U i)
 // =
 inline Mat4& Mat4::operator=(const Mat4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		arrMm[i] = b.arrMm[i];
@@ -230,7 +230,7 @@ inline Mat4& Mat4::operator=(const Mat4& b)
 inline Mat4 Mat4::operator+(const Mat4& b) const
 {
 	Mat4 c;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		c.arrMm[i] = _mm_add_ps(arrMm[i], b.arrMm[i]);
@@ -247,7 +247,7 @@ inline Mat4 Mat4::operator+(const Mat4& b) const
 // +=
 inline Mat4& Mat4::operator+=(const Mat4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		arrMm[i] = _mm_add_ps(arrMm[i], b.arrMm[i]);
@@ -265,7 +265,7 @@ inline Mat4& Mat4::operator+=(const Mat4& b)
 inline Mat4 Mat4::operator-(const Mat4& b) const
 {
 	Mat4 c;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		c.arrMm[i] = _mm_sub_ps(arrMm[i], b.arrMm[i]);
@@ -282,7 +282,7 @@ inline Mat4 Mat4::operator-(const Mat4& b) const
 // -=
 inline Mat4& Mat4::operator-=(const Mat4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	for(U i = 0; i < 4; i++)
 	{
 		arrMm[i] = _mm_sub_ps(arrMm[i], b.arrMm[i]);
@@ -300,7 +300,7 @@ inline Mat4& Mat4::operator-=(const Mat4& b)
 inline Mat4 Mat4::operator*(const Mat4& b) const
 {
 	Mat4 c;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	Mat4 t(b);
 	t.transpose();
 	for(U i = 0; i < 4; i++)
@@ -364,7 +364,7 @@ inline Bool Mat4::operator!=(const Mat4& b) const
 inline Mat4 Mat4::operator+(const F32 f) const
 {
 	Mat4 c;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -383,7 +383,7 @@ inline Mat4 Mat4::operator+(const F32 f) const
 // 4x4 += F32
 inline Mat4& Mat4::operator+=(const F32 f)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -403,7 +403,7 @@ inline Mat4& Mat4::operator+=(const F32 f)
 inline Mat4 Mat4::operator-(const F32 f) const
 {
 	Mat4 r;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -422,7 +422,7 @@ inline Mat4 Mat4::operator-(const F32 f) const
 // 4x4 -= F32
 inline Mat4& Mat4::operator-=(const F32 f)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -442,7 +442,7 @@ inline Mat4& Mat4::operator-=(const F32 f)
 inline Mat4 Mat4::operator*(const F32 f) const
 {
 	Mat4 r;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -461,7 +461,7 @@ inline Mat4 Mat4::operator*(const F32 f) const
 // 4x4 *= F32
 inline Mat4& Mat4::operator*=(const F32 f)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -481,7 +481,7 @@ inline Mat4& Mat4::operator*=(const F32 f)
 inline Mat4 Mat4::operator/(const F32 f) const
 {
 	Mat4 r;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -500,7 +500,7 @@ inline Mat4 Mat4::operator/(const F32 f) const
 // 4x4 /= F32
 inline Mat4& Mat4::operator/=(const F32 f)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -523,7 +523,7 @@ inline Mat4& Mat4::operator/=(const F32 f)
 // Mat4 * Vec4
 inline Vec4 Mat4::operator*(const Vec4& b) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	Vec4 v;
 	for(U i = 0; i < 4; i++)
 	{
@@ -557,7 +557,7 @@ inline Vec4 Mat4::operator*(const Vec4& b) const
 inline void Mat4::setRows(const Vec4& a, const Vec4& b, const Vec4& c,
 	const Vec4& d)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	arrMm[0] = a.getMm();
 	arrMm[1] = b.getMm();
 	arrMm[2] = c.getMm();
@@ -585,7 +585,7 @@ inline void Mat4::setRows(const Vec4& a, const Vec4& b, const Vec4& c,
 // setRow
 inline void Mat4::setRow(const U i, const Vec4& v)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	arrMm[i] = v.getMm();
 #else
 	(*this)(i, 0) = v.x();
@@ -641,7 +641,7 @@ inline Vec4 Mat4::getColumn(const U i) const
 // transpose
 inline void Mat4::transpose()
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	_MM_TRANSPOSE4_PS(arrMm[0], arrMm[1], arrMm[2], arrMm[3]);
 #else
 	F32 tmp = (*this)(0, 1);
@@ -939,7 +939,7 @@ inline Mat4 operator+(const F32 f, const Mat4& m4)
 inline Mat4 operator-(const F32 f, const Mat4& m4)
 {
 	Mat4 r;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)
@@ -965,7 +965,7 @@ inline Mat4 operator*(const F32 f, const Mat4& m4)
 inline Mat4 operator/(const F32 f, const Mat4& m4)
 {
 	Mat4 r;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	for(U i = 0; i < 4; i++)

+ 1 - 1
include/anki/math/Vec3.inl.h

@@ -410,7 +410,7 @@ inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
 // Mat4
 inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	Vec3 out;
 	Vec4 v4((*this), 1.0);
 	for(U i = 0; i < 3; i++)

+ 4 - 4
include/anki/math/Vec4.h

@@ -8,7 +8,7 @@ namespace anki {
 /// @addtogroup Math
 /// @{
 
-/// 4D vector. SSE optimized
+/// 4D vector. SIMD optimized
 class Vec4
 {
 public:
@@ -24,7 +24,7 @@ public:
 	explicit Vec4(const Vec3& v3, const F32 w);
 	Vec4(const Vec4& b);
 	explicit Vec4(const Quat& q);
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	explicit Vec4(const __m128& mm);
 #endif
 	/// @}
@@ -41,7 +41,7 @@ public:
 	F32 w() const;
 	F32& operator[](const U i);
 	F32 operator[](const U i) const;
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	__m128& getMm();
 	const __m128& getMm() const;
 #endif
@@ -115,7 +115,7 @@ private:
 
 		Array<F32, 4> arr;
 
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 		__m128 mm;
 #endif
 	};

+ 17 - 17
include/anki/math/Vec4.inl.h

@@ -9,7 +9,7 @@ namespace anki {
 // default
 inline Vec4::Vec4()
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_setzero_ps();
 #else
 	arr[0] = arr[1] = arr[2] = arr[3] = 0.0;
@@ -19,7 +19,7 @@ inline Vec4::Vec4()
 // F32
 inline Vec4::Vec4(F32 f)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_set1_ps(f);
 #else
 	arr[0] = arr[1] = arr[2] = arr[3] = f;
@@ -29,7 +29,7 @@ inline Vec4::Vec4(F32 f)
 // F32[]
 inline Vec4::Vec4(const F32 arr_[])
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_load_ps(arr_);
 #else
 	arr[0] = arr_[0];
@@ -43,7 +43,7 @@ inline Vec4::Vec4(const F32 arr_[])
 inline Vec4::Vec4(const F32 x_, const F32 y_, const F32 z_,
 	const F32 w_)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_set_ps(w_, z_, y_, x_);
 #else
 	x() = x_;
@@ -83,7 +83,7 @@ inline Vec4::Vec4(const Vec3& v3, const F32 w_)
 // Copy
 inline Vec4::Vec4(const Vec4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = b.mm;
 #else
 	x() = b.x();
@@ -103,7 +103,7 @@ inline Vec4::Vec4(const Quat& q)
 }
 
 // __m128
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 inline Vec4::Vec4(const __m128& mm_)
 {
 	mm = mm_;
@@ -164,7 +164,7 @@ inline F32 Vec4::w() const
 	return vec.w;
 }
 
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 inline __m128& Vec4::getMm()
 {
 	return mm;
@@ -194,7 +194,7 @@ inline Vec3 Vec4::xyz() const
 // =
 inline Vec4& Vec4::operator=(const Vec4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = b.mm;
 #else
 	x() = b.x();
@@ -208,7 +208,7 @@ inline Vec4& Vec4::operator=(const Vec4& b)
 // +
 inline Vec4 Vec4::operator+(const Vec4& b) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	return Vec4(_mm_add_ps(mm, b.mm));
 #else
 	return Vec4(x() + b.x(), y() + b.y(), z() + b.z(), w() + b.w());
@@ -218,7 +218,7 @@ inline Vec4 Vec4::operator+(const Vec4& b) const
 // +=
 inline Vec4& Vec4::operator+=(const Vec4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_add_ps(mm, b.mm);
 #else
 	x() += b.x();
@@ -232,7 +232,7 @@ inline Vec4& Vec4::operator+=(const Vec4& b)
 // -
 inline Vec4 Vec4::operator-(const Vec4& b) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	return Vec4(_mm_sub_ps(mm, b.mm));
 #else
 	return Vec4(x() - b.x(), y() - b.y(), z() - b.z(), w() - b.w());
@@ -242,7 +242,7 @@ inline Vec4 Vec4::operator-(const Vec4& b) const
 // -=
 inline Vec4& Vec4::operator-=(const Vec4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_sub_ps(mm, b.mm);
 #else
 	x() -= b.x();
@@ -256,7 +256,7 @@ inline Vec4& Vec4::operator-=(const Vec4& b)
 // *
 inline Vec4 Vec4::operator*(const Vec4& b) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	return Vec4(_mm_mul_ps(mm, b.mm));
 #else
 	return Vec4(x() * b.x(), y() * b.y(), z() * b.z(), w() * b.w());
@@ -266,7 +266,7 @@ inline Vec4 Vec4::operator*(const Vec4& b) const
 // *=
 inline Vec4& Vec4::operator*=(const Vec4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_mul_ps(mm, b.mm);
 #else
 	x() *= b.x();
@@ -280,7 +280,7 @@ inline Vec4& Vec4::operator*=(const Vec4& b)
 // /
 inline Vec4 Vec4::operator/(const Vec4& b) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	return Vec4(_mm_div_ps(mm, b.mm));
 #else
 	return Vec4(x() / b.x(), y() / b.y(), z() / b.z(), w() / b.w());
@@ -290,7 +290,7 @@ inline Vec4 Vec4::operator/(const Vec4& b) const
 // /=
 inline Vec4& Vec4::operator/=(const Vec4& b)
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	mm = _mm_div_ps(mm, b.mm);
 #else
 	x() /= b.x();
@@ -412,7 +412,7 @@ inline Vec4 Vec4::operator*(const Mat4& m4) const
 // dot
 inline F32 Vec4::dot(const Vec4& b) const
 {
-#if defined(ANKI_MATH_SIMD_SSE)
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
 	F32 o;
 	_mm_store_ss(&o, _mm_dp_ps(mm, b.mm, 0xF1));
 	return o;

+ 11 - 7
include/anki/util/Array.h

@@ -1,5 +1,5 @@
-#ifndef ANKI_UTIL_ARRAY_H
-#define ANKI_UTIL_ARRAY_H
+#ifndef ANKI_PtrSizeTIL_ARRAY_H
+#define ANKI_PtrSizeTIL_ARRAY_H
 
 #include "anki/util/Assert.h"
 #include "anki/util/StdTypes.h"
@@ -9,8 +9,8 @@ namespace anki {
 /// @addtogroup util
 /// @{
 
-/// Array
-template<typename T, U N>
+/// Like std::array but with some additions
+template<typename T, PtrSize N>
 struct Array
 {
 	typedef T Value;
@@ -21,39 +21,43 @@ struct Array
 
 	Value data[N];
 
-	Reference operator[](U n)
+	Reference operator[](const PtrSize n)
 	{
 		ANKI_ASSERT(n < N);
 		return data[n];
 	}
 
-	ConstReference operator[](U n) const
+	ConstReference operator[](const PtrSize n) const
 	{
 		ANKI_ASSERT(n < N);
 		return data[n];
 	}
 
+	/// Make it compatible with the C++11 range based for loop
 	Iterator begin()
 	{
 		return &data[0];
 	}
 
+	/// Make it compatible with the C++11 range based for loop
 	ConstIterator begin() const
 	{
 		return &data[0];
 	}
 
+	/// Make it compatible with the C++11 range based for loop
 	Iterator end()
 	{
 		return &data[0] + N;
 	}
 
+	/// Make it compatible with the C++11 range based for loop
 	ConstIterator end() const
 	{
 		return &data[0] + N;
 	}
 
-	static constexpr U getSize()
+	static constexpr PtrSize getSize()
 	{
 		return N;
 	}

+ 17 - 6
include/anki/util/Exception.h

@@ -2,6 +2,7 @@
 #define ANKI_UTIL_EXCEPTION_H
 
 #include "anki/Config.h"
+#include "anki/util/StdTypes.h"
 #include <exception>
 #include <string>
 
@@ -15,8 +16,12 @@ class Exception: public std::exception
 {
 public:
 	/// Constructor
-	Exception(const char* error, const char* file = "unknown",
-		int line = -1, const char* func = "unknown");
+	explicit Exception(const char* error, const char* file = "unknown",
+		I line = -1, const char* func = "unknown");
+
+	/// Constructor 2
+	explicit Exception(const std::string& error, const char* file = "unknown",
+		I line = -1, const char* func = "unknown");
 
 	/// Copy constructor
 	Exception(const Exception& e);
@@ -26,6 +31,12 @@ public:
 	{}
 
 	/// For re-throws
+	/// Usage:
+	/// @code
+	/// catch(std::exception& e) {
+	/// 	throw Exception("message", ...) << e;
+	/// }
+	/// @endcode
 	Exception operator<<(const std::exception& e) const;
 
 	/// Implements std::exception::what()
@@ -39,13 +50,13 @@ private:
 
 	/// Synthesize the error string
 	static std::string synthErr(const char* error, const char* file,
-		int line, const char* func);
+		I line, const char* func);
 };
 
-} // end namespace
+} // end namespace anki
 
 /// Macro for easy throwing
-#define ANKI_EXCEPTION(x) Exception((std::string() + x).c_str(), \
-	ANKI_FILE, __LINE__, ANKI_FUNC)
+#define ANKI_EXCEPTION(x) \
+	Exception(std::string() + x, ANKI_FILE, __LINE__, ANKI_FUNC)
 
 #endif

+ 1 - 1
include/anki/util/Observer.h

@@ -108,6 +108,6 @@ private:
 	(_sender)->_signal.addNewObserver( new \
 		RemovePointer<decltype(_receiver)>::Type::Observing_##_slot(_receiver))
 
-} // namespace anki
+} // end namespace anki
 
 #endif

+ 47 - 0
shaders/MsCommon.tc.glsl

@@ -0,0 +1,47 @@
+layout(vertices = 3) out;
+
+// Varyings in
+in vec3 vPosition[];
+in vec2 vTexCoords;
+in vec3 vNormal[];
+in vec3 vTangent[];
+in float vTangentW[];
+
+// Varyings out
+out vec3 tcPosition[];
+out vec2 tcTexCoords;
+out vec3 tcNormal[];
+out vec3 tcTangent[];
+out float tcTangentW[];
+
+#define tessellate_DEFINED
+void tessellate(in float tessLevelInner, in float tessLevelOuter)
+{
+	if(gl_InvocationID == 0) 
+	{
+		gl_TessLevelInner[0] = tessLevelInner;
+		gl_TessLevelOuter[0] = tessLevelOuter;
+		gl_TessLevelOuter[1] = tessLevelOuter;
+		gl_TessLevelOuter[2] = tessLevelOuter;
+	}
+}
+
+#define tessellatePosition_DEFINED
+void tessellatePosition()
+{
+	tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
+}
+
+#define tessellateTexCoords_DEFINED
+void tessellateTexCoords()
+{
+	tcTexCoords[gl_InvocationID] = vTexCoords[gl_InvocationID];
+}
+
+#define tessellatieNormalTangent_DEFINED
+void tessellatieNormalTangent()
+{
+	tcNormal[gl_InvocationID] = vNormal[gl_InvocationID];
+	tcTangent[gl_InvocationID] = vTangent[gl_InvocationID];
+	tcTangentW[gl_InvocationID] = vTangentW[gl_InvocationID];
+}

+ 0 - 328
shaders/MsMpGeneric.glsl

@@ -1,328 +0,0 @@
-/// @file
-/// 
-/// This a generic shader to fill the deferred shading buffers. You can always 
-/// build your own if you dont need to write in all the buffers
-/// 
-/// Control defines:
-/// DIFFUSE_MAPPING, NORMAL_MAPPING, SPECULAR_MAPPING, PARALLAX_MAPPING, 
-/// ENVIRONMENT_MAPPING, ALPHA_TESTING
- 
-#if defined(ALPHA_TESTING) && !defined(DIFFUSE_MAPPING)
-#	error "Cannot have ALPHA_TESTING without DIFFUSE_MAPPING"
-#endif
- 
-#if defined(DIFFUSE_MAPPING) || defined(NORMAL_MAPPING) || defined(SPECULAR_MAPPING)
-#	define NEEDS_TEX_MAPPING 1
-#else
-#	define NEEDS_TEX_MAPPING 0
-#endif
-
-
-#if defined(NORMAL_MAPPING) || defined(PARALLAX_MAPPING)
-	#define NEEDS_TANGENT 1
-#else
-	#define NEEDS_TANGENT 0
-#endif
-
-
-#pragma anki start vertexShader
-
-/// @name Attributes
-/// @{
-in vec3 position;
-in vec3 normal;
-#if NEEDS_TEX_MAPPING
-	in vec2 texCoords;
-#endif
-#if NEEDS_TANGENT
-	in vec4 tangent;
-#endif
-/// @}
-
-/// @name Uniforms
-/// @{
-uniform mat4 modelMat;
-uniform mat4 viewMat;
-uniform mat4 projectionMat;
-uniform mat4 modelViewMat;
-uniform mat3 normalMat;
-uniform mat4 modelViewProjectionMat;
-/// @}
-
-/// @name Varyings
-/// @{
-out vec3 vNormal;
-out vec2 vTexCoords;
-out vec3 vTangent;
-out float vTangentW;
-out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
-/// @}
-
-
-
-//==============================================================================
-// main                                                                        =
-//==============================================================================
-void main()
-{
-	// calculate the vert pos, normal and tangent
-	vNormal = normalMat * normal;
-
-	gl_Position = modelViewProjectionMat * vec4(position, 1.0);
-
-	// calculate the rest
-
-#if NEEDS_TEX_MAPPING
-	vTexCoords = texCoords;
-#endif
-
-#if NEEDS_TANGENT
-	vTangent = normalMat * vec3(tangent);
-	vTangentW = tangent.w;
-#endif
-
-#if defined(ENVIRONMENT_MAPPING) || defined(PARALLAX_MAPPING)
-	vVertPosViewSpace = vec3(modelViewMat * vec4(position, 1.0));
-#endif
-}
-
-
-#pragma anki start fragmentShader
-
-/// @note The process of calculating the diffuse color for the diffuse MSFAI is 
-/// divided into two parts. The first happens before the normal calculation and 
-/// the other just after it. In the first part we read the texture (or the 
-/// gl_Color) and we set the _diffColl_. In case of grass we discard. In the 
-/// second part we calculate a SEM color and we combine it with the _diffColl_. 
-/// We cannot put the second part before normal calculation because SEM needs
-/// the _normal_. Also we cannot put the first part after normal calculation 
-/// because in case of grass we will waste calculations for the normal. For 
-/// that two reasons we split the diffuse calculations in two parts
-
-#pragma anki include "shaders/Pack.glsl"
-
-
-#if defined(DIFFUSE_MAPPING)
-uniform sampler2D diffuseMap;
-#endif
-#if defined(NORMAL_MAPPING)
-uniform sampler2D normalMap;
-#endif
-#if defined(SPECULAR_MAPPING)
-uniform sampler2D specularMap;
-#endif
-#if defined(PARALLAX_MAPPING)
-uniform sampler2D heightMap;
-#endif
-#if defined(ENVIRONMENT_MAPPING)
-uniform sampler2D environmentMap;
-#endif
-uniform float shininess = 50.0;
-uniform vec3 diffuseCol = vec3(1.0, 0.0, 1.0);
-uniform vec3 specularCol = vec3(1.0, 0.0, 1.0);
-#if defined(ALPHA_TESTING)
-/// Below this value the pixels are getting discarded 
-uniform float alphaTestingTolerance = 0.5; 
-#endif
-uniform float blurring = 0.0;
-
-in vec3 vNormal;
-in vec3 vTangent;
-in float vTangentW;
-in vec2 vTexCoords;
-in vec3 vVertPosViewSpace;
-// @todo 
-in vec3 eye;
-
-layout(location = 0) out vec3 fMsNormalFai;
-layout(location = 1) out vec3 fMsDiffuseFai;
-layout(location = 2) out vec4 fMsSpecularFai;
-
-const float MAX_SHININESS = 128.0;
-
-
-//==============================================================================
-// Normal funcs                                                                =
-//==============================================================================
-/// @param[in] normal The fragment's normal in view space
-/// @param[in] tangent The tangent
-/// @param[in] tangent Extra stuff for the tangent
-/// @param[in] map The map
-/// @param[in] texCoords Texture coordinates
-vec3 getNormalUsingMap(in vec3 normal, in vec3 tangent, in float tangentW, 
-	in sampler2D map, in vec2 texCoords)
-{
-	vec3 n = normalize(normal);
-	vec3 t = normalize(tangent);
-	vec3 b = cross(n, t) * tangentW;
-
-	mat3 tbnMat = mat3(t, b, n);
-
-	vec3 nAtTangentspace = (texture2D(map, texCoords).rgb - 0.5) * 2.0;
-
-	return normalize(tbnMat * nAtTangentspace);
-}
-
-/// Just normalize
-vec3 getNormalSimple(in vec3 normal)
-{
-	return normalize(normal);
-}
-
-
-//==============================================================================
-// doEnvMapping                                                                =
-//==============================================================================
-/// Environment mapping calculations
-/// @param[in] vertPosViewSpace Fragment position in view space
-/// @param[in] normal Fragment's normal in view space as well
-/// @param[in] map The env map
-/// @return The color
-vec3 doEnvMapping(in vec3 vertPosViewSpace, in vec3 normal, in sampler2D map)
-{
-	// In case of normal mapping I could play with vertex's normal but this 
-	// gives better results and its allready computed
-	
-	vec3 u = normalize(vertPosViewSpace);
-	vec3 r = reflect(u, normal);
-	r.z += 1.0;
-	float m = 2.0 * length(r);
-	vec2 semTexCoords = r.xy / m + 0.5;
-
-	vec3 semCol = texture2D(map, semTexCoords).rgb;
-	return semCol;
-}
-
-
-//==============================================================================
-// doAlpha                                                                     =
-//==============================================================================
-/// Using a 4-channel texture and a tolerance discard the fragment if the 
-/// texture's alpha is less than the tolerance
-/// @param[in] map The diffuse map
-/// @param[in] tolerance Tolerance value
-/// @param[in] texCoords Texture coordinates
-/// @return The RGB channels of the map
-vec3 doAlpha(in sampler2D map, in float tolerance, in vec2 texCoords)
-{
-	vec4 col = texture2D(map, texCoords);
-	if(col.a < tolerance)
-	{
-		discard;
-	}
-	return col.rgb;
-}
-
-
-//==============================================================================
-// main                                                                        =
-//==============================================================================
-void main()
-{
-	//
-	// Paralax Mapping Calculations
-	// The code below reads the height map, makes some calculations and returns 
-	// a new texCoords
-	//
-#if defined(PARALLAX_MAPPING)
-	/*const float _scale = 0.04;
-	const float _bias = scale * 0.4;
-
-	vec3 _norm_eye = normalize(eye);
-
-	float _h = texture2D(heightMap, vTexCoords).r;
-	float _height = _scale * _h - _bias;
-
-	vec2 _superTexCoords__v2f = _height * _norm_eye.xy + vTexCoords;*/
-
-	vec2 _superTexCoords_ = vTexCoords;
-	const float maxStepCount = 100.0;
-	float nSteps = maxStepCount * length(_superTexCoords_);
-
-	vec3 dir = vVertPosViewSpace;
-	dir.xy /= 8.0;
-	dir /= -nSteps * dir.z;
-
-	float diff0, diff1 = 1.0 - texture2D(heightMap, _superTexCoords_).a;
-	if(diff1 > 0.0)
-	{
-		do 
-		{
-			_superTexCoords_ += dir.xy;
-
-			diff0 = diff1;
-			diff1 = texture2D(heightMap, _superTexCoords_).w;
-		} while(diff1 > 0.0);
-
-		_superTexCoords_.xy += (diff1 / (diff0 - diff1)) * dir.xy;
-	}
-#else
-#	define _superTexCoords_ vTexCoords
-#endif
-
-
-	//
-	// Diffuse Calculations (Part I)
-	// Get the color from the diffuse map and discard if alpha testing is on 
-	// and alpha is zero
-	//
-	vec3 _diffColl_;
-#if defined(DIFFUSE_MAPPING)
-
-#	if defined(ALPHA_TESTING)
-	_diffColl_ = doAlpha(diffuseMap, alphaTestingTolerance, _superTexCoords_);
-#	else // no alpha
-	_diffColl_ = texture2D(diffuseMap, _superTexCoords_).rgb;
-#	endif
-
-	_diffColl_ *= diffuseCol.rgb;
-#else // no diff mapping
-	_diffColl_ = diffuseCol.rgb;
-#endif
-
-
-	//
-	// Normal Calculations
-	// Either use a normap map and make some calculations or use the vertex 
-	// normal
-	//
-#if defined(NORMAL_MAPPING)
-	vec3 _normal_ = getNormalUsingMap(vNormal, vTangent, vTangentW, 
-		normalMap, _superTexCoords_);
-#else
-	vec3 _normal_ = getNormalSimple(vNormal);
-#endif
-
-
-	//
-	// Diffuse Calculations (Part II)
-	// If SEM is enabled make some calculations (using the vVertPosViewSpace, 
-	// environmentMap and the _normal_) and
-	// combine colors of SEM and the _diffColl_
-	//
-#if defined(ENVIRONMENT_MAPPING)
-	// blend existing color with the SEM texture map
-	_diffColl_ += doEnvMapping(vVertPosViewSpace, _normal_, environmentMap); 
-#endif
-
-
-	//
-	// Specular Calculations
-	//
-#if defined(SPECULAR_MAPPING)
-	vec4 _specularCol_ = vec4(
-		texture2D(specularMap, _superTexCoords_).rgb * specularCol,
-		shininess / MAX_SHININESS);
-#else // no specular map
-	vec4 _specularCol_ = vec4(specularCol, shininess / MAX_SHININESS);
-#endif
-
-
-	//
-	// Final Stage. Write all data
-	//
-	fMsNormalFai = vec3(packNormal(_normal_), blurring);
-	fMsDiffuseFai = _diffColl_;
-	fMsSpecularFai = _specularCol_;
-}
-

+ 0 - 58
shaders/MsMpSkybox.glsl

@@ -1,58 +0,0 @@
-#pragma anki vertShaderBegins
-
-in vec3 position;
-in vec2 texCoords;
-
-uniform mat4 viewProjectionMat;
-uniform mat4 viewMat;
-
-out vec2 vTexCoords;
-
-void main()
-{
-	vTexCoords = texCoords;
-	
-	mat4 modelMat = viewMat;
-	modelMat[3] = modelMat[7] = modelMat[11] = 0.0; // clear the translation part. We want only the rotation part
-	
-	gl_Position = viewProjectionMat * (modelMat * vec4(position, 1.0));
-}
-
-#pragma anki fragShaderBegins
-
-uniform sampler2D colorMap;
-uniform sampler2D noiseMap;
-uniform float timer = 0.0;
-uniform vec3 sceneAmbientCol;
-
-in vec2 vTexCoords;
-
-layout(location = 1) out vec3 fMsDiffuseFai;
-
-#define PI 3.14159265358979323846
-
-
-void main()
-{
-	float scaledTimer = timer * 0.4;
-
-	vec2 displacement = vTexCoords - vec2(scaledTimer);
-
-	vec3 noiseVec = normalize(texture2D(noisemap, displacement).xyz);
-	noiseVec = (noiseVec * 2.0 - 1.0);
-	
-	/*
-	 * edgeFactor is a value that varies from 1.0 to 0.0 and then again to 1.0. Its zero in the edge of the skybox quad
-	 * and one in the middle of the quad. We use it in order to reduse the distortion at the polygon edges because of
-	 * artifacts with the neighbor polygons
-	 */
-	float edgeFactor = sin(vTexCoords.s * PI) * sin(vTexCoords.t * PI);
-
-	const float strengthFactor = 0.015;
-
-	noiseVec = noiseVec * strengthFactor * edgeFactor;
-
-	// write to the diffuse buffer
-	fMsDiffuseFai = texture2D(colormap, vTexCoords + noiseVec.xy).rgb * sceneAmbientCol;
-}
-

+ 15 - 3
src/util/Exception.cpp

@@ -9,7 +9,7 @@ namespace anki {
 
 //==============================================================================
 Exception::Exception(const char* error, const char* file,
-	int line, const char* func)
+	I line, const char* func)
 {
 	err = synthErr(error, file, line, func);
 
@@ -19,6 +19,18 @@ Exception::Exception(const char* error, const char* file,
 #endif
 }
 
+//==============================================================================
+Exception::Exception(const std::string& error, const char* file,
+	I line, const char* func)
+{
+	err = synthErr(error.c_str(), file, line, func);
+
+#if ANKI_ABORT_ON_THROW
+	std::cerr << err << std::endl;
+	abort();
+#endif
+}
+
 //==============================================================================
 Exception::Exception(const Exception& e)
 	: err(e.err)
@@ -31,7 +43,7 @@ Exception::Exception(const Exception& e)
 
 //==============================================================================
 std::string Exception::synthErr(const char* error, const char* file,
-	int line, const char* func)
+	I line, const char* func)
 {
 	std::stringstream ss;
 	ss << "(" << file << ':' << line << ' ' << func << ") " << error;
@@ -47,4 +59,4 @@ Exception Exception::operator<<(const std::exception& e) const
 	return out;
 }
 
-} // end namespace
+} // end namespace anki