Remove all custom memcpy usage from core pcsx2 and remove memcpy_fast from plugins.

This commit is contained in:
Sacha 2014-08-27 13:45:23 +10:00
parent 3f7cb991e4
commit ad3b76c4d8
31 changed files with 52 additions and 54 deletions

View File

@ -118,7 +118,7 @@ template< typename T >
SafeArray<T>* SafeArray<T>::Clone() const
{
SafeArray<T>* retval = new SafeArray<T>( m_size );
memcpy_fast( retval->GetPtr(), m_ptr, sizeof(T) * m_size );
memcpy( retval->GetPtr(), m_ptr, sizeof(T) * m_size );
return retval;
}
@ -160,7 +160,7 @@ template< typename T, uint Alignment >
SafeAlignedArray<T,Alignment>* SafeAlignedArray<T,Alignment>::Clone() const
{
SafeAlignedArray<T,Alignment>* retval = new SafeAlignedArray<T,Alignment>( this->m_size );
memcpy_fast( retval->GetPtr(), this->m_ptr, sizeof(T) * this->m_size );
memcpy( retval->GetPtr(), this->m_ptr, sizeof(T) * this->m_size );
return retval;
}
@ -272,14 +272,14 @@ void SafeList<T>::Remove( int index )
int copylen = m_length - index;
if( copylen > 0 )
memcpy_fast( &m_ptr[index], &m_ptr[index+1], copylen );
memcpy( &m_ptr[index], &m_ptr[index+1], copylen );
}
template< typename T >
SafeList<T>* SafeList<T>::Clone() const
{
SafeList<T>* retval = new SafeList<T>( m_length );
memcpy_fast( retval->m_ptr, m_ptr, sizeof(T) * m_length );
memcpy( retval->m_ptr, m_ptr, sizeof(T) * m_length );
return retval;
}

View File

@ -265,7 +265,7 @@ FastFormatUnicode& FastFormatUnicode::WriteV( const char* fmt, va_list argptr )
const uint inspos = m_Length;
const uint convLen = converted.Length();
m_dest->MakeRoomFor((inspos + convLen + 64) * sizeof(wxChar));
memcpy_fast( &((wxChar*)m_dest->GetPtr())[inspos], converted.wc_str(), (convLen+1)*sizeof(wxChar) );
memcpy( &((wxChar*)m_dest->GetPtr())[inspos], converted.wc_str(), (convLen+1)*sizeof(wxChar) );
m_Length += convLen;
return *this;

View File

@ -60,7 +60,7 @@ void xSmartJump::SetTarget()
u8* destpos = xGetPtr();
const int copylen = (sptr)target - (sptr)saveme;
memcpy_fast( destpos, saveme, copylen );
memcpy( destpos, saveme, copylen );
xSetPtr( target - spacer );
}
}

View File

