public virtual void restartList() { paused = false; restarted = true; sync(); ExternalGE.onRestartList(this); }
public virtual int sceGeGetMtx(int mtxType, TPointer mtxAddr) { if (mtxType < 0 || mtxType > PSP_GE_MATRIX_TEXGEN) { Console.WriteLine(string.Format("sceGeGetMtx invalid type mtxType={0:D}", mtxType)); return(SceKernelErrors.ERROR_INVALID_INDEX); } float[] mtx; if (ExternalGE.Active) { mtx = ExternalGE.getMatrix(mtxType); } else { mtx = VideoEngine.Instance.getMatrix(mtxType); } for (int i = 0; i < mtx.Length; i++) { // Float value is returned in lower 24 bits. mtxAddr.setValue32(i << 2, (int)((uint)Float.floatToRawIntBits(mtx[i]) >> 8)); } if (log.InfoEnabled) { Console.WriteLine(string.Format("sceGeGetMtx mtxType={0:D}, mtxAddr={1}, mtx={2}", mtxType, mtxAddr, mtx)); } return(0); }
public override void stop() { Console.WriteLine(string.Format("Stopping {0}", Name)); if (ExternalGE.Active) { ExternalGE.onGeUserStop(); } }
public virtual int sceGeRestoreContext(TPointer contextAddr) { if (ExternalGE.Active) { return(ExternalGE.restoreContext(contextAddr.Address)); } VideoEngine.Instance.hleRestoreContext(contextAddr.Address); return(0); }
public virtual bool continueWaitState(SceKernelThreadInfo thread, ThreadWaitInfo wait) { // Continue the wait state until the list is done bool contineWait = !list.Done; if (!contineWait) { ExternalGE.onGeStopWaitList(); } return(contineWait); }
public static void exit() { if (DurationStatistics.collectStatistics) { Console.WriteLine(TextureCache.Instance.statistics); } RendererExecutor.exit(); VertexCache.Instance.exit(); Compiler.exit(); RuntimeContext.exit(); Profiler.exit(); GEProfiler.exit(); BaseRenderer.exit(); BasePrimitiveRenderer.exit(); ExternalGE.exit(); if (DurationStatistics.collectStatistics && Modules.ThreadManForUserModule.statistics != null && Modules.sceDisplayModule.statistics != null) { long totalMillis = Clock.milliTime(); long displayMillis = Modules.sceDisplayModule.statistics.cumulatedTimeMillis; long idleCpuMillis = RuntimeContext.idleDuration.CpuDurationMillis; long compilationCpuMillis = Compiler.compileDuration.CpuDurationMillis; long cpuMillis = Modules.ThreadManForUserModule.statistics.allCpuMillis - compilationCpuMillis - idleCpuMillis; long cpuCycles = Modules.ThreadManForUserModule.statistics.allCycles; double totalSecs = totalMillis / 1000.0; double displaySecs = displayMillis / 1000.0; double cpuSecs = cpuMillis / 1000.0; if (totalSecs != 0) { Console.WriteLine("Total execution time: " + string.Format("{0:F3}", totalSecs) + "s"); Console.WriteLine(" PSP CPU time: " + string.Format("{0:F3}", cpuSecs) + "s (" + string.Format("{0:F1}", cpuSecs / totalSecs * 100) + "%)"); Console.WriteLine(" Display time: " + string.Format("{0:F3}", displaySecs) + "s (" + string.Format("{0:F1}", displaySecs / totalSecs * 100) + "%)"); } if (VideoEngine.Statistics != null) { long videoCalls = VideoEngine.Statistics.numberCalls; if (videoCalls != 0) { Console.WriteLine("Elapsed time per frame: " + string.Format("{0:F3}", totalSecs / videoCalls) + "s:"); Console.WriteLine(" Display time: " + string.Format("{0:F3}", displaySecs / videoCalls)); Console.WriteLine(" PSP CPU time: " + string.Format("{0:F3}", cpuSecs / videoCalls) + " (" + (cpuCycles / videoCalls) + " instr)"); } if (totalSecs != 0) { Console.WriteLine("Display Speed: " + string.Format("{0:F2}", videoCalls / totalSecs) + " FPS"); } } if (cpuSecs != 0) { Console.WriteLine("PSP CPU Speed: " + string.Format("{0:F2}", cpuCycles / cpuSecs / 1000000.0) + "MHz (" + (long)(cpuCycles / cpuSecs) + " instructions per second)"); } } SoundChannel.exit(); }
public virtual void startListHead() { paused = false; ExternalGE.onGeStartList(this); if (ExternalGE.Active) { ExternalGE.startListHead(this); } else { videoEngine.pushDrawListHead(this); } }
public virtual void step() { ThreadManForUser threadMan = Modules.ThreadManForUserModule; for (int?thid = deferredThreadWakeupQueue.poll(); thid != null; thid = deferredThreadWakeupQueue.poll()) { //if (log.DebugEnabled) { Console.WriteLine("really waking thread " + thid.ToString("x") + "(" + threadMan.getThreadName(thid.Value) + ")"); } threadMan.hleUnblockThread(thid); ExternalGE.onGeStopWaitList(); } }
private void blockCurrentThreadOnList(PspGeList list, IAction action) { ThreadManForUser threadMan = Modules.ThreadManForUserModule; bool blockCurrentThread = false; bool executeAction = false; lock (this) { int currentThreadId = threadMan.CurrentThreadID; if (list.Done) { // There has been some race condition: the list has just completed // do not block the thread //if (log.DebugEnabled) { Console.WriteLine("blockCurrentThreadOnList not blocking thread " + currentThreadId.ToString("x") + ", list completed " + list); } executeAction = true; } else { //if (log.DebugEnabled) { Console.WriteLine("blockCurrentThreadOnList blocking thread " + currentThreadId.ToString("x") + " on list " + list); } list.blockedThreadIds.Add(currentThreadId); blockCurrentThread = true; } } // Execute the action outside of the synchronized block if (executeAction && action != null) { action.execute(); } // Block the thread outside of the synchronized block if (blockCurrentThread) { // Block the thread, but do not execute callbacks. threadMan.hleBlockCurrentThread(SceKernelThreadInfo.JPCSP_WAIT_GE_LIST, list.id, false, action, new ListSyncWaitStateChecker(list)); ExternalGE.onGeStartWaitList(); } }
public virtual int sceGeGetCmd(int cmd) { VideoEngine ve = VideoEngine.Instance; int value; if (ExternalGE.Active) { value = ExternalGE.getCmd(cmd); } else { value = ve.getCommandValue(cmd); } if (log.InfoEnabled) { Console.WriteLine(string.Format("sceGeGetCmd {0}: cmd=0x{1:X}, value=0x{2:X6}", ve.commandToString(cmd).ToUpper(), cmd, value)); } return(value); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: public int hleGeListEnQueue(pspsharp.HLE.TPointer listAddr, @CanBeNull pspsharp.HLE.TPointer stallAddr, int cbid, @CanBeNull pspsharp.HLE.TPointer argAddr, int saveContextAddr, bool enqueueHead) public virtual int hleGeListEnQueue(TPointer listAddr, TPointer stallAddr, int cbid, TPointer argAddr, int saveContextAddr, bool enqueueHead) { pspGeListOptParam optParams = null; int stackAddr = 0; if (argAddr.NotNull) { optParams = new pspGeListOptParam(); optParams.read(argAddr); stackAddr = optParams.stackAddr; saveContextAddr = optParams.contextAddr; //if (log.DebugEnabled) { Console.WriteLine(string.Format("hleGeListEnQueue optParams={0}", optParams)); } } bool useCachedMemory = false; if (Modules.SysMemUserForUserModule.hleKernelGetCompiledSdkVersion() >= 0x02000000) { bool isBusy; if (ExternalGE.Active) { isBusy = ExternalGE.hasDrawList(listAddr.Address, stackAddr); } else { isBusy = VideoEngine.Instance.hasDrawList(listAddr.Address, stackAddr); } if (isBusy) { Console.WriteLine(string.Format("hleGeListEnQueue can't enqueue duplicate list address {0}, stack 0x{1:X8}", listAddr, stackAddr)); return(SceKernelErrors.ERROR_BUSY); } } else { // Old games (i.e. having PSP SDK version < 2.00) are sometimes // reusing the same address for multiple lists, without waiting // for the previous list to complete. They assume that the lists // are being executed quite quickly, which is not the case when // using the OpenGL rendering engine. There is some delay before // the OpenGL frame refresh is being processed. useCachedMemory = true; } // No need to cache any memory when using the external software renderer if (ExternalGE.Active) { useCachedMemory = false; } int result; lock (this) { PspGeList list = listFreeQueue.poll(); if (list == null) { Console.WriteLine("hleGeListEnQueue no more free list available!"); //if (log.DebugEnabled) { for (int i = 0; i < NUMBER_GE_LISTS; i++) { Console.WriteLine(string.Format("List#{0:D}: {1}", i, allGeLists[i])); } } return(SceKernelErrors.ERROR_OUT_OF_MEMORY); } list.init(listAddr.Address, stallAddr.Address, cbid, optParams); list.SaveContextAddr = saveContextAddr; if (useCachedMemory) { setStallAddressWithCachedMemory(list, stallAddr.Address); } if (enqueueHead) { // Send the list to the VideoEngine at the head of the queue. list.startListHead(); } else { // Send the list to the VideoEngine before triggering the display (setting GE dirty) list.startList(); } Modules.sceDisplayModule.GeDirty = true; result = list.id; } //if (log.DebugEnabled) { Console.WriteLine(string.Format("hleGeListEnQueue returning 0x{0:X}", result)); } return(result); }
public virtual void finishList() { finished = true; ExternalGE.onGeFinishList(this); }