mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-28 00:54:23 +01:00
Fix vector operators to avoid needing overloads
This commit is contained in:
parent
0875ee0ddb
commit
4fc75f22dc
@ -159,41 +159,6 @@ class Pixel : public Vector4<uint16> {
|
||||
};
|
||||
REGISTER_VECTOR_TYPE(Pixel);
|
||||
|
||||
// Overload operators so that we can preserve bit depths...
|
||||
template<typename ScalarType>
|
||||
static inline Pixel ScalarMultiply(const Pixel &p, const ScalarType &s) {
|
||||
Pixel a(p);
|
||||
for(int i = 0; i < Pixel::Size; i++)
|
||||
a(i) = p(i) * s;
|
||||
return a;
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
static inline Pixel ScalarDivide(const Pixel &p, const ScalarType &s) {
|
||||
Pixel a(p);
|
||||
for(int i = 0; i < Pixel::Size; i++)
|
||||
a(i) = p(i) / s;
|
||||
return a;
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
static inline Pixel VectorAddition(const Pixel &p, const VectorType &v) {
|
||||
Pixel a(p);
|
||||
for(int i = 0; i < Pixel::Size; i++) {
|
||||
a(i) += v(i);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
static inline Pixel VectorSubtraction(const Pixel &p, const VectorType &v) {
|
||||
Pixel a(p);
|
||||
for(int i = 0; i < Pixel::Size; i++) {
|
||||
a(i) -= v(i);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
} // namespace FasTC
|
||||
|
||||
#endif // BASE_INCLUDE_PIXEL_H_
|
||||
|
@ -102,9 +102,9 @@ namespace FasTC {
|
||||
template<typename VectorTypeOne, typename VectorTypeTwo>
|
||||
static inline VectorTypeOne VectorAddition(const VectorTypeOne &v1,
|
||||
const VectorTypeTwo &v2) {
|
||||
VectorTypeOne a;
|
||||
VectorTypeOne a(v1);
|
||||
for(int i = 0; i < VectorTypeOne::Size; i++) {
|
||||
a(i) = v1(i) + v2(i);
|
||||
a(i) += v2(i);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
@ -124,9 +124,9 @@ namespace FasTC {
|
||||
template<typename VectorTypeOne, typename VectorTypeTwo>
|
||||
static inline VectorTypeOne VectorSubtraction(const VectorTypeOne &v1,
|
||||
const VectorTypeTwo &v2) {
|
||||
VectorTypeOne a;
|
||||
VectorTypeOne a(v1);
|
||||
for(int i = 0; i < VectorTypeOne::Size; i++) {
|
||||
a(i) = v1(i) - v2(i);
|
||||
a(i) -= v2(i);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
@ -204,9 +204,9 @@ namespace FasTC {
|
||||
|
||||
template<typename VectorType, typename ScalarType>
|
||||
static inline VectorType ScalarMultiply(const VectorType &v, const ScalarType &s) {
|
||||
VectorType a;
|
||||
VectorType a(v);
|
||||
for(int i = 0; i < VectorType::Size; i++)
|
||||
a(i) = static_cast<typename VectorType::ScalarType>(v(i) * s);
|
||||
a(i) *= static_cast<typename VectorType::ScalarType>(s);
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -221,9 +221,9 @@ namespace FasTC {
|
||||
|
||||
template<typename VectorType, typename ScalarType>
|
||||
static inline VectorType ScalarDivide(const VectorType &v, const ScalarType &s) {
|
||||
VectorType a;
|
||||
VectorType a(v);
|
||||
for(int i = 0; i < VectorType::Size; i++)
|
||||
a(i) = static_cast<typename VectorType::ScalarType>(v(i) / s);
|
||||
a(i) /= static_cast<typename VectorType::ScalarType>(s);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user