@ -735,7 +735,7 @@ int cdvdReadSector() {
}
else
{
memcpy_fast( mdest, cdr.Transfer, cdvd.BlockSize);
memcpy( mdest, cdr.Transfer, cdvd.BlockSize);
}
// decrypt sector's bytes
@ -1567,7 +1567,7 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
cdvd.Param[cdvd.ParamP-5], cdvd.Param[cdvd.ParamP-3], cdvd.Param[cdvd.ParamP-2], cdvd.Param[cdvd.ParamP-1]);
Console.WriteLn("RTC Write Sec %d Min %d Hr %d Day %d Month %d Year %d", cdvd.RTC.second, cdvd.RTC.minute,
cdvd.RTC.hour, cdvd.RTC.day, cdvd.RTC.month, cdvd.RTC.year);*/
//memcpy_fast((u8*)&cdvd.RTC, cdvd.Param, 7);
//memcpy((u8*)&cdvd.RTC, cdvd.Param, 7);
break;
case 0x0A: // sceCdReadNVM (2:3)
@ -1907,7 +1907,7 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
}
else
{
memcpy_fast(cdvd.mg_buffer + cdvd.mg_size, cdvd.Param, cdvd.ParamC);
memcpy(cdvd.mg_buffer + cdvd.mg_size, cdvd.Param, cdvd.ParamC);
cdvd.mg_size += cdvd.ParamC;
cdvd.Result[0] = 0; // 0 complete ; 1 busy ; 0x80 error
}
@ -1915,9 +1915,9 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
case 0x8E: // sceMgReadData
SetResultSize( std::min(16, cdvd.mg_size) );
memcpy_fast(cdvd.Result, cdvd.mg_buffer, cdvd.ResultC);
memcpy(cdvd.Result, cdvd.mg_buffer, cdvd.ResultC);
cdvd.mg_size -= cdvd.ResultC;
memcpy_fast(cdvd.mg_buffer, cdvd.mg_buffer+cdvd.ResultC, cdvd.mg_size);
memcpy(cdvd.mg_buffer, cdvd.mg_buffer+cdvd.ResultC, cdvd.mg_size);
break;
case 0x88: // secrman: __mechacon_auth_0x88 //for now it is the same; so, fall;)
@ -1984,7 +1984,7 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
{
SetResultSize(3);//in:0
int bit_ofs = mg_BIToffset(cdvd.mg_buffer);
memcpy_fast(cdvd.mg_buffer, &cdvd.mg_buffer[bit_ofs], 8+16*cdvd.mg_buffer[bit_ofs+4]);
memcpy(cdvd.mg_buffer, &cdvd.mg_buffer[bit_ofs], 8+16*cdvd.mg_buffer[bit_ofs+4]);
cdvd.mg_maxsize = 0; // don't allow any write
cdvd.mg_size = 8+16*cdvd.mg_buffer[4];//new offset, i just moved the data

View File

@ -422,7 +422,7 @@ s32 CALLBACK ISOreadSector(u8* tempbuffer, u32 lsn, int mode)
jNO_DEFAULT
}
memcpy_fast(tempbuffer, pbuffer, psize);
memcpy(tempbuffer, pbuffer, psize);
return 0;
}

View File

@ -917,7 +917,7 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) {
}
cdsize = (bcr & 0xffff) * 4;
memcpy_fast(iopPhysMem(madr), cdr.pTransfer, cdsize);
memcpy(iopPhysMem(madr), cdr.pTransfer, cdsize);
psxCpu->Clear(madr, cdsize/4);
cdr.pTransfer+=cdsize;
@ -947,7 +947,7 @@ s32 CALLBACK cdvdDmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProces
return 10000;
}
memcpy_fast(data, cdr.pTransfer, wordsLeft);
memcpy(data, cdr.pTransfer, wordsLeft);
//psxCpu->Clear(madr, cdsize/4);
cdr.pTransfer+=wordsLeft;
*wordsProcessed = wordsLeft;

View File

@ -145,7 +145,7 @@ int InputIsoFile::FinishRead3(u8* dst, uint mode)
length = end - _offset;
uint read_offset = (m_current_lsn - m_read_lsn) * m_blocksize;
memcpy_fast(dst + diff, m_readbuffer + ndiff + read_offset, length);
memcpy(dst + diff, m_readbuffer + ndiff + read_offset, length);
if (m_type == ISOTYPE_CD && diff >= 12)
{

View File

@ -161,7 +161,7 @@ int IsoFile::internalRead(void* dest, int off, int len)
slen = (int) (maxOffset - currentOffset);
}
memcpy_fast((u8*)dest + off, currentSector + sectorOffset, slen);
memcpy((u8*)dest + off, currentSector + sectorOffset, slen);
sectorOffset += slen;
currentOffset += slen;

View File

@ -222,7 +222,7 @@ struct Gif_Path {
}
//DevCon.WriteLn("Realign Packet [%d]", curSize - offset);
if (intersect) memmove(buffer, &buffer[offset], curSize - offset);
else memcpy_fast(buffer, &buffer[offset], curSize - offset);
else memcpy(buffer, &buffer[offset], curSize - offset);
curSize -= offset;
curOffset = gsPack.size;
gsPack.offset = 0;

View File

@ -626,7 +626,7 @@ void SysMtgsThread::WaitGS(bool syncRegs, bool weakWait, bool isMTVU)
if (syncRegs) {
ScopedLock lock(m_mtx_WaitGS);
// Completely synchronize GS and MTGS register states.
memcpy_fast(RingBuffer.Regs, PS2MEM_GS, sizeof(RingBuffer.Regs));
memcpy(RingBuffer.Regs, PS2MEM_GS, sizeof(RingBuffer.Regs));
}
}

View File

