mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
Simplify map structure tracker overloads
Due to less branching, this is actually faster than trying to be clever. git-svn-id: https://svn.eduke32.com/eduke32@7690 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
dd2e35eab3
commit
0556fe1738
6 changed files with 91 additions and 183 deletions
|
@ -368,8 +368,6 @@
|
|||
<ClInclude Include="..\..\source\build\include\softsurface.h" />
|
||||
<ClInclude Include="..\..\source\build\include\texcache.h" />
|
||||
<ClInclude Include="..\..\source\build\include\tracker.hpp" />
|
||||
<ClInclude Include="..\..\source\build\include\tracker_operator.hpp" />
|
||||
<ClInclude Include="..\..\source\build\include\tracker_operators.hpp" />
|
||||
<ClInclude Include="..\..\source\build\include\vfs.h" />
|
||||
<ClInclude Include="..\..\source\build\include\winbits.h" />
|
||||
<ClInclude Include="..\..\source\build\include\winlayer.h" />
|
||||
|
|
|
@ -370,12 +370,6 @@
|
|||
<ClInclude Include="..\..\source\build\include\tracker.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\source\build\include\tracker_operator.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\source\build\include\tracker_operators.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\source\build\include\winbits.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -285,23 +285,23 @@ static FORCE_INLINE void wall_tracker_hook(uintptr_t address);
|
|||
static FORCE_INLINE void sprite_tracker_hook(uintptr_t address);
|
||||
}
|
||||
|
||||
#define TRACKER_NAME_ SectorTracker
|
||||
#define TRACKER_GLOBAL_HOOK_ sector_tracker_hook
|
||||
#define TRACKER_NAME__ SectorTracker
|
||||
#define TRACKER_HOOK_ sector_tracker_hook
|
||||
#include "tracker.hpp"
|
||||
#undef TRACKER_NAME_
|
||||
#undef TRACKER_GLOBAL_HOOK_
|
||||
#undef TRACKER_NAME__
|
||||
#undef TRACKER_HOOK_
|
||||
|
||||
#define TRACKER_NAME_ WallTracker
|
||||
#define TRACKER_GLOBAL_HOOK_ wall_tracker_hook
|
||||
#define TRACKER_NAME__ WallTracker
|
||||
#define TRACKER_HOOK_ wall_tracker_hook
|
||||
#include "tracker.hpp"
|
||||
#undef TRACKER_NAME_
|
||||
#undef TRACKER_GLOBAL_HOOK_
|
||||
#undef TRACKER_NAME__
|
||||
#undef TRACKER_HOOK_
|
||||
|
||||
#define TRACKER_NAME_ SpriteTracker
|
||||
#define TRACKER_GLOBAL_HOOK_ sprite_tracker_hook
|
||||
#define TRACKER_NAME__ SpriteTracker
|
||||
#define TRACKER_HOOK_ sprite_tracker_hook
|
||||
#include "tracker.hpp"
|
||||
#undef TRACKER_NAME_
|
||||
#undef TRACKER_GLOBAL_HOOK_
|
||||
#undef TRACKER_NAME__
|
||||
#undef TRACKER_HOOK_
|
||||
|
||||
#define Tracker(Container, Type) Container##Tracker<Type>
|
||||
#define TrackerCast(x) x.cast()
|
||||
|
|
|
@ -1,109 +1,109 @@
|
|||
|
||||
|
||||
template<typename TrackedType>
|
||||
class TRACKER_NAME_
|
||||
template<typename T>
|
||||
class TRACKER_NAME__
|
||||
{
|
||||
public:
|
||||
TrackedType TrackedValue;
|
||||
T value;
|
||||
|
||||
inline TrackedType* operator & ()
|
||||
inline T *operator&()
|
||||
{
|
||||
TRACKER_GLOBAL_HOOK_((uintptr_t)&this->TrackedValue);
|
||||
return &this->TrackedValue;
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return &this->value;
|
||||
}
|
||||
|
||||
inline TrackedType operator ++ ()
|
||||
inline T operator++()
|
||||
{
|
||||
TRACKER_GLOBAL_HOOK_((uintptr_t)&this->TrackedValue);
|
||||
return ++this->TrackedValue;
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return ++this->value;
|
||||
}
|
||||
|
||||
inline TrackedType operator ++ (int)
|
||||
inline T operator++(int)
|
||||
{
|
||||
TRACKER_GLOBAL_HOOK_((uintptr_t)&this->TrackedValue);
|
||||
return this->TrackedValue++;
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value++;
|
||||
}
|
||||
|
||||
inline TrackedType operator -- ()
|
||||
inline T operator--()
|
||||
{
|
||||
TRACKER_GLOBAL_HOOK_((uintptr_t)&this->TrackedValue);
|
||||
return --this->TrackedValue;
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return --this->value;
|
||||
}
|
||||
|
||||
inline TrackedType operator -- (int)
|
||||
inline T operator--(int)
|
||||
{
|
||||
TRACKER_GLOBAL_HOOK_((uintptr_t)&this->TrackedValue);
|
||||
return this->TrackedValue--;
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value--;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator = (RightHandType);
|
||||
template <typename Tt> inline T operator=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value = (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator += (RightHandType);
|
||||
template <typename Tt> inline T operator+=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value += (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator -= (RightHandType);
|
||||
template <typename Tt> inline T operator-=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value -= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator *= (RightHandType);
|
||||
template <typename Tt> inline T operator*=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value *= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator /= (RightHandType);
|
||||
template <typename Tt> inline T operator/=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value /= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator |= (RightHandType);
|
||||
template <typename Tt> inline T operator|=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value |= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator &= (RightHandType);
|
||||
template <typename Tt> inline T operator&=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value &= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator ^= (RightHandType);
|
||||
template <typename Tt> inline T operator^=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value ^= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator <<= (RightHandType);
|
||||
template <typename Tt> inline T operator<<=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value <<= (T)operand;
|
||||
}
|
||||
|
||||
template <typename RightHandType>
|
||||
inline TrackedType operator >>= (RightHandType);
|
||||
template <typename Tt> inline T operator>>=(Tt operand)
|
||||
{
|
||||
TRACKER_HOOK_((uintptr_t) & this->value);
|
||||
return this->value >>= (T)operand;
|
||||
}
|
||||
|
||||
inline operator TrackedType() const;
|
||||
inline operator T() const { return this->value; }
|
||||
|
||||
inline TrackedType cast() const;
|
||||
};
|
||||
|
||||
#ifndef tracker_hpp_
|
||||
#define tracker_hpp_
|
||||
|
||||
enum {
|
||||
TRACKER_NOOP_RIGHTHAND_EQUAL_ = 0,
|
||||
TRACKER_NOOP_RIGHTHAND_ZERO_,
|
||||
TRACKER_NOOP_RIGHTHAND_ONE_,
|
||||
__TRACKER_NEVER,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include "tracker_operators.hpp"
|
||||
|
||||
template<typename TrackedType>
|
||||
inline TRACKER_NAME_<TrackedType>::operator TrackedType() const
|
||||
{
|
||||
return this->TrackedValue;
|
||||
}
|
||||
|
||||
template<typename TrackedType>
|
||||
inline TrackedType TRACKER_NAME_<TrackedType>::cast() const
|
||||
{
|
||||
return this->TrackedValue;
|
||||
}
|
||||
|
||||
template <typename TrackedType>
|
||||
struct is_signed<TRACKER_NAME_<TrackedType>>
|
||||
{
|
||||
static constexpr bool value = std::is_signed<TrackedType>::value;
|
||||
};
|
||||
template <typename TrackedType>
|
||||
struct is_unsigned<TRACKER_NAME_<TrackedType>>
|
||||
{
|
||||
static constexpr bool value = std::is_unsigned<TrackedType>::value;
|
||||
inline T cast() const { return this->value; }
|
||||
|
||||
struct is_signed
|
||||
{
|
||||
static constexpr bool value = std::is_signed<T>::value;
|
||||
};
|
||||
struct is_unsigned
|
||||
{
|
||||
static constexpr bool value = std::is_unsigned<T>::value;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
template <typename TrackedType>
|
||||
template <typename RightHandType>
|
||||
inline TrackedType TRACKER_NAME_<TrackedType>::operator TRACKER_OPERATOR_ (RightHandType rightHand)
|
||||
{
|
||||
bool isNoop = false;
|
||||
|
||||
switch (TRACKER_NOOP_)
|
||||
{
|
||||
case TRACKER_NOOP_RIGHTHAND_EQUAL_: isNoop = (this->TrackedValue == (TrackedType)rightHand); break;
|
||||
case TRACKER_NOOP_RIGHTHAND_ZERO_: isNoop = (rightHand == 0); break;
|
||||
case TRACKER_NOOP_RIGHTHAND_ONE_: isNoop = (rightHand == 1);
|
||||
fallthrough__;
|
||||
// case __TRACKER_NEVER:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isNoop)
|
||||
{
|
||||
TRACKER_GLOBAL_HOOK_((uintptr_t) & this->TrackedValue);
|
||||
return this->TrackedValue TRACKER_OPERATOR_ (TrackedType)rightHand;
|
||||
}
|
||||
else return this->TrackedValue;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#define TRACKER_OPERATOR_ =
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_EQUAL_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ +=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ZERO_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ -=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ZERO_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ *=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ONE_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ /=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ONE_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ |=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ZERO_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ &=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_EQUAL_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ ^=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ZERO_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ <<=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ZERO_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
||||
|
||||
#define TRACKER_OPERATOR_ >>=
|
||||
#define TRACKER_NOOP_ TRACKER_NOOP_RIGHTHAND_ZERO_
|
||||
#include "tracker_operator.hpp"
|
||||
#undef TRACKER_OPERATOR_
|
||||
#undef TRACKER_NOOP_
|
Loading…
Reference in a new issue