Upgrade CMP Core.
This commit is contained in:
4
extern/CMP_Core/source/CMP_Core.h
vendored
4
extern/CMP_Core/source/CMP_Core.h
vendored
@ -1,5 +1,5 @@
|
||||
//=====================================================================
|
||||
// Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files(the "Software"), to deal
|
||||
@ -19,7 +19,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
/// \file CMP_Core.h
|
||||
/// \file CMP_Core.h CPU User Interface
|
||||
//
|
||||
//=====================================================================
|
||||
|
||||
|
143
extern/CMP_Core/source/cmp_math_func.h
vendored
Normal file
143
extern/CMP_Core/source/cmp_math_func.h
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
//=====================================================================
|
||||
// Copyright 2020 (c), Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//=====================================================================
|
||||
#ifndef CMP_MATH_FUNC_H
|
||||
#define CMP_MATH_FUNC_H
|
||||
|
||||
|
||||
#include "Common_Def.h"
|
||||
|
||||
#ifndef ASPM_GPU
|
||||
|
||||
//============================================================================
|
||||
// Core API which have have GPU equivalents, defined here for HPC_CPU usage
|
||||
//============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
static CGU_INT QSortFCmp(const void *Elem1, const void *Elem2) {
|
||||
CGU_INT ret = 0;
|
||||
|
||||
if (*(CGU_FLOAT *)Elem1 - *(CGU_FLOAT *)Elem2 < 0.)
|
||||
ret = -1;
|
||||
else if (*(CGU_FLOAT *)Elem1 - *(CGU_FLOAT *)Elem2 > 0.)
|
||||
ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int QSortIntCmp(const void *Elem1, const void *Elem2)
|
||||
{
|
||||
return (*(CGU_INT32 *)Elem1 - *(CGU_INT32 *)Elem2);
|
||||
}
|
||||
|
||||
static CGU_FLOAT dot(CMP_IN CGU_Vec3f Color,CMP_IN CGU_Vec3f Color2)
|
||||
{
|
||||
CGU_FLOAT ColorDot;
|
||||
ColorDot = (Color.x * Color2.x) + (Color.y * Color2.y) + (Color.z * Color2.z);
|
||||
return ColorDot;
|
||||
}
|
||||
|
||||
static CGU_FLOAT dot(CMP_IN CGU_Vec2f Color,CMP_IN CGU_Vec2f Color2)
|
||||
{
|
||||
CGU_FLOAT ColorDot;
|
||||
ColorDot = Color.x * Color2.x + Color.y * Color2.y;
|
||||
return ColorDot;
|
||||
}
|
||||
|
||||
static CGU_Vec2f abs(CMP_IN CGU_Vec2f Color)
|
||||
{
|
||||
CGU_Vec2f ColorAbs;
|
||||
ColorAbs.x = std::abs(Color.x);
|
||||
ColorAbs.y = std::abs(Color.y);
|
||||
return ColorAbs;
|
||||
}
|
||||
|
||||
static CGU_Vec3f fabs(CMP_IN CGU_Vec3f Color)
|
||||
{
|
||||
CGU_Vec3f ColorAbs;
|
||||
ColorAbs.x = std::abs(Color.x);
|
||||
ColorAbs.y = std::abs(Color.y);
|
||||
ColorAbs.z = std::abs(Color.z);
|
||||
return ColorAbs;
|
||||
}
|
||||
|
||||
static CGU_Vec3f round(CMP_IN CGU_Vec3f Color)
|
||||
{
|
||||
CGU_Vec3f ColorRound;
|
||||
ColorRound.x = std::round(Color.x);
|
||||
ColorRound.y = std::round(Color.y);
|
||||
ColorRound.z = std::round(Color.z);
|
||||
return ColorRound;
|
||||
}
|
||||
|
||||
static CGU_Vec2f round(CMP_IN CGU_Vec2f Color)
|
||||
{
|
||||
CGU_Vec2f ColorRound;
|
||||
ColorRound.x = std::round(Color.x);
|
||||
ColorRound.y = std::round(Color.y);
|
||||
return ColorRound;
|
||||
}
|
||||
|
||||
static CGU_Vec3f ceil(CMP_IN CGU_Vec3f Color)
|
||||
{
|
||||
CGU_Vec3f ColorCeil;
|
||||
ColorCeil.x = std::ceil(Color.x);
|
||||
ColorCeil.y = std::ceil(Color.y);
|
||||
ColorCeil.z = std::ceil(Color.z);
|
||||
return ColorCeil;
|
||||
}
|
||||
|
||||
static CGU_Vec3f floor(CMP_IN CGU_Vec3f Color)
|
||||
{
|
||||
CGU_Vec3f Colorfloor;
|
||||
Colorfloor.x = std::floor(Color.x);
|
||||
Colorfloor.y = std::floor(Color.y);
|
||||
Colorfloor.z = std::floor(Color.z);
|
||||
return Colorfloor;
|
||||
}
|
||||
|
||||
static CGU_Vec3f saturate(CGU_Vec3f value)
|
||||
{
|
||||
if (value.x > 1.0f) value.x = 1.0f;
|
||||
else
|
||||
if (value.x < 0.0f) value.x = 0.0f;
|
||||
|
||||
if (value.y > 1.0f) value.y = 1.0f;
|
||||
else
|
||||
if (value.y < 0.0f) value.y = 0.0f;
|
||||
|
||||
if (value.z > 1.0f) value.z = 1.0f;
|
||||
else
|
||||
if (value.z < 0.0f) value.z = 0.0f;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
// Core API which are shared between GPU & CPU
|
||||
//============================================================================
|
||||
|
||||
#endif // Header Guard
|
||||
|
52
extern/CMP_Core/source/cmp_math_vec4.h
vendored
52
extern/CMP_Core/source/cmp_math_vec4.h
vendored
@ -30,14 +30,16 @@
|
||||
#if defined (_LINUX) || defined (_WIN32)
|
||||
|
||||
//============================================= VEC2 ==================================================
|
||||
template <class T> class vec3;
|
||||
|
||||
template<class T>
|
||||
class Vec2
|
||||
{
|
||||
public:
|
||||
|
||||
T x;
|
||||
T y;
|
||||
|
||||
|
||||
// *****************************************
|
||||
// Constructors
|
||||
// *****************************************
|
||||
@ -54,7 +56,6 @@ public:
|
||||
/// Single value constructor. Sets all components to the given value
|
||||
Vec2(const T& v) : x(v), y(v) {};
|
||||
|
||||
|
||||
// *****************************************
|
||||
// Conversions/Assignment/Indexing
|
||||
// *****************************************
|
||||
@ -92,6 +93,13 @@ public:
|
||||
/// Subtraction
|
||||
const Vec2<T> operator-(const Vec2<T>& rhs) const { return Vec2<T>(x - rhs.x, y - rhs.y); };
|
||||
|
||||
/// Multiply
|
||||
const Vec2<T> operator*(const Vec2<T>& rhs) const { return Vec2<T>(x * rhs.x, y * rhs.y); };
|
||||
|
||||
/// Divide
|
||||
const Vec2<T> operator/(const Vec2<T>& rhs) const { return Vec2<T>(x / rhs.x, y / rhs.y); };
|
||||
|
||||
|
||||
/// Multiply by scalar
|
||||
const Vec2<T> operator*(const T& v) const { return Vec2<T>(x * v, y * v); };
|
||||
|
||||
@ -113,11 +121,12 @@ public:
|
||||
|
||||
};
|
||||
|
||||
typedef Vec2<float> CMP_Vec2f;
|
||||
typedef Vec2<float> CGU_Vec2f;
|
||||
typedef Vec2<float> CGV_Vec2f;
|
||||
typedef Vec2<double> CMP_Vec2d;
|
||||
typedef Vec2<int> CMP_Vec2i;
|
||||
typedef Vec2<float> CMP_Vec2f;
|
||||
typedef Vec2<float> CGU_Vec2f;
|
||||
typedef Vec2<float> CGV_Vec2f;
|
||||
typedef Vec2<double> CMP_Vec2d;
|
||||
typedef Vec2<int> CMP_Vec2i;
|
||||
typedef Vec2<unsigned int> CGU_Vec2ui;
|
||||
|
||||
//}
|
||||
|
||||
@ -134,6 +143,7 @@ public:
|
||||
T y;
|
||||
T z;
|
||||
|
||||
|
||||
// *****************************************
|
||||
// Constructors
|
||||
// *****************************************
|
||||
@ -180,21 +190,24 @@ public:
|
||||
// Arithmetic
|
||||
// *****************************************
|
||||
|
||||
/// Addition
|
||||
/// Addition by vector
|
||||
const Vec3<T> operator+(const Vec3<T>& rhs) const { return Vec3<T>(x + rhs.x, y + rhs.y, z + rhs.z); };
|
||||
|
||||
/// Subtraction
|
||||
/// Subtraction by vector
|
||||
const Vec3<T> operator-(const Vec3<T>& rhs) const { return Vec3<T>(x - rhs.x, y - rhs.y, z - rhs.z); };
|
||||
|
||||
/// Multiply by vector
|
||||
const Vec3<T> operator*(const Vec3<T>& rhs) const { return Vec3<T>(x * rhs.x, y * rhs.y, z * rhs.z); };
|
||||
|
||||
/// Divide by vector
|
||||
const Vec3<T> operator/(const Vec3<T>& rhs) const { return Vec3<T>(x / rhs.x, y / rhs.y, z / rhs.z); };
|
||||
|
||||
/// Multiply by scalar
|
||||
const Vec3<T> operator*(const T& v) const { return Vec3<T>(x * v, y * v, z * v); };
|
||||
|
||||
/// Divide by scalar
|
||||
const Vec3<T> operator/(const T& v) const { return Vec3<T>(x / v, y / v, z / v); };
|
||||
|
||||
/// Divide by vector
|
||||
const Vec3<T> operator/(const Vec3<T>& rhs) const { return Vec3<T>(x / rhs.x, y / rhs.y, z / rhs.z); };
|
||||
|
||||
/// Addition in-place
|
||||
Vec3<T>& operator+= (const Vec3<T>& rhs) { x += rhs.x; y += rhs.y; z += rhs.z; return *this; };
|
||||
|
||||
@ -208,6 +221,7 @@ public:
|
||||
Vec3<T>& operator/= (const T& v) { x /= v; y /= v; z /= v; return *this; };
|
||||
};
|
||||
|
||||
typedef Vec3<bool> CGU_Vec3bool;
|
||||
typedef Vec3<float> CGU_Vec3f;
|
||||
typedef Vec3<float> CGV_Vec3f;
|
||||
typedef Vec3<unsigned char> CGU_Vec3uc;
|
||||
@ -217,6 +231,7 @@ typedef Vec3<float> CMP_Vec3f;
|
||||
typedef Vec3<double> CMP_Vec3d;
|
||||
typedef Vec3<int> CMP_Vec3i;
|
||||
typedef Vec3<unsigned char> CMP_Vec3uc;
|
||||
typedef Vec3<unsigned int> CMP_Vec3ui;
|
||||
|
||||
//============================================= VEC4 ==================================================
|
||||
template<class T>
|
||||
@ -275,21 +290,24 @@ public:
|
||||
// Arithmetic
|
||||
// *****************************************
|
||||
|
||||
/// Addition
|
||||
/// Addition by vector
|
||||
const Vec4<T> operator+(const Vec4<T>& rhs) const { return Vec4<T>(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w); };
|
||||
|
||||
/// Subtraction
|
||||
/// Subtraction by vector
|
||||
const Vec4<T> operator-(const Vec4<T>& rhs) const { return Vec4<T>(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w); };
|
||||
|
||||
/// Multiply by vector
|
||||
const Vec4<T> operator*(const Vec4<T>& rhs) const { return Vec4<T>(x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w); };
|
||||
|
||||
/// Divide by vector
|
||||
const Vec4<T> operator/(const Vec4<T>& rhs) const { return Vec4<T>(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w); };
|
||||
|
||||
/// Multiply by scalar
|
||||
const Vec4<T> operator*(const T& v) const { return Vec4<T>(x * v, y * v, z * v, w * v); };
|
||||
|
||||
/// Divide by scalar
|
||||
const Vec4<T> operator/(const T& v) const { return Vec4<T>(x / v, y / v, z / v, w / v); };
|
||||
|
||||
/// Divide by vector
|
||||
const Vec4<T> operator/(const Vec4<T>& rhs) const { return Vec4<T>(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w); };
|
||||
|
||||
/// Addition in-place
|
||||
Vec4<T>& operator+= (const Vec4<T>& rhs) { x += rhs.x; y += rhs.y; z += rhs.z; w += rhs.w; return *this; };
|
||||
|
||||
|
Reference in New Issue
Block a user