@ -217,7 +217,7 @@ __fi u32 VU_Thread::Read()
__fi void VU_Thread::Read(void* dest, u32 size)
{
memcpy_fast(dest, &buffer[read_pos], size);
memcpy(dest, &buffer[read_pos], size);
incReadPos(size_u32(size));
}
@ -240,7 +240,7 @@ __fi void VU_Thread::Write(u32 val)
}
__fi void VU_Thread::Write(void* src, u32 size)
{
memcpy_fast(GetWritePtr(), src, size);
memcpy(GetWritePtr(), src, size);
write_offset += size_u32(size);
}

View File

@ -455,7 +455,7 @@ static s32 CALLBACK CDVD_getBuffer2(u8* buffer)
u8* pb = CDVD->getBuffer();
if(pb == NULL) return -2;
memcpy_fast( buffer, pb, lastReadSize );
memcpy( buffer, pb, lastReadSize );
return 0;
}

View File

@ -216,7 +216,7 @@ static int __Deci2Call(int call, u32 *addr)
pdeciaddr += (d2ptr[4]+0xc) % 16;
const int copylen = std::min<uint>(255, d2ptr[1]-0xc);
memcpy_fast(deci2buffer, pdeciaddr, copylen );
memcpy(deci2buffer, pdeciaddr, copylen );
deci2buffer[copylen] = '\0';
eeConLog( ShiftJIS_ConvertString(deci2buffer) );

View File

@ -126,7 +126,7 @@ SaveStateBase& SaveStateBase::FreezeBios()
pxToUTF8 utf8(BiosDescription);
memzero( biosdesc );
memcpy_fast( biosdesc, utf8, std::min( sizeof(biosdesc), utf8.Length() ) );
memcpy( biosdesc, utf8, std::min( sizeof(biosdesc), utf8.Length() ) );
Freeze( bioscheck );
Freeze( biosdesc );
@ -282,7 +282,7 @@ void memSavingState::FreezeMem( void* data, int size )
if (!size) return;
m_memory->MakeRoomFor( m_idx + size );
memcpy_fast( m_memory->GetPtr(m_idx), data, size );
memcpy( m_memory->GetPtr(m_idx), data, size );
m_idx += size;
}
@ -322,7 +322,7 @@ void memLoadingState::FreezeMem( void* data, int size )
{
const u8* const src = m_memory->GetPtr(m_idx);
m_idx += size;
memcpy_fast( data, src, size );
memcpy( data, src, size );
}
// --------------------------------------------------------------------------------------

View File

@ -53,8 +53,8 @@ struct sifFifo
const int wP0 = std::min((FIFO_SIF_W - writePos), words);
const int wP1 = words - wP0;
memcpy_fast(&data[writePos], from, wP0 << 2);
memcpy_fast(&data[0], &from[wP0], wP1 << 2);
memcpy(&data[writePos], from, wP0 << 2);
memcpy(&data[0], &from[wP0], wP1 << 2);
writePos = (writePos + words) & (FIFO_SIF_W - 1);
size += words;
@ -69,8 +69,8 @@ struct sifFifo
const int wP0 = std::min((FIFO_SIF_W - readPos), words);
const int wP1 = words - wP0;
memcpy_fast(to, &data[readPos], wP0 << 2);
memcpy_fast(&to[wP0], &data[0], wP1 << 2);
memcpy(to, &data[readPos], wP0 << 2);
memcpy(&to[wP0], &data[0], wP1 << 2);
readPos = (readPos + words) & (FIFO_SIF_W - 1);
size -= words;

View File

