Beispiel #1
0
int RSP_ThreadProc(void *param)
{
    RSP_Init();
    while(true)
    {
        int num = 0;

        RSP.threadIdle = RSP.threadEvents.empty();

        //process all events
        while(!RSP.threadEvents.empty())
        {
            switch (RSP.threadEvents.front())
            {
                case (RSPMSG_PROCESSDLIST):
                    RSP_ProcessDList();
                    break;
                case (RSPMSG_UPDATESCREEN):
                    VI_UpdateScreen();
                    break;
                case (RSPMSG_CLOSE):
                    OGL_Stop();
                    return 0;
                    break;
                case (RSPMSG_DESTROYTEXTURES):
                    Combiner_Destroy();
                    TextureCache_Destroy();
                    break;
                case (RSPMSG_INITTEXTURES):
                    TextureCache_Init();
                    Combiner_Init();
                    gSP.changed = gDP.changed = 0xFFFFFFFF;
                    break;
                case (RSPMSG_CAPTURESCREEN):
                    OGL_SaveScreenshot();
                    break;
            }
            RSP.threadEvents.pop();
            num++;
        }
    }

    return 0;
}
EXPORT void CALL ProcessDList(void)
{
    OGL.frame_dl++;

    if (frameSkipper.willSkipNext())
    {
        OGL.frameSkipped++;
        RSP.busy = FALSE;
        RSP.DList++;

        /* avoid hang on frameskip */
        *REG.MI_INTR |= MI_INTR_DP;
        CheckInterrupts();
        *REG.MI_INTR |= MI_INTR_SP;
        CheckInterrupts();
        return;
    }

    OGL.consecutiveSkips = 0;
    RSP_ProcessDList();
    OGL.mustRenderDlist = true;
}
void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx, std::condition_variable_any * _pRspThreadCv, std::condition_variable_any * _pPluginThreadCv, API_COMMAND * _pCommand)
{
	_pRspThreadMtx->lock();
	RSP_Init();
	GBI.init();
	Config_LoadConfig();
	video().start();
	assert(!isGLError());

	while (true) {
		_pPluginThreadMtx->lock();
		_pPluginThreadCv->notify_one();
		_pPluginThreadMtx->unlock();
		_pRspThreadCv->wait(*_pRspThreadMtx);
		switch (*_pCommand) {
		case acProcessDList:
			RSP_ProcessDList();
			break;
		case acProcessRDPList:
			RDP_ProcessRDPList();
			break;
		case acUpdateScreen:
			VI_UpdateScreen();
			break;
		case acRomClosed:
			TFH.shutdown();
			video().stop();
			GBI.destroy();
			*_pCommand = acNone;
			_pRspThreadMtx->unlock();
			_pPluginThreadMtx->lock();
			_pPluginThreadCv->notify_one();
			_pPluginThreadMtx->unlock();
			return;
		}
		assert(!isGLError());
		*_pCommand = acNone;
	}
}
EXPORT void CALL ProcessDList(void)
{
    OGL.frame_dl++;

    if (config.autoFrameSkip)
    {
        OGL_UpdateFrameTime();

        if (OGL.consecutiveSkips < 1)
        {
            unsigned t = 0;
            for(int i = 0; i < OGL_FRAMETIME_NUM; i++) t += OGL.frameTime[i];
            t *= config.targetFPS;
            if (config.romPAL) t = (t * 5) / 6;
            if (t > (OGL_FRAMETIME_NUM * 1000))
            {
                OGL.consecutiveSkips++;
                OGL.frameSkipped++;
                RSP.busy = FALSE;
                RSP.DList++;
                return;
            }
        }
    }
    else if ((OGL.frame_vsync % config.frameRenderRate) != 0)
    {
        OGL.frameSkipped++;
        RSP.busy = FALSE;
        RSP.DList++;
        return;
    }

    OGL.consecutiveSkips = 0;
    RSP_ProcessDList();
    OGL.mustRenderDlist = true;
}
	bool run() {
		RSP_ProcessDList();
		return true;
	}