Common: Replace MemsetFast routines with C memset

And associated cleanup.

On most compilers these days, it'll either inline the memset with vector
fills or rep stosq, or outline with a call to memset.

I trust the compiler is probably going to make a better decision here,
than manual SSE intrinsics.

Ends up a couple of percent faster in FMV decoding.
This commit is contained in:
Stenzek 2023-06-16 21:25:52 +10:00 committed by Connor McLaughlin
parent 0366929231
commit 7c9c8e197c
40 changed files with 128 additions and 246 deletions

View File

@ -81,7 +81,6 @@ target_sources(common PRIVATE
HeapArray.h
HTTPDownloader.h
MemorySettingsInterface.h
MemsetFast.inl
MD5Digest.h
MRCHelpers.h
Path.h

View File

@ -198,24 +198,6 @@ private:
#define SafeSysMunmap(ptr, size) \
((void)(HostSys::Munmap(ptr, size), (ptr) = 0))
// This method can clear any object-like entity -- which is anything that is not a pointer.
// Structures, static arrays, etc. No need to include sizeof() crap, this does it automatically
// for you!
template <typename T>
static __fi void memzero(T& object)
{
static_assert(std::is_trivially_copyable_v<T>);
std::memset(&object, 0, sizeof(T));
}
// This method clears an object with the given 8 bit value.
template <u8 data, typename T>
static __fi void memset8(T& object)
{
static_assert(std::is_trivially_copyable_v<T>);
std::memset(&object, data, sizeof(T));
}
extern u64 GetTickFrequency();
extern u64 GetCPUTicks();
extern u64 GetPhysicalMemory();

View File

@ -1,95 +0,0 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <xmmintrin.h>
template <u8 data>
__noinline void memset_sse_a(void* dest, const size_t size)
{
const uint MZFqwc = size / 16;
pxAssert((size & 0xf) == 0);
__m128 srcreg;
if (data != 0)
{
alignas(16) static const u8 loadval[8] = {data, data, data, data, data, data, data, data};
srcreg = _mm_loadh_pi(_mm_load_ps((float*)loadval), (__m64*)loadval);
}
else
srcreg = _mm_setzero_ps();
float(*destxmm)[4] = (float(*)[4])dest;
switch (MZFqwc & 0x07)
{
case 0x07:
_mm_store_ps(&destxmm[0x07 - 1][0], srcreg);
// Fall through
case 0x06:
_mm_store_ps(&destxmm[0x06 - 1][0], srcreg);
// Fall through
case 0x05:
_mm_store_ps(&destxmm[0x05 - 1][0], srcreg);
// Fall through
case 0x04:
_mm_store_ps(&destxmm[0x04 - 1][0], srcreg);
// Fall through
case 0x03:
_mm_store_ps(&destxmm[0x03 - 1][0], srcreg);
// Fall through
case 0x02:
_mm_store_ps(&destxmm[0x02 - 1][0], srcreg);
// Fall through
case 0x01:
_mm_store_ps(&destxmm[0x01 - 1][0], srcreg);
// Fall through
}
destxmm += (MZFqwc & 0x07);
for (uint i = 0; i < MZFqwc / 8; ++i, destxmm += 8)
{
_mm_store_ps(&destxmm[0][0], srcreg);
_mm_store_ps(&destxmm[1][0], srcreg);
_mm_store_ps(&destxmm[2][0], srcreg);
_mm_store_ps(&destxmm[3][0], srcreg);
_mm_store_ps(&destxmm[4][0], srcreg);
_mm_store_ps(&destxmm[5][0], srcreg);
_mm_store_ps(&destxmm[6][0], srcreg);
_mm_store_ps(&destxmm[7][0], srcreg);
}
};
static __fi void memzero_sse_a(void* dest, const size_t size)
{
memset_sse_a<0>(dest, size);
}
template <u8 data, typename T>
__noinline void memset_sse_a(T& dest)
{
static_assert((sizeof(dest) & 0xf) == 0, "Bad size for SSE memset");
memset_sse_a<data>(&dest, sizeof(dest));
}
template <typename T>
void memzero_sse_a(T& dest)
{
static_assert((sizeof(dest) & 0xf) == 0, "Bad size for SSE memset");
memset_sse_a<0>(&dest, sizeof(dest));
}

View File

@ -66,8 +66,6 @@ x86capabilities::x86capabilities()
, PhysicalCores(0)
, LogicalCores(0)
{
memzero(VendorName);
memzero(FamilyName);
}
#if defined(_MSC_VER)
#pragma optimize("", on)
@ -148,7 +146,6 @@ void x86capabilities::Identify()
s32 regs[4];
u32 cmds;
memzero(VendorName);
cpuid(regs, 0);
cmds = regs[0];
@ -201,7 +198,6 @@ void x86capabilities::Identify()
EFlags = regs[3];
}
memzero(FamilyName);
cpuid((int*)FamilyName, 0x80000002);
cpuid((int*)(FamilyName + 16), 0x80000003);
cpuid((int*)(FamilyName + 32), 0x80000004);

