예제 #1
0
파일: System.cpp 프로젝트: dutea/ppsspp
void PSP_RunLoopUntil(u64 globalticks) {
	SaveState::Process();
	if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) {
		return;
	}

	if (cpuThread != NULL) {
		// Tell the gpu a new frame is about to begin, before we start the CPU.
		gpu->SyncBeginFrame();

		cpuThreadUntil = globalticks;
		if (CPU_NextState(CPU_THREAD_RUNNING, CPU_THREAD_EXECUTE)) {
			// The CPU doesn't actually respect cpuThreadUntil well, especially when skipping frames.
			// TODO: Something smarter?  Or force CPU to bail periodically?
			while (!CPU_IsReady()) {
				gpu->RunEventsUntil(CoreTiming::GetTicks() + msToCycles(1000));
				if (coreState != CORE_RUNNING) {
					CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsReady);
				}
			}
		} else {
			ERROR_LOG(CPU, "Unable to execute CPU run loop, unexpected state: %d", cpuThreadState);
		}
	} else {
		mipsr4k.RunLoopUntil(globalticks);
	}
}
예제 #2
0
파일: System.cpp 프로젝트: Alceris/ppsspp
void PSP_RunLoopUntil(u64 globalticks) {
	SaveState::Process();
	if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) {
		return;
	}

	// Switch the CPU thread on or off, as the case may be.
	bool useCPUThread = g_Config.bSeparateCPUThread;
	if (useCPUThread && cpuThread == nullptr) {
		// Need to start the cpu thread.
		Core_ListenShutdown(System_Wake);
		CPU_SetState(CPU_THREAD_RESUME);
		cpuThread = new std::thread(&CPU_RunLoop);
		cpuThreadID = cpuThread->get_id();
		cpuThread->detach();
		if (gpu) {
			gpu->SetThreadEnabled(true);
		}
		CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsReady);
	} else if (!useCPUThread && cpuThread != nullptr) {
		CPU_SetState(CPU_THREAD_QUIT);
		CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsShutdown);
		delete cpuThread;
		cpuThread = nullptr;
		cpuThreadID = std::thread::id();
		if (gpu) {
			gpu->SetThreadEnabled(false);
		}
	}

	if (cpuThread != nullptr) {
		// Tell the gpu a new frame is about to begin, before we start the CPU.
		gpu->SyncBeginFrame();

		cpuThreadUntil = globalticks;
		if (CPU_NextState(CPU_THREAD_RUNNING, CPU_THREAD_EXECUTE)) {
			// The CPU doesn't actually respect cpuThreadUntil well, especially when skipping frames.
			// TODO: Something smarter?  Or force CPU to bail periodically?
			while (!CPU_IsReady()) {
				gpu->RunEventsUntil(CoreTiming::GetTicks() + msToCycles(1000));
				if (coreState != CORE_RUNNING) {
					CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsReady);
				}
			}
		} else {
			ERROR_LOG(CPU, "Unable to execute CPU run loop, unexpected state: %d", cpuThreadState);
		}
	} else {
		mipsr4k.RunLoopUntil(globalticks);
	}

	gpu->CleanupBeforeUI();
}
예제 #3
0
void PSP_RunLoopUntil(u64 globalticks) {
	SaveState::Process();

	if (cpuThread != NULL) {
		cpuThreadUntil = globalticks;
		if (CPU_NextState(CPU_THREAD_RUNNING, CPU_THREAD_EXECUTE)) {
			// The CPU doesn't actually respect cpuThreadUntil well, especially when skipping frames.
			// TODO: Something smarter?  Or force CPU to bail periodically?
			while (!CPU_IsReady()) {
				gpu->RunEventsUntil(CoreTiming::GetTicks() + msToCycles(100));
			}
		} else {
			ERROR_LOG(CPU, "Unable to execute CPU run loop, unexpected state: %d", cpuThreadState);
		}
	} else {
		mipsr4k.RunLoopUntil(globalticks);
	}
}
예제 #4
0
파일: System.cpp 프로젝트: dutea/ppsspp
bool PSP_InitUpdate(std::string *error_string) {
	if (pspIsInited || !pspIsIniting) {
		return true;
	}

	if (g_Config.bSeparateCPUThread && !CPU_IsReady()) {
		return false;
	}

	bool success = coreParameter.fileToStart != "";
	*error_string = coreParameter.errorString;
	if (success) {
		success = GPU_Init();
		if (!success) {
			PSP_Shutdown();
			*error_string = "Unable to initialize rendering engine.";
		}
	}
	pspIsInited = success;
	pspIsIniting = false;
	return true;
}