This commit is contained in:
Pavel 2024-11-13 15:49:39 +03:00
parent 9c4f46e033
commit 431645854a
2 changed files with 159 additions and 51 deletions

View File

@ -16,6 +16,7 @@ uses
si_ci_vi_merged_enum, si_ci_vi_merged_enum,
sys_bootparam, sys_bootparam,
host_ipc_interface,
md_sleep, md_sleep,
Vulkan, Vulkan,
@ -192,6 +193,8 @@ type
var var
use_renderdoc_capture:Boolean=False; use_renderdoc_capture:Boolean=False;
wait_loop_detect :Boolean=True;
wait_loop_autoskip :Boolean=False;
implementation implementation
@ -2566,9 +2569,15 @@ begin
end; end;
end; end;
function SendWarnMsg(const s:RawByteString):Integer;
begin
Result:=p_host_ipc.SendSync(HashIpcStr('WARNING'),Length(s)+1,pchar(s));
end;
procedure pm4_WaitRegMem(var ctx:t_me_render_context;node:p_pm4_node_WaitRegMem); procedure pm4_WaitRegMem(var ctx:t_me_render_context;node:p_pm4_node_WaitRegMem);
label label
_repeat; _repeat,
_reset;
var var
wait_addr:p_me_wait_addr; wait_addr:p_me_wait_addr;
begin begin
@ -2597,12 +2606,30 @@ begin
// //
Inc(ctx.stream^.hint_loop); Inc(ctx.stream^.hint_loop);
// //
if wait_loop_detect then
if (ctx.stream^.hint_loop>10000) then if (ctx.stream^.hint_loop>10000) then
begin begin
//loop detection //loop detection
Writeln(stderr,'WaitReg loop detected 0x',HexStr(QWORD(node^.pollAddr),10),' -> skip'); if wait_loop_autoskip then
Exit; begin
end; Writeln(stderr,'WaitRegMem hang detected 0x',HexStr(QWORD(node^.pollAddr),10),' -> skip');
goto _reset;
end else
begin
Writeln(stderr,'WaitRegMem hang detected 0x',HexStr(QWORD(node^.pollAddr),10));
//
if SendWarnMsg('Hang in WaitRegMem instruction detected, skip instruction?')=0 then
begin
Writeln(stderr,' -> skip');
goto _reset;
end else
begin
Writeln(stderr,' -> repeat');
ctx.stream^.hint_loop:=0;
end;
//
end;
end; //hint_loop
// //
ctx.switch_task; ctx.switch_task;
//early check //early check
@ -2611,10 +2638,12 @@ begin
goto _repeat; goto _repeat;
end; end;
// //
Exit; Exit; //dont reset wait addr
end; end;
wait_addr^.set_adr(ctx.me^.gc_kqueue,nil); _reset:
ctx.stream^.hint_loop:=0;
wait_addr^.set_adr(ctx.me^.gc_kqueue,nil);
end; end;
// //

View File

