engine: optimize traces
This commit is contained in:
parent
0235b1ed4d
commit
8acf608b4d
@ -873,9 +873,9 @@ bool IntersectRayWithBoxBrush( TraceInfo_t *pTraceInfo, const cbrush_t *pBrush,
|
|||||||
FPExceptionDisabler hideExceptions;
|
FPExceptionDisabler hideExceptions;
|
||||||
|
|
||||||
// Load the unaligned ray/box parameters into SIMD registers
|
// Load the unaligned ray/box parameters into SIMD registers
|
||||||
fltx4 start = LoadUnaligned3SIMD(pTraceInfo->m_start.Base());
|
fltx4 start = LoadAlignedSIMD(pTraceInfo->m_start.Base());
|
||||||
fltx4 extents = LoadUnaligned3SIMD(pTraceInfo->m_extents.Base());
|
fltx4 extents = LoadAlignedSIMD(pTraceInfo->m_extents.Base());
|
||||||
fltx4 delta = LoadUnaligned3SIMD(pTraceInfo->m_delta.Base());
|
fltx4 delta = LoadAlignedSIMD(pTraceInfo->m_delta.Base());
|
||||||
fltx4 boxMins = LoadAlignedSIMD( pBox->mins.Base() );
|
fltx4 boxMins = LoadAlignedSIMD( pBox->mins.Base() );
|
||||||
fltx4 boxMaxs = LoadAlignedSIMD( pBox->maxs.Base() );
|
fltx4 boxMaxs = LoadAlignedSIMD( pBox->maxs.Base() );
|
||||||
|
|
||||||
@ -899,7 +899,7 @@ bool IntersectRayWithBoxBrush( TraceInfo_t *pTraceInfo, const cbrush_t *pBrush,
|
|||||||
|
|
||||||
fltx4 crossPlane = OrSIMD(XorSIMD(startOutMins,endOutMins), XorSIMD(startOutMaxs,endOutMaxs));
|
fltx4 crossPlane = OrSIMD(XorSIMD(startOutMins,endOutMins), XorSIMD(startOutMaxs,endOutMaxs));
|
||||||
// now build the per-axis interval of t for intersections
|
// now build the per-axis interval of t for intersections
|
||||||
fltx4 invDelta = LoadUnaligned3SIMD(pTraceInfo->m_invDelta.Base());
|
fltx4 invDelta = LoadAlignedSIMD(pTraceInfo->m_invDelta.Base());
|
||||||
fltx4 tmins = MulSIMD( offsetMinsExpanded, invDelta );
|
fltx4 tmins = MulSIMD( offsetMinsExpanded, invDelta );
|
||||||
fltx4 tmaxs = MulSIMD( offsetMaxsExpanded, invDelta );
|
fltx4 tmaxs = MulSIMD( offsetMaxsExpanded, invDelta );
|
||||||
// now sort the interval per axis
|
// now sort the interval per axis
|
||||||
@ -1037,9 +1037,9 @@ bool IntersectRayWithBox( const Ray_t &ray, const VectorAligned &inInvDelta, con
|
|||||||
pTrace->fraction = 1.0f;
|
pTrace->fraction = 1.0f;
|
||||||
|
|
||||||
// Load the unaligned ray/box parameters into SIMD registers
|
// Load the unaligned ray/box parameters into SIMD registers
|
||||||
fltx4 start = LoadUnaligned3SIMD(ray.m_Start.Base());
|
fltx4 start = LoadAlignedSIMD(ray.m_Start.Base());
|
||||||
fltx4 extents = LoadUnaligned3SIMD(ray.m_Extents.Base());
|
fltx4 extents = LoadAlignedSIMD(ray.m_Extents.Base());
|
||||||
fltx4 delta = LoadUnaligned3SIMD(ray.m_Delta.Base());
|
fltx4 delta = LoadAlignedSIMD(ray.m_Delta.Base());
|
||||||
fltx4 boxMins = LoadAlignedSIMD( inBoxMins.Base() );
|
fltx4 boxMins = LoadAlignedSIMD( inBoxMins.Base() );
|
||||||
fltx4 boxMaxs = LoadAlignedSIMD( inBoxMaxs.Base() );
|
fltx4 boxMaxs = LoadAlignedSIMD( inBoxMaxs.Base() );
|
||||||
|
|
||||||
@ -1372,9 +1372,9 @@ void FASTCALL CM_ClipBoxToBrush( TraceInfo_t * RESTRICT pTraceInfo, const cbrush
|
|||||||
|
|
||||||
inline bool IsTraceBoxIntersectingBoxBrush( TraceInfo_t *pTraceInfo, cboxbrush_t *pBox )
|
inline bool IsTraceBoxIntersectingBoxBrush( TraceInfo_t *pTraceInfo, cboxbrush_t *pBox )
|
||||||
{
|
{
|
||||||
fltx4 start = LoadUnaligned3SIMD(pTraceInfo->m_start.Base());
|
fltx4 start = LoadAlignedSIMD(pTraceInfo->m_start.Base());
|
||||||
fltx4 mins = LoadUnaligned3SIMD(pTraceInfo->m_mins.Base());
|
fltx4 mins = LoadAlignedSIMD(pTraceInfo->m_mins.Base());
|
||||||
fltx4 maxs = LoadUnaligned3SIMD(pTraceInfo->m_maxs.Base());
|
fltx4 maxs = LoadAlignedSIMD(pTraceInfo->m_maxs.Base());
|
||||||
|
|
||||||
fltx4 boxMins = LoadAlignedSIMD( pBox->mins.Base() );
|
fltx4 boxMins = LoadAlignedSIMD( pBox->mins.Base() );
|
||||||
fltx4 boxMaxs = LoadAlignedSIMD( pBox->maxs.Base() );
|
fltx4 boxMaxs = LoadAlignedSIMD( pBox->maxs.Base() );
|
||||||
@ -1569,15 +1569,15 @@ void FASTCALL CM_TraceToLeaf( TraceInfo_t * RESTRICT pTraceInfo, int ndxLeaf, fl
|
|||||||
if (IsX360())
|
if (IsX360())
|
||||||
{
|
{
|
||||||
// set up some relatively constant variables we'll use in the loop below
|
// set up some relatively constant variables we'll use in the loop below
|
||||||
fltx4 traceStart = LoadUnaligned3SIMD(pTraceInfo->m_start.Base());
|
fltx4 traceStart = LoadAlignedSIMD(pTraceInfo->m_start.Base());
|
||||||
fltx4 traceDelta = LoadUnaligned3SIMD(pTraceInfo->m_delta.Base());
|
fltx4 traceDelta = LoadAlignedSIMD(pTraceInfo->m_delta.Base());
|
||||||
fltx4 traceInvDelta = LoadUnaligned3SIMD(pTraceInfo->m_invDelta.Base());
|
fltx4 traceInvDelta = LoadAlignedSIMD(pTraceInfo->m_invDelta.Base());
|
||||||
static const fltx4 vecEpsilon = {DISPCOLL_DIST_EPSILON,DISPCOLL_DIST_EPSILON,DISPCOLL_DIST_EPSILON,DISPCOLL_DIST_EPSILON};
|
static const fltx4 vecEpsilon = {DISPCOLL_DIST_EPSILON,DISPCOLL_DIST_EPSILON,DISPCOLL_DIST_EPSILON,DISPCOLL_DIST_EPSILON};
|
||||||
// only used in !IS_POINT version:
|
// only used in !IS_POINT version:
|
||||||
fltx4 extents;
|
fltx4 extents;
|
||||||
if (!IS_POINT)
|
if (!IS_POINT)
|
||||||
{
|
{
|
||||||
extents = LoadUnaligned3SIMD(pTraceInfo->m_extents.Base());
|
extents = LoadAlignedSIMD(pTraceInfo->m_extents.Base());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this loop probably ought to be unrolled so that we can make a more efficient
|
// TODO: this loop probably ought to be unrolled so that we can make a more efficient
|
||||||
|
@ -42,13 +42,13 @@ struct TraceInfo_t
|
|||||||
m_nCheckDepth = -1;
|
m_nCheckDepth = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector m_start;
|
VectorAligned m_start;
|
||||||
Vector m_end;
|
VectorAligned m_end;
|
||||||
Vector m_mins;
|
VectorAligned m_mins;
|
||||||
Vector m_maxs;
|
VectorAligned m_maxs;
|
||||||
Vector m_extents;
|
VectorAligned m_extents;
|
||||||
Vector m_delta;
|
VectorAligned m_delta;
|
||||||
Vector m_invDelta;
|
VectorAligned m_invDelta;
|
||||||
|
|
||||||
trace_t m_trace;
|
trace_t m_trace;
|
||||||
trace_t m_stabTrace;
|
trace_t m_stabTrace;
|
||||||
|
@ -4934,7 +4934,7 @@ static bool EnumerateLeafInBox_R(mnode_t * RESTRICT node, const EnumLeafBoxInfo_
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// take advantage of high throughput/high latency
|
// take advantage of high throughput/high latency
|
||||||
fltx4 planeNormal = LoadUnaligned3SIMD( plane->normal.Base() );
|
fltx4 planeNormal = LoadAlignedSIMD( plane->normal.Base() );
|
||||||
fltx4 vecBoxMin = LoadAlignedSIMD(pInfo->m_vecBoxMin);
|
fltx4 vecBoxMin = LoadAlignedSIMD(pInfo->m_vecBoxMin);
|
||||||
fltx4 vecBoxMax = LoadAlignedSIMD(pInfo->m_vecBoxMax);
|
fltx4 vecBoxMax = LoadAlignedSIMD(pInfo->m_vecBoxMax);
|
||||||
fltx4 cornermin, cornermax;
|
fltx4 cornermin, cornermax;
|
||||||
|
@ -987,7 +987,7 @@ private:
|
|||||||
int m_iTree;
|
int m_iTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
class CIntersectPoint : public CPartitionVisitor
|
class CIntersectPoint : public CPartitionVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -1009,7 +1009,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
fltx4 m_f4Point;
|
fltx4 m_f4Point;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
class CIntersectBox : public CPartitionVisitor
|
class CIntersectBox : public CPartitionVisitor
|
||||||
{
|
{
|
||||||
@ -1040,8 +1040,8 @@ class CIntersectRay : public CPartitionVisitor
|
|||||||
public:
|
public:
|
||||||
CIntersectRay( CVoxelTree *pPartition, const Ray_t &ray, const Vector &vecInvDelta ) : CPartitionVisitor( pPartition )
|
CIntersectRay( CVoxelTree *pPartition, const Ray_t &ray, const Vector &vecInvDelta ) : CPartitionVisitor( pPartition )
|
||||||
{
|
{
|
||||||
m_f4Start = LoadUnaligned3SIMD( ray.m_Start.Base() );
|
m_f4Start = LoadAlignedSIMD( ray.m_Start.Base() );
|
||||||
m_f4Delta = LoadUnaligned3SIMD( ray.m_Delta.Base() );
|
m_f4Delta = LoadAlignedSIMD( ray.m_Delta.Base() );
|
||||||
m_f4InvDelta = LoadUnaligned3SIMD( vecInvDelta.Base() );
|
m_f4InvDelta = LoadUnaligned3SIMD( vecInvDelta.Base() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1069,10 +1069,10 @@ class CIntersectSweptBox : public CPartitionVisitor
|
|||||||
public:
|
public:
|
||||||
CIntersectSweptBox( CVoxelTree *pPartition, const Ray_t &ray, const Vector &vecInvDelta ) : CPartitionVisitor( pPartition )
|
CIntersectSweptBox( CVoxelTree *pPartition, const Ray_t &ray, const Vector &vecInvDelta ) : CPartitionVisitor( pPartition )
|
||||||
{
|
{
|
||||||
m_f4Start = LoadUnaligned3SIMD( ray.m_Start.Base() );
|
m_f4Start = LoadAlignedSIMD( ray.m_Start.Base() );
|
||||||
m_f4Delta = LoadUnaligned3SIMD( ray.m_Delta.Base() );
|
m_f4Delta = LoadAlignedSIMD( ray.m_Delta.Base() );
|
||||||
|
m_f4Extents = LoadAlignedSIMD( ray.m_Extents.Base() );
|
||||||
m_f4InvDelta = LoadUnaligned3SIMD( vecInvDelta.Base() );
|
m_f4InvDelta = LoadUnaligned3SIMD( vecInvDelta.Base() );
|
||||||
m_f4Extents = LoadUnaligned3SIMD( ray.m_Extents.Base() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersects( const float *pMins, const float *pMaxs ) const
|
bool Intersects( const float *pMins, const float *pMaxs ) const
|
||||||
|
@ -114,7 +114,7 @@ inline T clamp( T const &val, T const &minVal, T const &maxVal )
|
|||||||
// FIXME: this should move to a different file
|
// FIXME: this should move to a different file
|
||||||
struct cplane_t
|
struct cplane_t
|
||||||
{
|
{
|
||||||
Vector normal;
|
VectorAligned normal;
|
||||||
float dist;
|
float dist;
|
||||||
byte type; // for fast side tests
|
byte type; // for fast side tests
|
||||||
byte signbits; // signx + (signy<<1) + (signz<<1)
|
byte signbits; // signx + (signy<<1) + (signz<<1)
|
||||||
|
Loading…
Reference in New Issue
Block a user