mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-04 18:09:53 +03:00
WIP: fix some memaccess-class warnings
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
#include "materialsystem/deformations.h"
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h"
|
||||
#include "materialsystem/IColorCorrection.h"
|
||||
|
||||
#include "tier1/memhelpers.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
@@ -1563,12 +1563,9 @@ public:
|
||||
|
||||
template< class E > inline E* IMatRenderContext::LockRenderDataTyped( int nCount, const E* pSrcData )
|
||||
{
|
||||
int nSizeInBytes = nCount * sizeof(E);
|
||||
E *pDstData = (E*)LockRenderData( nSizeInBytes );
|
||||
E *pDstData = (E*)LockRenderData( nCount*sizeof(E) );
|
||||
if ( pSrcData && pDstData )
|
||||
{
|
||||
memcpy( pDstData, pSrcData, nSizeInBytes );
|
||||
}
|
||||
memutils::copy( pDstData, pSrcData, nCount );
|
||||
return pDstData;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "tier0/dbg.h"
|
||||
#include "tier1/utlsoacontainer.h"
|
||||
#include "mathlib/ssemath.h"
|
||||
#include "tier1/memhelpers.h"
|
||||
|
||||
class CSIMDVectorMatrix
|
||||
{
|
||||
@@ -61,19 +62,19 @@ public:
|
||||
// set up storage and fields for m x n matrix. destroys old data
|
||||
void SetSize( int width, int height )
|
||||
{
|
||||
if ( ( ! m_pData ) || ( width != m_nWidth ) || ( height != m_nHeight ) )
|
||||
if ( ( ! m_pData ) || ( width > m_nWidth ) || ( height > m_nHeight ) )
|
||||
{
|
||||
if ( m_pData )
|
||||
delete[] m_pData;
|
||||
|
||||
m_nWidth = width;
|
||||
m_nHeight = height;
|
||||
|
||||
|
||||
m_nPaddedWidth = ( m_nWidth + 3) >> 2;
|
||||
m_pData = NULL;
|
||||
if ( width && height )
|
||||
m_pData = new FourVectors[ m_nPaddedWidth * m_nHeight ];
|
||||
}
|
||||
|
||||
m_nWidth = width;
|
||||
m_nHeight = height;
|
||||
}
|
||||
|
||||
CSIMDVectorMatrix( int width, int height )
|
||||
@@ -86,7 +87,8 @@ public:
|
||||
{
|
||||
SetSize( src.m_nWidth, src.m_nHeight );
|
||||
if ( m_pData )
|
||||
memcpy( m_pData, src.m_pData, m_nHeight*m_nPaddedWidth*sizeof(m_pData[0]) );
|
||||
memutils::copy( m_pData, src.m_pData, m_nHeight*m_nPaddedWidth );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -131,7 +133,9 @@ public:
|
||||
void Clear( void )
|
||||
{
|
||||
Assert( m_pData );
|
||||
memset( m_pData, 0, m_nHeight*m_nPaddedWidth*sizeof(m_pData[0]) );
|
||||
|
||||
static FourVectors value{Four_Zeros, Four_Zeros, Four_Zeros};
|
||||
memutils::set( m_pData, value, m_nHeight*m_nPaddedWidth );
|
||||
}
|
||||
|
||||
void RaiseToPower( float power );
|
||||
|
||||
@@ -2613,6 +2613,13 @@ public:
|
||||
z=src.z;
|
||||
}
|
||||
|
||||
FourVectors( fltx4 x, fltx4 y, fltx4 z )
|
||||
{
|
||||
this->x=x;
|
||||
this->y=y;
|
||||
this->z=z;
|
||||
}
|
||||
|
||||
FORCEINLINE void operator=( FourVectors const &src )
|
||||
{
|
||||
x=src.x;
|
||||
|
||||
@@ -3298,17 +3298,19 @@ inline int Studio_LoadVertexes( const vertexFileHeader_t *pTempVvdHdr, vertexFil
|
||||
}
|
||||
|
||||
// copy vertexes
|
||||
|
||||
// TODO(nillerusr): That sucks and needs to be fixed
|
||||
memcpy(
|
||||
(mstudiovertex_t *)((byte *)pNewVvdHdr+pNewVvdHdr->vertexDataStart) + target,
|
||||
(mstudiovertex_t *)((byte *)pTempVvdHdr+pTempVvdHdr->vertexDataStart) + pFixupTable[i].sourceVertexID,
|
||||
(byte*)((mstudiovertex_t *)((byte *)pNewVvdHdr+pNewVvdHdr->vertexDataStart) + target),
|
||||
(byte*)((mstudiovertex_t *)((byte *)pTempVvdHdr+pTempVvdHdr->vertexDataStart) + pFixupTable[i].sourceVertexID),
|
||||
pFixupTable[i].numVertexes*sizeof(mstudiovertex_t) );
|
||||
|
||||
if (bNeedsTangentS)
|
||||
{
|
||||
// copy tangents
|
||||
memcpy(
|
||||
(Vector4D *)((byte *)pNewVvdHdr+pNewVvdHdr->tangentDataStart) + target,
|
||||
(Vector4D *)((byte *)pTempVvdHdr+pTempVvdHdr->tangentDataStart) + pFixupTable[i].sourceVertexID,
|
||||
(byte*)((Vector4D *)((byte *)pNewVvdHdr+pNewVvdHdr->tangentDataStart) + target),
|
||||
(byte*)((Vector4D *)((byte *)pTempVvdHdr+pTempVvdHdr->tangentDataStart) + pFixupTable[i].sourceVertexID),
|
||||
pFixupTable[i].numVertexes*sizeof(Vector4D) );
|
||||
}
|
||||
|
||||
|
||||
@@ -1266,12 +1266,12 @@ struct CPUInformation
|
||||
|
||||
uint8 m_nLogicalProcessors; // Number op logical processors.
|
||||
uint8 m_nPhysicalProcessors; // Number of physical processors
|
||||
|
||||
|
||||
bool m_bSSE3 : 1,
|
||||
m_bSSSE3 : 1,
|
||||
m_bSSE4a : 1,
|
||||
m_bSSE41 : 1,
|
||||
m_bSSE42 : 1;
|
||||
m_bSSE42 : 1;
|
||||
|
||||
int64 m_Speed; // In cycles per second.
|
||||
|
||||
@@ -1280,7 +1280,7 @@ struct CPUInformation
|
||||
uint32 m_nModel;
|
||||
uint32 m_nFeatures[3];
|
||||
|
||||
CPUInformation(): m_Size(0){}
|
||||
CPUInformation() = default;
|
||||
};
|
||||
|
||||
// Have to return a pointer, not a reference, because references are not compatible with the
|
||||
|
||||
32
public/tier1/memhelpers.h
Normal file
32
public/tier1/memhelpers.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// ======= Copyright nillerusr, 2022 =======
|
||||
|
||||
// Helper аunctions for setting/сopying memory ( specially for non-POD types )
|
||||
// FUCK STL
|
||||
|
||||
#ifndef MEMHELPERS_H
|
||||
#define MEMHELPERS_H
|
||||
|
||||
namespace memutils
|
||||
{
|
||||
template<typename T>
|
||||
inline void copy( T *dest, const T *src, size_t n )
|
||||
{
|
||||
do
|
||||
{
|
||||
--n;
|
||||
*(dest+n) = *(src+n);
|
||||
} while( n );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void set( T *dest, T value, size_t n )
|
||||
{
|
||||
do
|
||||
{
|
||||
--n;
|
||||
*(dest+n) = value;
|
||||
} while( n );
|
||||
}
|
||||
}
|
||||
|
||||
#endif //MEMHELPERS_H
|
||||
@@ -1039,10 +1039,6 @@ struct fluidparams_t
|
||||
//-----------------------------------------------------------------------------
|
||||
struct springparams_t
|
||||
{
|
||||
springparams_t()
|
||||
{
|
||||
memset( this, 0, sizeof(*this) );
|
||||
}
|
||||
float constant; // spring constant
|
||||
float naturalLength;// relaxed length
|
||||
float damping; // damping factor
|
||||
|
||||
Reference in New Issue
Block a user