From 144fedd5509c90bcd962c6e9559377306d78ea80 Mon Sep 17 00:00:00 2001 From: red-prig Date: Mon, 17 Oct 2022 02:18:56 +0300 Subject: [PATCH] + --- chip/ps4_videodrv.pas | 35 +++++++++++++++++++++++++++-------- fpPS4.lpi | 2 ++ src/ps4_libscegnmdriver.pas | 23 ++++++++++++++++++++++- src/ps4_libsceime.pas | 22 +++++++++++++++++++++- 4 files changed, 72 insertions(+), 10 deletions(-) diff --git a/chip/ps4_videodrv.pas b/chip/ps4_videodrv.pas index 835fb8b1..4d915a56 100644 --- a/chip/ps4_videodrv.pas +++ b/chip/ps4_videodrv.pas @@ -69,6 +69,8 @@ const procedure vSubmitDone; +function vSubmitsAllowed:Boolean; + var DEPTH_DISABLE_HACK:Boolean=false; COMPUTE_DISABLE_HACK:Boolean=false; @@ -164,6 +166,9 @@ var FIdleEvent:PRTLEvent=nil; + FSubmitEvent:PRTLEvent=nil; + FSubmitAllowed:DWORD=0; + GPU_REGS:TGPU_REGS; FCmdPool:TvCmdPool; @@ -420,10 +425,10 @@ begin begin if me_node_test(GFXMicroEngine.Current) then begin - if (GFXMicroEngine.Current^.mode=metCmdBuffer) then - begin - RTLEventSetEvent(FIdleEvent); - end; + //if (GFXMicroEngine.Current^.mode=metCmdBuffer) then + //begin + // RTLEventSetEvent(FIdleEvent); + //end; end else begin time:=-100000; @@ -462,6 +467,9 @@ begin FIdleEvent:=RTLEventCreate; RTLEventSetEvent(FIdleEvent); + FSubmitEvent:=RTLEventCreate; + RTLEventSetEvent(FSubmitEvent); + t:=BeginThread(@GFX_thread); _gfx_handle:=t; @@ -607,14 +615,25 @@ end; procedure vSubmitDone; begin - if (FIdleEvent<>nil) then + if (FIdleEvent<>nil) and (FSubmitEvent<>nil) then begin - RTLEventWaitFor(FIdleEvent); + While not CAS(FSubmitAllowed,0,1) do + begin + RTLEventWaitFor(FSubmitEvent); //wait another vSubmitDone + end; + RTLEventResetEvent(FSubmitEvent); + + RTLEventWaitFor(FIdleEvent,2000); //wait idle GPU + + RTLEventSetEvent(FSubmitEvent); + store_release(FSubmitAllowed,0); end; - //Sleep(100); - //Device.WaitIdle; end; +function vSubmitsAllowed:Boolean; +begin + Result:=FSubmitAllowed=0; +end; procedure onPrepareFlip(); begin diff --git a/fpPS4.lpi b/fpPS4.lpi index 3796b439..a8d60ee4 100644 --- a/fpPS4.lpi +++ b/fpPS4.lpi @@ -302,6 +302,7 @@ + @@ -316,6 +317,7 @@ + diff --git a/src/ps4_libscegnmdriver.pas b/src/ps4_libscegnmdriver.pas index 22abd641..caa187c5 100644 --- a/src/ps4_libscegnmdriver.pas +++ b/src/ps4_libscegnmdriver.pas @@ -1300,6 +1300,9 @@ end; // +var + SceSubmitDoneGame:TRTLCriticalSection; + function ps4_sceGnmSubmitCommandBuffersForWorkload( workload:QWORD; count:DWORD; @@ -1322,7 +1325,11 @@ begin Submit.ccbSizesInBytes:=ccbSizesInBytes; _sig_lock; + EnterCriticalSection(SceSubmitDoneGame); + Result:=vSubmitCommandBuffers(@Submit,nil); + + LeaveCriticalSection(SceSubmitDoneGame); _sig_unlock; Result:=0; @@ -1380,7 +1387,11 @@ begin Flip.flipArg :=flipArg; _sig_lock; + EnterCriticalSection(SceSubmitDoneGame); + Result:=vSubmitCommandBuffers(@Submit,@Flip); + + LeaveCriticalSection(SceSubmitDoneGame); _sig_unlock; Result:=0; @@ -1449,8 +1460,12 @@ begin Flip.flipArg :=flipArg; _sig_lock; + EnterCriticalSection(SceSubmitDoneGame); + Result:=vSubmitCommandBuffers(@Submit,@Flip); vSubmitDone; + + LeaveCriticalSection(SceSubmitDoneGame); _sig_unlock; Result:=0; @@ -1482,7 +1497,11 @@ begin //exit(0); _sig_lock; + EnterCriticalSection(SceSubmitDoneGame); + vSubmitDone; + + LeaveCriticalSection(SceSubmitDoneGame); _sig_unlock; Result:=0; @@ -1512,7 +1531,7 @@ end; //A value of true is returned if submit/dingdong is allowed; otherwise false is returned. function ps4_sceGnmAreSubmitsAllowed:Boolean; SysV_ABI_CDecl; begin - Result:=true; + Result:=vSubmitsAllowed; end; const @@ -1742,6 +1761,8 @@ end; initialization GnmInitEmbedded; + InitCriticalSection(SceSubmitDoneGame); + EopEvents.Init; ComputeEvents[0].Init; ComputeEvents[1].Init; diff --git a/src/ps4_libsceime.pas b/src/ps4_libsceime.pas index 341370f3..475b7291 100644 --- a/src/ps4_libsceime.pas +++ b/src/ps4_libsceime.pas @@ -11,11 +11,30 @@ uses implementation +type + pSceImeEvent=^SceImeEvent; + SceImeEvent=packed record + id:Integer; //SceImeEventId + //param:SceImeEventParam; + end; + + SceImeEventHandler=procedure(arg:Pointer;e:pSceImeEvent); + + pSceImeKeyboardParam=^SceImeKeyboardParam; + SceImeKeyboardParam=packed record + option:DWORD; + reserved1:DWORD; + arg:Pointer; + handler:SceImeEventHandler; + reserved2:QWORD; + end; + function ps4_sceImeKeyboardOpen( userId:Integer; - param:Pointer //SceImeKeyboardParam + param:pSceImeKeyboardParam ):Integer; SysV_ABI_CDecl; begin + Writeln('sceImeKeyboardOpen:',userId,' ',HexStr(param)); Result:=Integer($80BC0004); end; @@ -23,6 +42,7 @@ function ps4_sceImeUpdate( handler:Pointer //SceImeEventHandler ):Integer; SysV_ABI_CDecl; begin + Writeln('sceImeUpdate:',HexStr(handler)); Result:=Integer($80BC0004); end;