@ -319,7 +319,7 @@ SIO_WRITE memcardErase(u8 data)
{
case 0x82: // Erase
//siomode = SIO_DUMMY; // Nothing more to do here.
memcpy_fast(sio.buf, &header[1], 4);
memcpy(sio.buf, &header[1], 4);
sio.bufSize = 3;
mcd->EraseBlock();
break;
@ -367,7 +367,7 @@ SIO_WRITE memcardWrite(u8 data)
switch(data)
{
case 0x42: // Write
memcpy_fast(sio.buf, header, 4);
memcpy(sio.buf, header, 4);
once = true;
break;
@ -375,7 +375,7 @@ SIO_WRITE memcardWrite(u8 data)
if(once)
{
siomode = SIO_DUMMY; // Nothing more to do here.
memcpy_fast(sio.buf, &header[1], 4);
memcpy(sio.buf, &header[1], 4);
sio.bufSize = 3;
sio2.packet.recvVal1 = 0x1600; // Writing
@ -454,7 +454,7 @@ SIO_WRITE memcardRead(u8 data)
switch(data)
{
case 0x43: // Read
memcpy_fast(sio.buf, header, 4);
memcpy(sio.buf, header, 4);
once = true;
break;
@ -462,7 +462,7 @@ SIO_WRITE memcardRead(u8 data)
if(once)
{
siomode = SIO_DUMMY; // Nothing more to do here.
memcpy_fast(sio.buf, &header[1], 4);
memcpy(sio.buf, &header[1], 4);
sio.bufSize = 3;
sio2.packet.recvVal1 = 0x1700; // Reading
@ -624,7 +624,7 @@ SIO_WRITE sioWriteMemcard(u8 data)
cmd.mc_xor = info.Xor;
cmd.Z = mcd->term;
memcpy_fast(&sio.buf[2], &cmd, sizeof(mc_command_0x26_tag));
memcpy(&sio.buf[2], &cmd, sizeof(mc_command_0x26_tag));
}
break;
@ -698,7 +698,7 @@ SIO_WRITE sioWriteMemcardPSX(u8 data)
{
case 0x53: // PSX 'S'tate // haven't seen it happen yet
sio.buf[1] = mcd->FLAG;
memcpy_fast(&sio.buf[2], memcard_psx, 8);
memcpy(&sio.buf[2], memcard_psx, 8);
siomode = SIO_DUMMY;
break;

View File

@ -296,9 +296,9 @@ static __fi void _vifCode_MPG(int idx, u32 addr, const u32 *data, int size) {
if (!idx) CpuVU0->Clear(addr, (idx ? 0x4000 : 0x1000) - addr);
else CpuVU1->Clear(addr, (idx ? 0x4000 : 0x1000) - addr);
memcpy_fast(VUx.Micro + addr, data, (idx ? 0x4000 : 0x1000) - addr);
memcpy(VUx.Micro + addr, data, (idx ? 0x4000 : 0x1000) - addr);
size -= ((idx ? 0x4000 : 0x1000) - addr) / 4;
memcpy_fast(VUx.Micro, data, size);
memcpy(VUx.Micro, data, size);
vifX.tag.addr = size * 4;
}
@ -310,7 +310,7 @@ static __fi void _vifCode_MPG(int idx, u32 addr, const u32 *data, int size) {
// Clear VU memory before writing!
if (!idx) CpuVU0->Clear(addr, size*4);
else CpuVU1->Clear(addr, size*4);
memcpy_fast(VUx.Micro + addr, data, size*4); //from tests, memcpy is 1fps faster on Grandia 3 than memcpy_fast
memcpy(VUx.Micro + addr, data, size*4); //from tests, memcpy is 1fps faster on Grandia 3 than memcpy
vifX.tag.addr += size * 4;
}

View File

@ -584,7 +584,7 @@ bool ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
int endpos = m_CurQueuePos + text.Length();
m_QueueBuffer.MakeRoomFor( endpos + 1 ); // and the null!!
memcpy_fast( &m_QueueBuffer[m_CurQueuePos], text.wc_str(), sizeof(wxChar) * text.Length() );
memcpy( &m_QueueBuffer[m_CurQueuePos], text.wc_str(), sizeof(wxChar) * text.Length() );
m_CurQueuePos = endpos;
// this NULL may be overwritten if the next message sent doesn't perform a color change.

View File

@ -2179,7 +2179,7 @@ StartRecomp:
}
}
memcpy_fast(&(*recRAMCopy)[HWADDR(startpc) / 4], PSM(startpc), pc - startpc);
memcpy(&(*recRAMCopy)[HWADDR(startpc) / 4], PSM(startpc), pc - startpc);
}
s_pCurBlock->SetFnptr((uptr)recPtr);

View File

@ -530,7 +530,7 @@ void mVUDoTBit(microVU& mVU, microFlagCycles* mFC)
void mVUSaveFlags(microVU& mVU,microFlagCycles &mFC, microFlagCycles &mFCBackup)
{
memcpy_fast(&mFCBackup, &mFC, sizeof(microFlagCycles));
memcpy(&mFCBackup, &mFC, sizeof(microFlagCycles));
mVUsetFlags(mVU, mFCBackup); // Sets Up Flag instances
}
void* mVUcompile(microVU& mVU, u32 startPC, uptr pState) {

View File

@ -898,7 +898,7 @@ static VuFunctionHeader* SuperVURecompileProgram(u32 startpc, int vuindex)
#ifdef SUPERVU_CACHING
//memxor_mmx(r.checksum, &VU->Micro[r.start], r.size);
r.pmem = malloc(r.size);
memcpy_fast(r.pmem, &VU->Micro[r.start], r.size);
memcpy(r.pmem, &VU->Micro[r.start], r.size);
#endif
s_pFnHeader->ranges.push_back(r);
}

View File

@ -68,7 +68,6 @@ extern "C" char* CALLBACK PS2EgetLibName(void);
#include "GSDump.h"
#include "Utilities/MemcpyFast.h"
#define memcpy_amd memcpy_fast
extern wxString s_strIniPath; // Air's new (r2361) new constant for ini file path

View File

@ -493,7 +493,7 @@ template <>
/*__forceinline*/ void ClutBuffer_to_Array<u32>(u32* dst, u32 csa, u32 clutsize)
{
u8* clut = (u8*)GetClutBufferAddress<u32>(csa);
memcpy_amd((u8*)dst, clut, clutsize);
memcpy((u8*)dst, clut, clutsize);
}
template <>

View File

@ -657,7 +657,7 @@ inline void FlushSetStream(VB& curvb)
g_nCurVBOIndex = (g_nCurVBOIndex + 1) % g_vboBuffers.size();
glBufferData(GL_ARRAY_BUFFER, curvb.nCount * sizeof(VertexGPU), curvb.pBufferData, GL_STREAM_DRAW);
// void* pdata = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
// memcpy_amd(pdata, curvb.pBufferData, curvb.nCount * sizeof(VertexGPU));
// memcpy(pdata, curvb.pBufferData, curvb.nCount * sizeof(VertexGPU));
// glUnmapBuffer(GL_ARRAY_BUFFER);
SET_STREAM();

View File

@ -89,7 +89,7 @@ class VB
assert(pBufferData != NULL);
nNumVertices *= 2;
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nNumVertices, 256);
memcpy_amd(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
memcpy(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
assert(nCount <= nNumVertices);
_aligned_free(pBufferData);
pBufferData = ptemp;

View File

@ -1979,7 +1979,7 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc
assert(targ->ptex->ref > 0);
}
memcpy_amd(targ->ptex->memptr, MemoryAddress(targ->realy), MemorySize(targ->height));
memcpy(targ->ptex->memptr, MemoryAddress(targ->realy), MemorySize(targ->height));
__aligned16 u8* ptexdata = NULL;
bool has_data = false;

View File

@ -86,7 +86,6 @@ typedef signed long long int64;
#include "GSDump.h"
#include "Utilities/MemcpyFast.h"
#define memcpy_amd memcpy_fast
extern wxString s_strIniPath; // Air's new (r2361) new constant for ini file path

View File

@ -489,7 +489,7 @@ template <>
/*__forceinline*/ void ClutBuffer_to_Array<u32>(u32* dst, u32 csa, u32 clutsize)
{
u8* clut = (u8*)GetClutBufferAddress<u32>(csa);
memcpy_amd((u8*)dst, clut, clutsize);
memcpy((u8*)dst, clut, clutsize);
}
template <>

View File

@ -364,7 +364,7 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc
assert(targ->ptex->ref > 0);
}
memcpy_amd(targ->ptex->memptr, MemoryAddress(targ->realy), MemorySize(targ->height));
memcpy(targ->ptex->memptr, MemoryAddress(targ->realy), MemorySize(targ->height));
__aligned16 u8* ptexdata = NULL;
bool has_data = false;

View File

@ -535,7 +535,7 @@ inline void FlushSetStream(VB& curvb)
// void* pdata = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
// memcpy_amd(pdata, curvb.pBufferData, curvb.nCount * sizeof(VertexGPU));
// memcpy(pdata, curvb.pBufferData, curvb.nCount * sizeof(VertexGPU));
// glUnmapBuffer(GL_ARRAY_BUFFER);
SET_STREAM();

View File

@ -89,7 +89,7 @@ class VB
assert(pBufferData != NULL);
nNumVertices *= 2;
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nNumVertices, 256);
memcpy_amd(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
memcpy(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
assert(nCount <= nNumVertices);
_aligned_free(pBufferData);
pBufferData = ptemp;