@ -151,6 +151,7 @@ type
function OnMainWindows (mlen:DWORD;buf:Pointer):Ptruint; //MAIN_WINDOWS function OnMainWindows (mlen:DWORD;buf:Pointer):Ptruint; //MAIN_WINDOWS
function OnCaptionFPS (mlen:DWORD;buf:Pointer):Ptruint; //CAPTION_FPS function OnCaptionFPS (mlen:DWORD;buf:Pointer):Ptruint; //CAPTION_FPS
function OnError (mlen:DWORD;buf:Pointer):Ptruint; //ERROR function OnError (mlen:DWORD;buf:Pointer):Ptruint; //ERROR
function OnWarning (mlen:DWORD;buf:Pointer):Ptruint; //WARNING
function OnParamSfoInit(mlen:DWORD;buf:Pointer):Ptruint; //PARAM_SFO_INIT function OnParamSfoInit(mlen:DWORD;buf:Pointer):Ptruint; //PARAM_SFO_INIT
function OnPlaygoInit (mlen:DWORD;buf:Pointer):Ptruint; //PLAYGO_INIT function OnPlaygoInit (mlen:DWORD;buf:Pointer):Ptruint; //PLAYGO_INIT
@ -244,20 +245,96 @@ begin
Result := ((-fd.Height) * 72) div Font.PixelsPerInch; Result := ((-fd.Height) * 72) div Font.PixelsPerInch;
end; end;
const
MsgDlgBtnToStr: array[TMsgDlgBtn] of PChar = (
'&Yes',
'&No',
'&OK',
'&Cancel',
'&Abort',
'&Retry',
'&Ignore',
'&All',
'&NoToAll',
'&YesToAll',
'&Help',
'&Close'
);
MsgDlgBtnToResult: array[TMsgDlgBtn] of Byte = (
mrYes,
mrNo,
mrOK,
mrCancel,
mrAbort,
mrRetry,
mrIgnore,
mrAll,
mrNoToAll,
mrYesToAll,
mrNone, //Help
mrClose
);
type
TMsgDlgAButtons=array of TMsgDlgBtn;
function MessageDlgEx(const AMsg:RawByteString; function MessageDlgEx(const AMsg:RawByteString;
ADlgType:TMsgDlgType; const ACaption:RawByteString;
AButtons:TMsgDlgButtons; AButtons:TMsgDlgAButtons;
AParent:TForm):TModalResult; AParent:TForm):TModalResult;
var var
MsgForm:TForm; MsgForm:TForm;
MsgMemo:TMemo; MsgMemo:TMemo;
MsgBtnz:TButton; MsgBtnz:TButton;
//(asrTop, asrBottom, asrCenter);
Procedure NewBtn(DlgType:TMsgDlgBtn;DlgPos:TAnchorSideReference);
begin
MsgBtnz:=TButton.Create(MsgForm);
case DlgPos of
asrTop:
begin
MsgBtnz.Anchors:=[akLeft,akBottom];
MsgBtnz.AnchorSide[akLeft ].Control:=MsgForm;
MsgBtnz.AnchorSide[akLeft ].Side :=asrTop;
MsgBtnz.AnchorSide[akBottom].Control:=MsgForm;
MsgBtnz.AnchorSide[akBottom].Side :=asrBottom;
end;
asrBottom:
begin
MsgBtnz.Anchors:=[akRight,akBottom];
MsgBtnz.AnchorSide[akRight ].Control:=MsgForm;
MsgBtnz.AnchorSide[akRight ].Side :=asrBottom;
MsgBtnz.AnchorSide[akBottom].Control:=MsgForm;
MsgBtnz.AnchorSide[akBottom].Side :=asrBottom;
end;
asrCenter:
begin
MsgBtnz.Anchors:=[akLeft,akBottom];
MsgBtnz.AnchorSide[akLeft ].Control:=MsgForm;
MsgBtnz.AnchorSide[akLeft ].Side :=asrCenter;
MsgBtnz.AnchorSide[akBottom].Control:=MsgForm;
MsgBtnz.AnchorSide[akBottom].Side :=asrBottom;
end;
end;
MsgBtnz.BorderSpacing.Around :=10;
MsgBtnz.Constraints.MinHeight:=25;
MsgBtnz.Constraints.MinWidth :=75;
MsgBtnz.AutoSize :=True;
MsgBtnz.Caption :=MsgDlgBtnToStr[DlgType];
MsgBtnz.Parent :=MsgForm;
MsgBtnz.ModalResult:=MsgDlgBtnToResult[DlgType];
end;
begin begin
MsgBtnz:=nil; MsgBtnz:=nil;
MsgForm:=TForm.Create(nil); MsgForm:=TForm.Create(nil);
try try
MsgForm.Caption :='Error'; MsgForm.Caption :=ACaption;
MsgForm.Position :=poDesigned; MsgForm.Position :=poDesigned;
MsgForm.BorderIcons:=[biSystemMenu]; MsgForm.BorderIcons:=[biSystemMenu];
MsgForm.FormStyle :=fsSystemStayOnTop; MsgForm.FormStyle :=fsSystemStayOnTop;
@ -266,40 +343,24 @@ begin
MsgForm.Width :=400; MsgForm.Width :=400;
MsgForm.Height:=200; MsgForm.Height:=200;
// //
if (mbOK in AButtons) then Case Length(AButtons) of
begin 0:;
MsgBtnz:=TButton.Create(MsgForm); 1:
MsgBtnz.Anchors:=[akLeft,akBottom]; begin
MsgBtnz.AnchorSide[akLeft ].Control:=MsgForm; NewBtn(AButtons[0],asrTop);
MsgBtnz.AnchorSide[akLeft ].Side :=asrTop; end;
MsgBtnz.AnchorSide[akBottom].Control:=MsgForm; 2:
MsgBtnz.AnchorSide[akBottom].Side :=asrBottom; begin
MsgBtnz.BorderSpacing.Bottom:=10; NewBtn(AButtons[0],asrTop);
MsgBtnz.BorderSpacing.Left :=10; NewBtn(AButtons[1],asrBottom);
MsgBtnz.Constraints.MinHeight:=25; end;
MsgBtnz.Constraints.MinWidth :=75; 3:
MsgBtnz.AutoSize:=True; begin
MsgBtnz.Caption:='OK'; NewBtn(AButtons[0],asrTop);
MsgBtnz.Parent:=MsgForm; NewBtn(AButtons[1],asrCenter);
MsgBtnz.ModalResult:=mrOK; NewBtn(AButtons[2],asrBottom);
end; end;
// else;
if (mbAbort in AButtons) then
begin
MsgBtnz:=TButton.Create(MsgForm);
MsgBtnz.Anchors:=[akRight,akBottom];
MsgBtnz.AnchorSide[akRight ].Control:=MsgForm;
MsgBtnz.AnchorSide[akRight ].Side :=asrBottom;
MsgBtnz.AnchorSide[akBottom].Control:=MsgForm;
MsgBtnz.AnchorSide[akBottom].Side :=asrBottom;
MsgBtnz.BorderSpacing.Bottom:=10;
MsgBtnz.BorderSpacing.Right :=10;
MsgBtnz.Constraints.MinHeight:=25;
MsgBtnz.Constraints.MinWidth :=75;
MsgBtnz.Caption:='Abort';
MsgBtnz.AutoSize:=True;
MsgBtnz.Parent:=MsgForm;
MsgBtnz.ModalResult:=mrAbort;
end; end;
// //
MsgMemo:=TMemo.Create(MsgForm); MsgMemo:=TMemo.Create(MsgForm);
@ -397,7 +458,7 @@ end;
function TfrmMain.OnError(mlen:DWORD;buf:Pointer):Ptruint; //ERROR function TfrmMain.OnError(mlen:DWORD;buf:Pointer):Ptruint; //ERROR
begin begin
Result:=0; Result:=0;
if (MessageDlgEx(PChar(buf),mtError,[mbOK,mbAbort],Self)=mrAbort) then if (MessageDlgEx(PChar(buf),'Error',[mbOK,mbAbort],Self)=mrAbort) then
begin begin
if (FGameProcess<>nil) then if (FGameProcess<>nil) then
if (FGameProcess.g_ipc<>nil) then if (FGameProcess.g_ipc<>nil) then
@ -407,6 +468,23 @@ begin
end; end;
end; end;
function TfrmMain.OnWarning(mlen:DWORD;buf:Pointer):Ptruint; //WARNING
begin
Result:=MessageDlgEx(PChar(buf),'Warning',[mbYes,mbNo,mbAbort],Self);
if (Result=mrAbort) then
begin
if (FGameProcess<>nil) then
if (FGameProcess.g_ipc<>nil) then
begin
FGameProcess.g_ipc.FStop:=True;
end;
end;
if (Result=mrYes) then
begin
Result:=0;
end;
end;
function TfrmMain.OnParamSfoInit(mlen:DWORD;buf:Pointer):Ptruint; //PARAM_SFO_INIT function TfrmMain.OnParamSfoInit(mlen:DWORD;buf:Pointer):Ptruint; //PARAM_SFO_INIT
var var
ParamSfo:TParamSfoFile; ParamSfo:TParamSfoFile;
@ -428,7 +506,7 @@ begin
begin begin
V:='"{$GAME}/sce_sys/param.sfo" not found, continue?'; V:='"{$GAME}/sce_sys/param.sfo" not found, continue?';
if (MessageDlgEx(V,mtError,[mbOK,mbAbort],Self)=mrOK) then if (MessageDlgEx(V,'Error',[mbOK,mbAbort],Self)=mrOK) then
begin begin
Exit(0); Exit(0);
end else end else
@ -468,7 +546,7 @@ begin
begin begin
V:='"{$GAME}/sce_sys/playgo-chunk.dat" not found, continue?'; V:='"{$GAME}/sce_sys/playgo-chunk.dat" not found, continue?';
if (MessageDlgEx(V,mtError,[mbOK,mbAbort],Self)=mrOK) then if (MessageDlgEx(V,'Error',[mbOK,mbAbort],Self)=mrOK) then
begin begin
Exit(0); Exit(0);
end else end else
@ -662,7 +740,7 @@ begin
JReader.Execute(FConfigInfo); JReader.Execute(FConfigInfo);
except except
on E: Exception do on E: Exception do
MessageDlgEx(E.Message,mtError,[mbOK],Self); MessageDlgEx(E.Message,'Error',[mbOK],Self);
end; end;
FreeAndNil(JReader); FreeAndNil(JReader);
FreeAndNil(m); FreeAndNil(m);
@ -683,7 +761,7 @@ begin
JReader.Execute(obj); JReader.Execute(obj);
except except
on E: Exception do on E: Exception do
MessageDlgEx(E.Message,mtError,[mbOK],Self); MessageDlgEx(E.Message,'Error',[mbOK],Self);
end; end;
FreeAndNil(JReader); FreeAndNil(JReader);
FreeAndNil(m); FreeAndNil(m);
@ -726,7 +804,7 @@ begin
M.SaveToFile(GameListFile); M.SaveToFile(GameListFile);
except except
on E: Exception do on E: Exception do
MessageDlgEx(E.Message,mtError,[mbOK],Self); MessageDlgEx(E.Message,'Error',[mbOK],Self);
end; end;
FreeAndNil(M); FreeAndNil(M);
@ -770,6 +848,7 @@ begin
IpcHandler.AddCallback('MAIN_WINDOWS' ,@OnMainWindows ); IpcHandler.AddCallback('MAIN_WINDOWS' ,@OnMainWindows );
IpcHandler.AddCallback('CAPTION_FPS' ,@OnCaptionFPS ); IpcHandler.AddCallback('CAPTION_FPS' ,@OnCaptionFPS );
IpcHandler.AddCallback('ERROR' ,@OnError ); IpcHandler.AddCallback('ERROR' ,@OnError );
IpcHandler.AddCallback('WARNING', @OnWarning );
IpcHandler.AddCallback('PARAM_SFO_INIT',@OnParamSfoInit); IpcHandler.AddCallback('PARAM_SFO_INIT',@OnParamSfoInit);
IpcHandler.AddCallback('PLAYGO_INIT' ,@OnPlaygoInit ); IpcHandler.AddCallback('PLAYGO_INIT' ,@OnPlaygoInit );
@ -1127,7 +1206,7 @@ begin
M.SaveToFile(fpps4File); M.SaveToFile(fpps4File);
except except
on E: Exception do on E: Exception do
MessageDlgEx(E.Message,mtError,[mbOK],Self); MessageDlgEx(E.Message,'Error',[mbOK],Self);
end; end;
FreeAndNil(M); FreeAndNil(M);
@ -1284,7 +1363,7 @@ begin
r:='Game process stopped with exit code:0x'+HexStr(exit_code,8); r:='Game process stopped with exit code:0x'+HexStr(exit_code,8);
FileWrite(FAddHandle,PChar(r)^,Length(r)); FileWrite(FAddHandle,PChar(r)^,Length(r));
MessageDlgEx(r,mtError,[mbOK],Self); MessageDlgEx(r,'Error',[mbOK],Self);
end; end;
end else end else