Added experimental files
This commit is contained in:
4
experimental/half/half.cpp
Normal file
4
experimental/half/half.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "precompiled.h"
|
||||
#include "half.h"
|
||||
|
||||
|
||||
119
experimental/half/half.h
Normal file
119
experimental/half/half.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef __HALF_H__
|
||||
#define __HALF_H__
|
||||
|
||||
namespace dev
|
||||
{
|
||||
/* namespace detail
|
||||
{
|
||||
class _halfGTX;
|
||||
|
||||
struct hdata
|
||||
{
|
||||
hdata() : data(0) {}
|
||||
hdata(const hdata& value);
|
||||
//hdata(float value);
|
||||
|
||||
hdata& operator=(_halfGTX s);
|
||||
hdata& operator=(float s);
|
||||
hdata& operator=(double s);
|
||||
|
||||
//operator float();
|
||||
//operator const float() const;
|
||||
|
||||
short data;
|
||||
};
|
||||
|
||||
float _toFloat32(hdata value);
|
||||
hdata _toFloat16(float value);
|
||||
|
||||
union uif
|
||||
{
|
||||
int i;
|
||||
float f;
|
||||
};
|
||||
|
||||
class _halfGTX
|
||||
{
|
||||
public:
|
||||
// Constructors
|
||||
_halfGTX();
|
||||
_halfGTX(float s);
|
||||
_halfGTX(double s);
|
||||
_halfGTX(int s);
|
||||
_halfGTX(bool s);
|
||||
_halfGTX(detail::hdata value) :
|
||||
data(value)
|
||||
{}
|
||||
|
||||
operator float() const;
|
||||
operator double() const;
|
||||
operator int() const;
|
||||
operator detail::hdata() const;
|
||||
|
||||
// Operators
|
||||
_halfGTX& operator=(_halfGTX s);
|
||||
_halfGTX& operator=(float s);
|
||||
_halfGTX operator+ (_halfGTX s) const;
|
||||
_halfGTX& operator+= (_halfGTX s);
|
||||
_halfGTX operator+ (float s) const;
|
||||
_halfGTX& operator+= (float s);
|
||||
_halfGTX operator- (_halfGTX s) const;
|
||||
_halfGTX& operator-= (_halfGTX s);
|
||||
_halfGTX operator- (float s) const;
|
||||
_halfGTX& operator-= (float s);
|
||||
_halfGTX operator* (_halfGTX s) const;
|
||||
_halfGTX& operator*= (_halfGTX s);
|
||||
_halfGTX operator* (float s) const;
|
||||
_halfGTX& operator*= (float s);
|
||||
_halfGTX operator/ (_halfGTX s) const;
|
||||
_halfGTX& operator/= (_halfGTX s);
|
||||
_halfGTX operator/ (float s) const;
|
||||
_halfGTX& operator/= (float s);
|
||||
_halfGTX operator- () const;
|
||||
_halfGTX operator++ ();
|
||||
_halfGTX operator++ (int n) const;
|
||||
_halfGTX operator-- ();
|
||||
_halfGTX operator-- (int n) const;
|
||||
|
||||
bool operator< (const _halfGTX& s) const;
|
||||
bool operator> (const _halfGTX& s) const;
|
||||
bool operator<=(const _halfGTX& s) const;
|
||||
bool operator>=(const _halfGTX& s) const;
|
||||
bool operator==(const _halfGTX& s) const;
|
||||
bool operator!=(const _halfGTX& s) const;
|
||||
|
||||
detail::hdata _data() const{return data;}
|
||||
|
||||
private:
|
||||
detail::hdata data;
|
||||
};
|
||||
|
||||
class _hvec2GTX
|
||||
{
|
||||
public:
|
||||
typedef _halfGTX value_type;
|
||||
typedef int size_type;
|
||||
static const size_type value_size;
|
||||
|
||||
union
|
||||
{
|
||||
struct{detail::hdata x, y;};
|
||||
struct{detail::hdata r, g;};
|
||||
struct{detail::hdata s, t;};
|
||||
};
|
||||
|
||||
_hvec2GTX()
|
||||
{}
|
||||
|
||||
_hvec2GTX(const _halfGTX x, const _halfGTX y) :
|
||||
x(x._data()),
|
||||
y(y._data())
|
||||
{}
|
||||
};
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//#include "half.inl"
|
||||
|
||||
#endif//__HALF_H__
|
||||
0
experimental/half/half.inl
Normal file
0
experimental/half/half.inl
Normal file
39
experimental/half/half_test.cpp
Normal file
39
experimental/half/half_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "precompiled.h"
|
||||
#include "half_test.h"
|
||||
#include "half.h"
|
||||
|
||||
void test_hdata()
|
||||
{
|
||||
//dev::detail::hdata HdataA(dev::detail::_toFloat16(1.0f));
|
||||
//dev::detail::hdata HdataB(dev::detail::_toFloat16(2.0f));
|
||||
//float FloatA = float(dev::detail::_toFloat32(HdataA) + dev::detail::_toFloat32(HdataB));
|
||||
//float FloatB = _toFloat32(HdataA) + _toFloat32(HdataB);
|
||||
//float FloatC = _toFloat32(HdataA);
|
||||
//float FloatD = _toFloat32(HdataB);
|
||||
|
||||
//dev::detail::_halfGTX HalfA(HdataA);
|
||||
//dev::detail::_halfGTX HalfB(HdataB);
|
||||
//float FloatE = float(HalfA);
|
||||
//float FloatF = float(HalfB);
|
||||
//dev::detail::_halfGTX HalfC(FloatE);
|
||||
//dev::detail::_halfGTX HalfD(FloatF);
|
||||
//float FloatG = float(HalfC);
|
||||
//float FloatH = float(HalfD);
|
||||
|
||||
//dev::detail::_hvec2GTX hvec2A(HalfA, HalfB);
|
||||
//dev::detail::_hvec2GTX hvec2B(HalfC, HalfD);
|
||||
|
||||
//HdataA = HalfA;
|
||||
//HdataB = 4.0f;
|
||||
//HdataB = 4.0;
|
||||
|
||||
//float FloatI = float(dev::detail::_halfGTX(HdataA));
|
||||
//float FloatJ = float(dev::detail::_halfGTX(HdataB));
|
||||
|
||||
int end = 0;
|
||||
}
|
||||
|
||||
void test_half_full()
|
||||
{
|
||||
test_hdata();
|
||||
}
|
||||
6
experimental/half/half_test.h
Normal file
6
experimental/half/half_test.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __HALF_TEST_H__
|
||||
#define __HALF_TEST_H__
|
||||
|
||||
void test_half_full();
|
||||
|
||||
#endif//__HALF_TEST_H__
|
||||
Reference in New Issue
Block a user