Found a better way to do the previous change. Allow JIT on mac/linux.

This commit is contained in:
Henrik Rydgård 2012-11-19 14:51:47 +01:00
parent fb25b7405c
commit 14a59fdc75
4 changed files with 21 additions and 30 deletions

View File

@ -38,7 +38,8 @@ enum CoreState
CORE_RUNNING,
CORE_STEPPING,
CORE_POWERDOWN,
CORE_ERROR
CORE_ERROR,
CORE_NEXTFRAME,
};

View File

@ -25,6 +25,7 @@
#include "sceAudio.h"
#include "../Host.h"
#include "../Config.h"
#include "../Core/Core.h"
#include "sceDisplay.h"
#include "sceKernel.h"
#include "sceKernelThread.h"
@ -61,7 +62,6 @@ static int hCountTotal = 0; //unused
static int vCount = 0;
static int isVblank = 0;
static bool frameDone;
// STATE END
// The vblank period is 731.5 us (0.7315 ms)
@ -87,7 +87,6 @@ void hleLeaveVblank(u64 userdata, int cyclesLate);
void __DisplayInit()
{
framebufIsLatched = false;
frameDone = false;
framebuf.topaddr = 0x04000000;
framebuf.pspframebuf = Memory::GetPointer(0x04000000);
framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888;
@ -108,14 +107,6 @@ void __DisplayShutdown()
ShutdownGfxState();
}
// will return true once after every end-of-frame.
bool __DisplayFrameDone()
{
bool retVal = frameDone;
frameDone = false;
return retVal;
}
void hleEnterVblank(u64 userdata, int cyclesLate)
{
int vbCount = userdata;
@ -133,7 +124,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
CoreTiming::ScheduleEvent(msToCycles(vblankMs) - cyclesLate, leaveVblankEvent, vbCount+1);
// TODO: Should this be done here or in hleLeaveVblank?
if (framebufIsLatched)
if (framebufIsLatched)
{
DEBUG_LOG(HLE, "Setting latched framebuffer %08x (prev: %08x)", latchedFramebuf.topaddr, framebuf.topaddr);
framebuf = latchedFramebuf;
@ -141,7 +132,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
}
// Draw screen overlays before blitting. Saves and restores the Ge context.
/*
if (g_Config.bShowGPUStats)
{
@ -172,7 +163,10 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
}
// Tell the emu core that it's time to stop emulating
frameDone = true;
// Win32 doesn't need this.
#ifndef _WIN32
coreState = CORE_NEXTFRAME;
#endif
}

View File

@ -109,13 +109,7 @@ void MIPSState::SingleStep()
// returns 1 if reached ticks limit
int MIPSState::RunLoopUntil(u64 globalTicks)
{
// Don't subvert this by setting useJIT to true - other places also check the coreparameter
bool useJIT = PSP_CoreParameter().cpuCore == CPU_JIT;
#if defined(ANDROID) || defined(BLACKBERRY)
useJIT = false;
#endif
if (useJIT)
if (PSP_CoreParameter().cpuCore == CPU_JIT)
{
MIPSComp::jit->RunLoopUntil(globalTicks);
}
@ -194,12 +188,6 @@ int MIPSState::RunLoopUntil(u64 globalTicks)
// DEBUG_LOG(CPU, "Hit the max ticks, bailing 1 : %llu, %llu", globalTicks, CoreTiming::GetTicks());
return 1;
}
#ifndef _WIN32 // Windows simply keeps running and control the refresh from sceDisplay
if (__DisplayFrameDone()) {
// End of frame! Need to quit the CPU loop temporarily.
return 0;
}
#endif
}
CoreTiming::Advance();

View File

@ -47,7 +47,11 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true)
INFO_LOG(BOOT, "Starting up hardware.");
CoreParameter coreParam;
#if defined(ANDROID) || defined(BLACKBERRY)
coreParam.cpuCore = CPU_INTERPRETER;
#else
coreParam.cpuCore = g_Config.bJIT ? CPU_JIT : CPU_INTERPRETER;
#endif
coreParam.gpuCore = GPU_GLES;
coreParam.enableSound = g_Config.bEnableSound;
coreParam.fileToStart = fileToStart;
@ -150,11 +154,15 @@ void EmuScreen::render()
// Let's do 120 "blocks" per second just to try it
int blockTicks = usToCycles(1000000 / 120);
while (retval == 1) {
// Run until CORE_NEXTFRAME
while (coreState == CORE_RUNNING) {
u64 nowTicks = CoreTiming::GetTicks();
retval = mipsr4k.RunLoopUntil(nowTicks + blockTicks);
// If exited because of cycles, try again.
// If exited because of end of frame, great!
}
// Hopefully coreState is now CORE_NEXTFRAME
if (coreState == CORE_NEXTFRAME) {
// set back to running for the next frame
coreState = CORE_RUNNING;
}
//if (hasRendered)