mVU: minor cleanups...

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2680 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2010-03-07 02:44:32 +00:00
parent 0244097a26
commit 8064d9a4d4
2 changed files with 26 additions and 57 deletions

View File

@ -171,13 +171,15 @@ _f void mVUclear(mV, u32 addr, u32 size) {
// Micro VU - Private Functions
//------------------------------------------------------------------
// Finds and Ages/Kills Programs if they haven't been used in a while.
_f void mVUvsyncUpdate(mV) {
//mVU->prog.curFrame++;
}
// Clears program data
_mVUt _f void mVUclearProg(microProgram& program, bool deleteBlocks) {
_mVUt _f void mVUclearProg(microProgram& program, u32 startPC, bool deleteBlocks) {
microVU* mVU = mVUx;
program.used = 0;
program.age = isDead;
program.frame = mVU->prog.curFrame;
program.startPC = 0x7fffffff;
program.startPC = startPC;
for (int j = 0; j <= program.ranges.max; j++) {
program.ranges.range[j][0] = -1; // Set range to
program.ranges.range[j][1] = -1; // indeterminable status
@ -193,11 +195,8 @@ _mVUt _f microProgram* mVUcreateProg(int startPC) {
microVU* mVU = mVUx;
microProgram* prog = (microProgram*)_aligned_malloc(sizeof(microProgram), 64);
memzero_ptr<sizeof(microProgram)>(prog);
mVUclearProg<vuIndex>(*prog);
prog->age = isYoung;
prog->used = 1;
prog->idx = mVU->prog.total++;
prog->startPC = startPC;
prog->idx = mVU->prog.total++;
mVUclearProg<vuIndex>(*prog, startPC);
mVUcacheProg<vuIndex>(*prog); // Cache Micro Program
float cacheSize = (float)((u32)mVU->prog.x86end - (u32)mVU->prog.x86start);
float cacheUsed =((float)((u32)mVU->prog.x86ptr - (u32)mVU->prog.x86start)) / cacheSize * 100;
@ -215,30 +214,7 @@ _mVUt _f void mVUcacheProg(microProgram& prog) {
mVUdumpProg(prog);
}
// Finds and Ages/Kills Programs if they haven't been used in a while.
_f void mVUvsyncUpdate(mV) {
/*for (int i = 0; i <= mVU->prog.max; i++) {
if (mVU->prog.prog[i].age == isDead) continue;
if (mVU->prog.prog[i].used) {
mVU->prog.prog[i].used = 0;
mVU->prog.prog[i].frame = mVU->prog.curFrame;
}
else { // Age Micro Program that wasn't used
s32 diff = mVU->prog.curFrame - mVU->prog.prog[i].frame;
if (diff >= (60 * 1)) {
if (i == mVU->prog.cur) continue; // Don't Age/Kill last used program
mVU->prog.total--;
if (!mVU->index) mVUclearProg<0>(i);
else mVUclearProg<1>(i);
DevCon.WriteLn("microVU%d: Killing Dead Program [%03d]", mVU->index, i+1);
}
//elif(diff >= (60 * 1)) { mVU->prog.prog[i].age = isOld; }
//elif(diff >= (20 * 1)) { mVU->prog.prog[i].age = isAged; }
}
}
mVU->prog.curFrame++;*/
}
// Compare partial program by only checking compiled ranges...
_mVUt _f bool mVUcmpPartial(microProgram& prog) {
microVU* mVU = mVUx;
for (int i = 0; i <= prog.ranges.total; i++) {
@ -254,14 +230,11 @@ _mVUt _f bool mVUcmpPartial(microProgram& prog) {
// Compare Cached microProgram to mVU->regs->Micro
_mVUt _f bool mVUcmpProg(microProgram& prog, const bool cmpWholeProg) {
microVU* mVU = mVUx;
if (prog.age == isDead) return 0;
if ((cmpWholeProg && !memcmp_mmx((u8*)prog.data, mVU->regs->Micro, mVU->microMemSize))
|| (!cmpWholeProg && mVUcmpPartial<vuIndex>(prog))) {
mVU->prog.cleared = 0;
mVU->prog.cur =&prog;
mVU->prog.isSame = cmpWholeProg ? 1 : -1;
prog.used = 1;
prog.age = isYoung;
mVU->prog.cleared = 0;
mVU->prog.cur = &prog;
mVU->prog.isSame = cmpWholeProg ? 1 : -1;
return 1;
}
return 0;
@ -283,21 +256,20 @@ _mVUt _f void* mVUsearchProg(u32 startPC, uptr pState) {
return mVUentryGet(mVU, quick.block, startPC, pState);
}
}
mVU->prog.cur = mVUcreateProg<vuIndex>(startPC/8); // If cleared and program not found, make a new program instance
mVU->prog.cleared = 0;
mVU->prog.isSame = 1;
mVUcurProg.startPC = startPC / 8;
void* entryPoint = mVUblockFetch(mVU, startPC, pState);
quick.block = mVUcurProg.block[startPC/8];
quick.prog = &mVUcurProg;
list.list->push_front(&mVUcurProg);
// If cleared and program not found, make a new program instance
mVU->prog.cleared = 0;
mVU->prog.isSame = 1;
mVU->prog.cur = mVUcreateProg<vuIndex>(startPC/8);
void* entryPoint = mVUblockFetch(mVU, startPC, pState);
quick.block = mVU->prog.cur->block[startPC/8];
quick.prog = mVU->prog.cur;
list.list->push_front(mVU->prog.cur);
return entryPoint;
}
// If list.quick, then we've already found and recompiled the program ;)
mVU->prog.isSame = -1;
mVU->prog.cur = quick.prog;
//mVU->prog.cur->used = 1;
//mVU->prog.cur->age = isYoung;
return mVUentryGet(mVU, quick.block, startPC, pState); // If list.quick, then we've already found and recompiled the program ;)
return mVUentryGet(mVU, quick.block, startPC, pState);
}
//------------------------------------------------------------------

View File

@ -128,11 +128,8 @@ struct microProgram {
u32 data [mProgSize]; // Holds a copy of the VU microProgram
microBlockManager* block[mProgSize/2]; // Array of Block Managers
microRange ranges; // The ranges of the microProgram that have already been recompiled
u32 frame; // Frame # the program was last used on
u32 used; // Program was used this frame?
int age; // Program age... Young, Aged, Old, or Dead...
int idx; // Program idx in array[mMaxProg]
u32 startPC; // Start PC of this program
u32 startPC; // Start PC of this program
int idx; // Program index
};
struct microProgramList {
@ -217,7 +214,7 @@ mVUop(mVUopU);
mVUop(mVUopL);
// Private Functions
_mVUt _f void mVUclearProg(microProgram& prog, bool deleteBlocks = 1);
_mVUt _f void mVUclearProg(microProgram& prog, u32 startPC = -1, bool deleteBlocks = 1);
_mVUt _f void mVUcacheProg(microProgram& prog);
_mVUt _f void* mVUsearchProg(u32 startPC, uptr pState);
_mVUt _f microProgram* mVUfindLeastUsedProg();