View File

@ -46,8 +46,8 @@ public:
u32 EFlags2; // Extended Feature Flags pg2
u32 SEFlag; // Structured Extended Feature Flags Enumeration
char VendorName[16]; // Vendor/Creator ID
char FamilyName[50]; // the original cpu name
char VendorName[16] = {}; // Vendor/Creator ID
char FamilyName[50] = {}; // the original cpu name
// ----------------------------------------------------------------------------
// x86 CPU Capabilities Section (all boolean flags!)
@ -55,6 +55,8 @@ public:
union
{
u64 AllCapabilities = 0;
struct
{
u32 hasFloatingPointUnit : 1;
@ -101,13 +103,11 @@ public:
u32 hasAMD64BitArchitecture : 1;
u32 hasStreamingSIMD4ExtensionsA : 1;
};
u64 AllCapabilities;
};
// Core Counts!
u32 PhysicalCores;
u32 LogicalCores;
u32 PhysicalCores = 0;
u32 LogicalCores = 0;
public:
x86capabilities();

View File

@ -913,7 +913,7 @@ static uint cdvdBlockReadTime(CDVD_MODE_TYPE mode)
void cdvdReset()
{
memzero(cdvd);
std::memset(&cdvd, 0, sizeof(cdvd));
cdvd.Type = CDVD_TYPE_NODISC;
cdvd.Spinning = false;
@ -1824,7 +1824,7 @@ static void cdvdWrite04(u8 rt)
cdvd.SCMDParamC = 0;
cdvdUpdateStatus(CDVD_STATUS_STOP);
cdvd.Spinning = false;
memzero(cdvd.SCMDResult);
std::memset(cdvd.SCMDResult, 0, sizeof(cdvd.SCMDResult));
cdvdSetIrq();
break;
@ -2337,7 +2337,7 @@ static void cdvdWrite16(u8 rt) // SCOMMAND
CDVD_LOG("cdvdWrite16: SCMD %s (%x) (ParamP = %x)", sCmdName[rt], rt, cdvd.SCMDParamP);
cdvd.sCommand = rt;
memzero(cdvd.SCMDResult);
std::memset(cdvd.SCMDResult, 0, sizeof(cdvd.SCMDResult));
switch (rt)
{

View File

@ -591,7 +591,7 @@ void cdrReadInterrupt()
if (cdr.RErr == -1)
{
DevCon.Warning("CD err");
memzero(cdr.Transfer);
std::memset(cdr.Transfer, 0, sizeof(cdr.Transfer));
cdr.Stat = DiskError;
cdr.StatP |= STATUS_ERROR;
cdr.Result[0] = cdr.StatP;
@ -1107,7 +1107,7 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr)
void cdrReset()
{
memzero(cdr);
std::memset(&cdr, 0, sizeof(cdr));
cdr.CurTrack = 1;
cdr.File = 1;
cdr.Channel = 1;

View File

@ -165,7 +165,7 @@ namespace
void resetCache()
{
memzero(cache);
std::memset(&cache, 0, sizeof(cache));
}
static bool findInCache(const CacheSet& set, uptr ppf, int* way)

View File

@ -164,7 +164,7 @@ void rcntInit()
g_FrameCount = 0;
memzero(counters);
std::memset(counters, 0, sizeof(counters));
for (i=0; i<4; i++) {
counters[i].rate = 2;

View File

@ -40,7 +40,7 @@ void gsReset()
{
GetMTGS().ResetGS(true);
gsVideoMode = GS_VideoMode::Uninitialized;
memzero(g_RealGSMem);
std::memset(g_RealGSMem, 0, sizeof(g_RealGSMem));
UpdateVSyncRate(true);
}
@ -85,7 +85,7 @@ static __fi void gsCSRwrite( const tGS_CSR& csr )
gifUnit.gsSIGNAL.queued = false;
gifUnit.gsFINISH.gsFINISHFired = true;
// Privilage registers also reset.
memzero(g_RealGSMem);
std::memset(g_RealGSMem, 0, sizeof(g_RealGSMem));
GSIMR.reset();
CSRreg.Reset();
GetMTGS().SendSimplePacket(GS_RINGTYPE_RESET, 0, 0, 0);

View File

@ -82,7 +82,7 @@ bool CheckPaths()
void GIF_Fifo::init()
{
memzero(data);
std::memset(data, 0, sizeof(data));
fifoSize = 0;
gifRegs.stat.FQC = 0;

View File

@ -65,7 +65,7 @@ struct Gif_Tag
setTag(pMem, analyze);
}
__ri void Reset() { memzero(*this); }
__ri void Reset() { std::memset(this, 0, sizeof(*this)); }
__ri u8 curReg() { return regs[nRegIdx & 0xf]; }
__ri void packedStep()
@ -163,21 +163,21 @@ struct GS_Packet
s32 cycles; // EE Cycles taken to process this GS packet
s32 readAmount; // Dummy read-amount data needed for proper buffer calculations
GS_Packet() { Reset(); }
void Reset() { memzero(*this); }
void Reset() { std::memset(this, 0, sizeof(*this)); }
};
struct GS_SIGNAL
{
u32 data[2];
bool queued;
void Reset() { memzero(*this); }
void Reset() { std::memset(this, 0, sizeof(*this)); }
};
struct GS_FINISH
{
bool gsFINISHFired;
void Reset() { memzero(*this); }
void Reset() { std::memset(this, 0, sizeof(*this)); }
};
static __fi void incTag(u32& offset, u32& size, u32 incAmount)

View File

@ -58,7 +58,7 @@ void hwReset()
{
hwInit();
memzero( eeHw );
std::memset(eeHw, 0, sizeof(eeHw));
psHu32(SBUS_F260) = 0x1D000060;

View File

@ -23,8 +23,6 @@
#include <limits.h>
#include "Config.h"
#include "common/MemsetFast.inl"
// the BP doesn't advance and returns -1 if there is no data to be read
alignas(16) tIPU_cmd ipu_cmd;
alignas(16) tIPU_BP g_BP;
@ -88,7 +86,7 @@ __ri static u8 getBits32(u8* address, bool advance)
void tIPU_cmd::clear()
{
memzero_sse_a(*this);
std::memset(this, 0, sizeof(*this));
current = 0xffffffff;
}
@ -104,9 +102,9 @@ __fi void IPUProcessInterrupt()
void ipuReset()
{
IPUWorker = MULTI_ISA_SELECT(IPUWorker);
memzero(ipuRegs);
memzero(g_BP);
memzero(decoder);
std::memset(&ipuRegs, 0, sizeof(ipuRegs));
std::memset(&g_BP, 0, sizeof(g_BP));
std::memset(&decoder, 0, sizeof(decoder));
decoder.picture_structure = FRAME_PICTURE; //default: progressive...my guess:P
@ -314,7 +312,7 @@ __fi u64 ipuRead64(u32 mem)
void ipuSoftReset()
{
ipu_fifo.clear();
memzero(g_BP);
std::memset(&g_BP, 0, sizeof(g_BP));
coded_block_pattern = 0;
g_ipu_thresh[0] = 0;
@ -389,7 +387,7 @@ __fi bool ipuWrite64(u32 mem, u64 value)
static void ipuBCLR(u32 val)
{
ipu_fifo.in.clear();
memzero(g_BP);
std::memset(&g_BP, 0, sizeof(g_BP));
g_BP.BP = val & 0x7F;
ipuRegs.cmd.BUSY = 0;
@ -441,8 +439,8 @@ static __ri void ipuBDEC(tIPU_CMD_BDEC bdec)
decoder.dcr = bdec.DCR;
decoder.macroblock_modes |= bdec.MBI ? MACROBLOCK_INTRA : MACROBLOCK_PATTERN;
memzero_sse_a(decoder.mb8);
memzero_sse_a(decoder.mb16);
std::memset(&decoder.mb8, 0, sizeof(decoder.mb8));
std::memset(&decoder.mb16, 0, sizeof(decoder.mb16));
}
static void ipuSETTH(u32 val)

View File

@ -27,13 +27,13 @@ void IPU_Fifo::init()
out.writepos = 0;
in.readpos = 0;
in.writepos = 0;
memzero(in.data);
memzero(out.data);
std::memset(in.data, 0, sizeof(in.data));
std::memset(out.data, 0, sizeof(out.data));
}
void IPU_Fifo_Input::clear()
{
memzero(data);
std::memset(data, 0, sizeof(data));
g_BP.IFC = 0;
ipuRegs.ctrl.IFC = 0;
readpos = 0;
@ -50,7 +50,7 @@ void IPU_Fifo_Input::clear()
void IPU_Fifo_Output::clear()
{
memzero(data);
std::memset(data, 0, sizeof(data));
ipuRegs.ctrl.OFC = 0;
readpos = 0;
writepos = 0;

View File

@ -26,7 +26,8 @@
#include "IPU/IPUdma.h"
#include "IPU/yuv2rgb.h"
#include "IPU/IPU_MultiISA.h"
#include "common/MemsetFast.inl"
#include "common/General.h"
// the IPU is fixed to 16 byte strides (128-bit / QWC resolution):
static const uint decoder_stride = 16;
@ -960,7 +961,7 @@ __ri static bool slice_non_intra_DCT(s16 * const dest, const int stride, const b
if (!skip)
{
memzero_sse_a(decoder.DCTblock);
std::memset(decoder.DCTblock, 0, sizeof(decoder.DCTblock));
}
if (!get_non_intra_block(&last))
@ -1033,8 +1034,8 @@ __ri static bool mpeg2sliceIDEC()
}
decoder.coded_block_pattern = 0x3F;//all 6 blocks
memzero_sse_a(mb8);
memzero_sse_a(rgb32);
std::memset(&mb8, 0, sizeof(mb8));
std::memset(&rgb32, 0, sizeof(rgb32));
[[fallthrough]];
case 1:
@ -1282,8 +1283,8 @@ __fi static bool mpeg2_slice()
ipuRegs.ctrl.ECD = 0;
ipuRegs.top = 0;
memzero_sse_a(mb8);
memzero_sse_a(mb16);
std::memset(&mb8, 0, sizeof(mb8));
std::memset(&mb16, 0, sizeof(mb16));
[[fallthrough]];
case 1:

View File

@ -136,7 +136,7 @@ void psxRcntInit()
{
int i;
memzero(psxCounters);
std::memset(psxCounters, 0, sizeof(psxCounters));
for (i = 0; i < 3; i++)
{

View File

@ -129,8 +129,8 @@ void VU_Thread::Reset()
m_write_pos = 0;
m_ato_read_pos = 0;
m_read_pos = 0;
memzero(vif);
memzero(vifRegs);
std::memset(&vif, 0, sizeof(vif));
std::memset(&vifRegs, 0, sizeof(vifRegs));
for (size_t i = 0; i < 4; ++i)
vu1Thread.vuCycles[i] = 0;
vu1Thread.mtvuInterrupts = 0;

View File

@ -36,9 +36,11 @@
#include <map>
static const int MCD_SIZE = 1024 * 8 * 16; // Legacy PSX card default size
static constexpr int MCD_SIZE = 1024 * 8 * 16; // Legacy PSX card default size
static const int MC2_MBSIZE = 1024 * 528 * 2; // Size of a single megabyte of card data
static constexpr int MC2_MBSIZE = 1024 * 528 * 2; // Size of a single megabyte of card data
static constexpr int MC2_ERASE_SIZE = 528 * 16;
static const char* s_folder_mem_card_id_file = "_pcsx2_superblock";
@ -166,17 +168,16 @@ static bool ConvertRAWtoNoECC(const char* file_in, const char* file_out)
class FileMemoryCard
{
protected:
std::FILE* m_file[8];
std::string m_filenames[8];
u8 m_effeffs[528 * 16];
std::FILE* m_file[8] = {};
std::string m_filenames[8] = {};
SafeArray<u8> m_currentdata;
u64 m_chksum[8];
bool m_ispsx[8];
u32 m_chkaddr;
u64 m_chksum[8] = {};
bool m_ispsx[8] = {};
u32 m_chkaddr = 0;
public:
FileMemoryCard();
virtual ~FileMemoryCard() = default;
~FileMemoryCard();
void Lock();
void Unlock();
@ -257,11 +258,9 @@ std::string FileMcd_GetDefaultName(uint slot)
return StringUtil::StdStringFromFormat("Mcd%03u.ps2", slot + 1);
}
FileMemoryCard::FileMemoryCard()
: m_chkaddr(0)
{
memset8<0xff>(m_effeffs);
}
FileMemoryCard::FileMemoryCard() = default;
FileMemoryCard::~FileMemoryCard() = default;
void FileMemoryCard::Open()
{
@ -431,9 +430,12 @@ bool FileMemoryCard::Create(const char* mcdFile, uint sizeInMB)
if (!fp)
return false;
for (uint i = 0; i < (MC2_MBSIZE * sizeInMB) / sizeof(m_effeffs); i++)
u8 buf[MC2_ERASE_SIZE];
std::memset(buf, 0xff, sizeof(buf));
for (uint i = 0; i < (MC2_MBSIZE * sizeInMB) / sizeof(buf); i++)
{
if (std::fwrite(m_effeffs, sizeof(m_effeffs), 1, fp.get()) != 1)
if (std::fwrite(buf, sizeof(buf), 1, fp.get()) != 1)
return false;
}
return true;
@ -557,7 +559,10 @@ s32 FileMemoryCard::EraseBlock(uint slot, u32 adr)
if (!Seek(mcfp, adr))
return 0;
return std::fwrite(m_effeffs, sizeof(m_effeffs), 1, mcfp) == 1;
u8 buf[MC2_ERASE_SIZE];
std::memset(buf, 0xff, sizeof(buf));
return std::fwrite(buf, sizeof(buf), 1, mcfp) == 1;
}
u64 FileMemoryCard::GetCRC(uint slot)
@ -963,13 +968,13 @@ bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, Me
Console.WriteLn("(FileMcd) Creating new PS2 %uMB memory card: '%s'", size / MC2_MBSIZE, full_path.c_str());
// PS2 Memory Card
u8 m_effeffs[528 * 16];
memset8<0xff>(m_effeffs);
u8 buf[MC2_ERASE_SIZE];
std::memset(buf, 0xff, sizeof(buf));
const u32 count = size / sizeof(m_effeffs);
const u32 count = size / sizeof(buf);
for (uint i = 0; i < count; i++)
{
if (std::fwrite(m_effeffs, sizeof(m_effeffs), 1, fp.get()) != 1)
if (std::fwrite(buf, sizeof(buf), 1, fp.get()) != 1)
{
Host::ReportFormattedErrorAsync("Memory Card Creation Failed", "Failed to write file '%s'.", full_path.c_str());
return false;
@ -983,13 +988,13 @@ bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, Me
Console.WriteLn("(FileMcd) Creating new PSX 128 KiB memory card: '%s'", full_path.c_str());
// PSX Memory Card; 8192 is the size in bytes of a single block of a PSX memory card (8 KiB).
u8 m_effeffs_psx[8192];
memset8<0xff>(m_effeffs_psx);
u8 buf[8192];
std::memset(buf, 0xff, sizeof(buf));
// PSX cards consist of 16 blocks, each 8 KiB in size.
for (uint i = 0; i < 16; i++)
{
if (std::fwrite(m_effeffs_psx, sizeof(m_effeffs_psx), 1, fp.get()) != 1)
if (std::fwrite(buf, sizeof(buf), 1, fp.get()) != 1)
{
Host::ReportFormattedErrorAsync("Memory Card Creation Failed", "Failed to write file '%s'.", full_path.c_str());
return false;

View File

@ -48,7 +48,7 @@ alignas(16) psxRegisters psxRegs;
void psxReset()
{
memzero(psxRegs);
std::memset(&psxRegs, 0, sizeof(psxRegs));
psxRegs.pc = 0xbfc00000; // Start in bootstrap
psxRegs.CP0.n.Status = 0x10900000; // COP0 enabled | BEV = 1 | TS = 1

View File

@ -77,9 +77,9 @@ void cpuReset()
GetVmMemory().Reset();
memzero(cpuRegs);
memzero(fpuRegs);
memzero(tlb);
std::memset(&cpuRegs, 0, sizeof(cpuRegs));
std::memset(&fpuRegs, 0, sizeof(fpuRegs));
std::memset(&tlb, 0, sizeof(tlb));
cpuRegs.pc = 0xbfc00000; //set pc reg to stack
cpuRegs.CP0.n.Config = 0x440;

View File

@ -154,7 +154,7 @@ void Deci2Reset()
{
deci2handler = 0;
deci2addr = 0;
memzero( deci2buffer );
std::memset(deci2buffer, 0, sizeof(deci2buffer));
}
void SaveStateBase::deci2Freeze()

View File

@ -126,14 +126,14 @@ void SaveStateBase::PrepBlock( int size )
void SaveStateBase::FreezeTag(const char* src)
{
const uint allowedlen = sizeof( m_tagspace )-1;
pxAssertDev(strlen(src) < allowedlen, "Tag name exceeds the allowed length");
char tagspace[32];
pxAssertDev(std::strlen(src) < (sizeof(tagspace) - 1), "Tag name exceeds the allowed length");
memzero( m_tagspace );
strcpy( m_tagspace, src );
Freeze( m_tagspace );
std::memset(tagspace, 0, sizeof(tagspace));
StringUtil::Strlcpy(tagspace, src, sizeof(tagspace));
Freeze(tagspace);
if( strcmp( m_tagspace, src ) != 0 )
if (std::strcmp(tagspace, src) != 0)
{
std::string msg(fmt::format("Savestate data corruption detected while reading tag: {}", src));
pxFail(msg.c_str());
@ -151,8 +151,8 @@ SaveStateBase& SaveStateBase::FreezeBios()
u32 bioscheck = BiosChecksum;
char biosdesc[256];
memzero( biosdesc );
memcpy( biosdesc, BiosDescription.c_str(), std::min( sizeof(biosdesc), BiosDescription.length() ) );
std::memset(biosdesc, 0, sizeof(biosdesc));
StringUtil::Strlcpy(biosdesc, BiosDescription, sizeof(biosdesc));
Freeze(bioscheck);
Freeze(biosdesc);

View File

@ -78,7 +78,6 @@ class SaveStateBase
{
protected:
VmStateBuffer* m_memory;
char m_tagspace[32];
u32 m_version; // version of the savestate being loaded.

View File

@ -23,8 +23,8 @@
void sifReset()
{
memzero(sif0);
memzero(sif1);
std::memset(&sif0, 0, sizeof(sif0));
std::memset(&sif1, 0, sizeof(sif1));
}
void SaveStateBase::sifFreeze()

View File

@ -141,7 +141,7 @@ struct sifFifo
}
void clear()
{
memzero(data);
std::memset(data, 0, sizeof(data));
readPos = 0;
writePos = 0;
size = 0;

View File

@ -28,7 +28,6 @@
#include "x86/newVif.h"
#include "common/Align.h"
#include "common/MemsetFast.inl"
#include "common/Perf.h"
#include "common/StringUtil.h"

View File

@ -64,9 +64,9 @@ void vuMemoryReserve::Reset()
//memMapVUmicro();
// === VU0 Initialization ===
memzero(VU0.ACC);
memzero(VU0.VF);
memzero(VU0.VI);
std::memset(&VU0.ACC, 0, sizeof(VU0.ACC));
std::memset(VU0.VF, 0, sizeof(VU0.VF));
std::memset(VU0.VI, 0, sizeof(VU0.VI));
VU0.VF[0].f.x = 0.0f;
VU0.VF[0].f.y = 0.0f;
VU0.VF[0].f.z = 0.0f;
@ -74,9 +74,9 @@ void vuMemoryReserve::Reset()
VU0.VI[0].UL = 0;
// === VU1 Initialization ===
memzero(VU1.ACC);
memzero(VU1.VF);
memzero(VU1.VI);
std::memset(&VU1.ACC, 0, sizeof(VU1.ACC));
std::memset(VU1.VF, 0, sizeof(VU1.VF));
std::memset(VU1.VI, 0, sizeof(VU1.VI));
VU1.VF[0].f.x = 0.0f;
VU1.VF[0].f.y = 0.0f;
VU1.VF[0].f.z = 0.0f;

View File

@ -29,8 +29,8 @@ alignas(16) vifStruct vif0, vif1;
void vif0Reset()
{
/* Reset the whole VIF, meaning the internal pcsx2 vars and all the registers */
memzero(vif0);
memzero(vif0Regs);
std::memset(&vif0, 0, sizeof(vif0));
std::memset(&vif0Regs, 0, sizeof(vif0Regs));
resetNewVif(0);
}
@ -38,8 +38,8 @@ void vif0Reset()
void vif1Reset()
{
/* Reset the whole VIF, meaning the internal pcsx2 vars, and all the registers */
memzero(vif1);
memzero(vif1Regs);
std::memset(&vif1, 0, sizeof(vif1));
std::memset(&vif1Regs, 0, sizeof(vif1Regs));
resetNewVif(1);
}
@ -127,7 +127,7 @@ __fi void vif0FBRST(u32 value)
SaveCol._u64[1] = vif0.MaskCol._u64[1];
SaveRow._u64[0] = vif0.MaskRow._u64[0];
SaveRow._u64[1] = vif0.MaskRow._u64[1];
memzero(vif0);
std::memset(&vif0, 0, sizeof(vif0));
vif0.MaskCol._u64[0] = SaveCol._u64[0];
vif0.MaskCol._u64[1] = SaveCol._u64[1];
vif0.MaskRow._u64[0] = SaveRow._u64[0];
@ -225,7 +225,7 @@ __fi void vif1FBRST(u32 value)
SaveRow._u64[0] = vif1.MaskRow._u64[0];
SaveRow._u64[1] = vif1.MaskRow._u64[1];
u8 mfifo_empty = vif1.inprogress & 0x10;
memzero(vif1);
std::memset(&vif1, 0, sizeof(vif1));
vif1.MaskCol._u64[0] = SaveCol._u64[0];
vif1.MaskCol._u64[1] = SaveCol._u64[1];
vif1.MaskRow._u64[0] = SaveRow._u64[0];

View File

@ -39,7 +39,6 @@
#include "VMManager.h"
#include "common/Align.h"
#include "common/MemsetFast.inl"
#include "fmt/core.h"
@ -1215,7 +1214,7 @@ void vtlb_VMapUnmap(u32 vaddr, u32 size)
void vtlb_Init()
{
vtlbHandlerCount = 0;
memzero(vtlbdata.RWFT);
std::memset(vtlbdata.RWFT, 0, sizeof(vtlbdata.RWFT));
#define VTLB_BuildUnmappedHandler(baseName) \
baseName##ReadSm<mem8_t>, baseName##ReadSm<mem16_t>, baseName##ReadSm<mem32_t>, \
@ -1420,7 +1419,7 @@ void VtlbMemoryReserve::Assign(VirtualMemoryManagerPtr allocator, size_t offset,
void VtlbMemoryReserve::Reset()
{
memzero_sse_a(GetPtr(), GetSize());
std::memset(GetPtr(), 0, GetSize());
}
@ -1577,7 +1576,7 @@ bool vtlb_private::PageFaultHandler(const PageFaultInfo& info)
void mmap_ResetBlockTracking()
{
//DbgCon.WriteLn( "vtlb/mmap: Block Tracking reset..." );
memzero(m_PageProtectInfo);
std::memset(m_PageProtectInfo, 0, sizeof(m_PageProtectInfo));
if (eeMem)
HostSys::MemProtect(eeMem->Main, Ps2MemSize::MainRam, PageAccess_ReadWrite());
vtlb_UpdateFastmemProtection(0, Ps2MemSize::MainRam, PageAccess_ReadWrite());

View File

@ -243,9 +243,9 @@ struct eeProfiler
void Reset()
{
memzero(opStats);
memzero(memStats);
memzero(memStatsConst);
std::memset(opStats, 0, sizeof(opStats));
std::memset(memStats, 0, sizeof(memStats));
std::memset(memStatsConst, 0, sizeof(memStatsConst));
memStatsSlow = 0;
memStatsFast = 0;
memMask = 0xF700FFF0;

View File

@ -41,7 +41,7 @@ _x86regs x86regs[iREGCNT_GPR], s_saveX86regs[iREGCNT_GPR];
// Clear allocation counter
void _initXMMregs()
{
memzero(xmmregs);
std::memset(xmmregs, 0, sizeof(xmmregs));
g_xmmAllocCounter = 0;
}
@ -906,11 +906,11 @@ int _allocIfUsedFPUtoXMM(int fpureg, int mode)
void _recClearInst(EEINST* pinst)
{
// we set everything as being live to begin with, since it needs to be written at the end of the block
memzero(*pinst);
memset8<EEINST_LIVE>(pinst->regs);
memset8<EEINST_LIVE>(pinst->fpuregs);
memset8<EEINST_LIVE>(pinst->vfregs);
memset8<EEINST_LIVE>(pinst->viregs);
std::memset(pinst, 0, sizeof(EEINST));
std::memset(pinst->regs, EEINST_LIVE, sizeof(pinst->regs));
std::memset(pinst->fpuregs, EEINST_LIVE, sizeof(pinst->fpuregs));
std::memset(pinst->vfregs, EEINST_LIVE, sizeof(pinst->vfregs));
std::memset(pinst->viregs, EEINST_LIVE, sizeof(pinst->viregs));
}
// returns nonzero value if reg has been written between [startpc, endpc-4]

View File

@ -37,7 +37,7 @@ static uint g_x86checknext;
void _initX86regs()
{
memzero(x86regs);
std::memset(x86regs, 0, sizeof(x86regs));
g_x86AllocCounter = 0;
g_x86checknext = 0;
}

View File

@ -33,7 +33,6 @@
#include "common/AlignedMalloc.h"
#include "common/FastJmp.h"
#include "common/MemsetFast.inl"
#include "common/Perf.h"
// Only for MOVQ workaround.

View File

@ -40,7 +40,7 @@ void mVUreserveCache(microVU& mVU)
// Only run this once per VU! ;)
void mVUinit(microVU& mVU, uint vuIndex)
{
memzero(mVU.prog);
std::memset(&mVU.prog, 0, sizeof(mVU.prog));
mVU.index = vuIndex;
mVU.cop2 = 0;
@ -155,7 +155,7 @@ __fi void mVUclear(mV, u32 addr, u32 size)
if (!mVU.prog.cleared)
{
mVU.prog.cleared = 1; // Next execution searches/creates a new microprogram
memzero(mVU.prog.lpState); // Clear pipeline state
std::memset(&mVU.prog.lpState, 0, sizeof(mVU.prog.lpState)); // Clear pipeline state
for (u32 i = 0; i < (mVU.progSize / 2); i++)
{
mVU.prog.quick[i].block = NULL; // Clear current quick-reference block

View File

@ -26,8 +26,8 @@ __fi int getLastFlagInst(microRegInfo& pState, int* xFlag, int flagType, int isE
return (((pState.flagInfo >> (2 * flagType + 2)) & 3) - 1) & 3;
}
void mVU0clearlpStateJIT() { if (!microVU0.prog.cleared) memzero(microVU0.prog.lpState); }
void mVU1clearlpStateJIT() { if (!microVU1.prog.cleared) memzero(microVU1.prog.lpState); }
void mVU0clearlpStateJIT() { if (!microVU0.prog.cleared) std::memset(&microVU0.prog.lpState, 0, sizeof(microVU1.prog.lpState)); }
void mVU1clearlpStateJIT() { if (!microVU1.prog.cleared) std::memset(&microVU1.prog.lpState, 0, sizeof(microVU1.prog.lpState)); }
void mVUDTendProgram(mV, microFlagCycles* mFC, int isEbit)
{
@ -166,8 +166,8 @@ void mVUendProgram(mV, microFlagCycles* mFC, int isEbit)
if (isEbit && isEbit != 3)
{
memzero(mVUinfo);
memzero(mVUregsTemp);
std::memset(&mVUinfo, 0, sizeof(mVUinfo));
std::memset(&mVUregsTemp, 0, sizeof(mVUregsTemp));
mVUincCycles(mVU, 100); // Ensures Valid P/Q instances (And sets all cycle data to 0)
mVUcycles -= 100;
qInst = mVU.q;

View File

@ -497,8 +497,8 @@ __fi void startLoop(mV)
DevCon.WriteLn(Color_Green, "microVU%d: D-bit set! PC = %x", getIndex, xPC);
if (curI & _Tbit_)
DevCon.WriteLn(Color_Green, "microVU%d: T-bit set! PC = %x", getIndex, xPC);
memzero(mVUinfo);
memzero(mVUregsTemp);
std::memset(&mVUinfo, 0, sizeof(mVUinfo));
std::memset(&mVUregsTemp, 0, sizeof(mVUregsTemp));
}
// Initialize VI Constants (vi15 propagates through blocks)

View File

@ -108,7 +108,7 @@ struct microProfiler
int index;
void Reset(int _index)
{
memzero(*this);
std::memset(this, 0, sizeof(*this));
index = _index;
}
void EmitOp(microOpcode op)

View File

@ -82,7 +82,7 @@ void resetNewVif(int idx)
nVif[idx].idx = idx;
nVif[idx].bSize = 0;
memzero(nVif[idx].buffer);
std::memset(nVif[idx].buffer, 0, sizeof(nVif[idx].buffer));
if (newVifDynaRec)
dVifReset(idx);