mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-01 01:25:38 +03:00
Merge pull request #286 from dreamstalker/asmlib_update
Use SSE for some typical floating point operations
This commit is contained in:
commit
c787546bef
@ -154,6 +154,9 @@ extern int loadsize;
|
||||
#define Q_atoi atoi
|
||||
#define Q_atof atof
|
||||
#define Q_sqrt M_sqrt
|
||||
#define Q_min M_min
|
||||
#define Q_max M_max
|
||||
#define Q_clamp M_clamp
|
||||
//#define Q_strtoull strtoull
|
||||
//#define Q_FileNameCmp FileNameCmp
|
||||
#define Q_vsnprintf _vsnprintf
|
||||
@ -182,6 +185,9 @@ extern int loadsize;
|
||||
#define Q_atoi atoi
|
||||
#define Q_atof atof
|
||||
#define Q_sqrt sqrt
|
||||
#define Q_min min
|
||||
#define Q_max max
|
||||
#define Q_clamp clamp
|
||||
//#define Q_strtoull strtoull
|
||||
//#define Q_FileNameCmp FileNameCmp
|
||||
#define Q_vsnprintf _vsnprintf
|
||||
|
@ -477,9 +477,9 @@ void SV_DropClient_internal(client_t *cl, qboolean crash, const char *string)
|
||||
MSG_WriteByte(&cl->netchan.message, svc_disconnect);
|
||||
MSG_WriteString(&cl->netchan.message, string);
|
||||
final[0] = svc_disconnect;
|
||||
Q_strncpy((char *)&final[1], string, min(sizeof(final) - 1, Q_strlen(string) + 1));
|
||||
Q_strncpy((char *)&final[1], string, Q_min(sizeof(final) - 1, Q_strlen(string) + 1));
|
||||
final[sizeof(final) - 1] = 0;
|
||||
i = 1 + min(sizeof(final) - 1, Q_strlen(string) + 1);
|
||||
i = 1 + Q_min(sizeof(final) - 1, Q_strlen(string) + 1);
|
||||
}
|
||||
if (cl->edict && cl->spawned)
|
||||
gEntityInterface.pfnClientDisconnect(cl->edict);
|
||||
|
@ -56,24 +56,57 @@ static const int nanmask = 0x7F800000;
|
||||
|
||||
#define IS_NAN(fvar) ((*reinterpret_cast<int*>(&(fvar)) & nanmask) == nanmask)
|
||||
|
||||
inline double M_sqrt(int value) {
|
||||
return sqrt(value);
|
||||
}
|
||||
|
||||
inline float M_sqrt(float value) {
|
||||
return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value)));
|
||||
}
|
||||
|
||||
inline double M_sqrt(double value) {
|
||||
double ret;
|
||||
auto v = _mm_load_sd(&value);
|
||||
_mm_store_sd(&ret, _mm_sqrt_sd(v, v));
|
||||
return ret;
|
||||
return _mm_cvtsd_f64(_mm_sqrt_sd(v, v));
|
||||
}
|
||||
|
||||
inline double M_sqrt(long double value)
|
||||
{
|
||||
return M_sqrt(double(value));
|
||||
template<typename T>
|
||||
inline double M_sqrt(T value) {
|
||||
return sqrt(value);
|
||||
}
|
||||
|
||||
inline float M_min(float a, float b) {
|
||||
return _mm_cvtss_f32(_mm_min_ss(_mm_load_ss(&a), _mm_load_ss(&b)));
|
||||
}
|
||||
|
||||
inline double M_min(double a, double b) {
|
||||
return _mm_cvtsd_f64(_mm_min_sd(_mm_load_sd(&a), _mm_load_sd(&b)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T M_min(T a, T b) {
|
||||
return min(a, b);
|
||||
}
|
||||
|
||||
inline float M_max(float a, float b) {
|
||||
return _mm_cvtss_f32(_mm_max_ss(_mm_load_ss(&a), _mm_load_ss(&b)));
|
||||
}
|
||||
|
||||
inline double M_max(double a, double b) {
|
||||
return _mm_cvtsd_f64(_mm_max_sd(_mm_load_sd(&a), _mm_load_sd(&b)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T M_max(T a, T b) {
|
||||
return max(a, b);
|
||||
}
|
||||
|
||||
inline float M_clamp(float a, float min, float max) {
|
||||
return _mm_cvtss_f32(_mm_min_ss(_mm_max_ss(_mm_load_ss(&a), _mm_load_ss(&min)), _mm_load_ss(&max)));
|
||||
}
|
||||
|
||||
inline double M_clamp(double a, double min, double max) {
|
||||
return _mm_cvtsd_f64(_mm_min_sd(_mm_max_sd(_mm_load_sd(&a), _mm_load_sd(&min)), _mm_load_sd(&max)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T M_clamp(T a, T min, T max) {
|
||||
return clamp(a, min, max);
|
||||
}
|
||||
|
||||
float anglemod(float a);
|
||||
|
@ -1360,7 +1360,7 @@ int NET_SendLong(netsrc_t sock, int s, const char *buf, int len, int flags, cons
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
size = min(int(SPLIT_SIZE), len);
|
||||
size = Q_min(int(SPLIT_SIZE), len);
|
||||
|
||||
pPacket->packetID = (packetNumber << 4) + packetCount;
|
||||
|
||||
|
@ -883,7 +883,7 @@ qboolean SV_CheckSphereIntersection(edict_t *ent, const vec_t *start, const vec_
|
||||
pseqdesc += ent->v.sequence;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
maxDim[i] = max(fabs(pseqdesc->bbmax[i]), fabs(pseqdesc->bbmin[i]));
|
||||
maxDim[i] = Q_max(fabs(pseqdesc->bbmax[i]), fabs(pseqdesc->bbmin[i]));
|
||||
}
|
||||
radiusSquared = maxDim[0] * maxDim[0] + maxDim[1] * maxDim[1] + maxDim[2] * maxDim[2];
|
||||
return DoesSphereIntersect(ent->v.origin, radiusSquared, traceOrg, traceDir) != 0;
|
||||
|
@ -719,7 +719,7 @@ void SV_StartParticle(const vec_t *org, const vec_t *dir, int color, int count)
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
MSG_WriteChar(&g_psv.datagram, clamp((int)(dir[i] * 16.0f), -128, 127));
|
||||
MSG_WriteChar(&g_psv.datagram, Q_clamp((int)(dir[i] * 16.0f), -128, 127));
|
||||
}
|
||||
|
||||
MSG_WriteByte(&g_psv.datagram, count);
|
||||
@ -1771,7 +1771,7 @@ int SV_GetFragmentSize(void *state)
|
||||
if (val[0] != 0)
|
||||
{
|
||||
size = Q_atoi( val );
|
||||
size = clamp(size, FRAGMENT_S2C_MIN_SIZE, FRAGMENT_S2C_MAX_SIZE);
|
||||
size = Q_clamp(size, FRAGMENT_S2C_MIN_SIZE, FRAGMENT_S2C_MAX_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4937,7 +4937,7 @@ void SV_ExtractFromUserinfo(client_t *cl)
|
||||
if (val[0] != 0)
|
||||
{
|
||||
i = Q_atoi(val);
|
||||
cl->netchan.rate = clamp(float(i), MIN_RATE, MAX_RATE);
|
||||
cl->netchan.rate = Q_clamp(float(i), MIN_RATE, MAX_RATE);
|
||||
}
|
||||
|
||||
val = Info_ValueForKey(userinfo, "topcolor");
|
||||
|
@ -1119,7 +1119,7 @@ int CUtlRBTree<T, I>::Depth( I node ) const
|
||||
|
||||
int depthright = Depth( RightChild(node) );
|
||||
int depthleft = Depth( LeftChild(node) );
|
||||
return max(depthright, depthleft) + 1;
|
||||
return Q_max(depthright, depthleft) + 1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user