mirror of
https://github.com/red-prig/fpPS4.git
synced 2024-10-07 03:33:20 +00:00
Exponential backoff strategy for gfx thread
This commit is contained in:
parent
711bc11b47
commit
b214aee42f
@ -423,9 +423,47 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
type
|
||||
gfx_backoff_exp=object
|
||||
private
|
||||
Const
|
||||
lower_bound = 1000;
|
||||
upper_bound = 100000;
|
||||
Var
|
||||
m_nExpCur:SizeUInt;
|
||||
public
|
||||
Procedure Wait;
|
||||
Procedure Reset;
|
||||
end;
|
||||
|
||||
Procedure gfx_backoff_exp.Wait;
|
||||
Var
|
||||
time:Int64;
|
||||
begin
|
||||
if (m_nExpCur<=upper_bound) then
|
||||
begin
|
||||
m_nExpCur:=m_nExpCur*2;
|
||||
end;
|
||||
time:=-m_nExpCur;
|
||||
NtDelayExecution(True,@time);
|
||||
end;
|
||||
|
||||
Procedure gfx_backoff_exp.Reset; inline;
|
||||
begin
|
||||
m_nExpCur:=lower_bound;
|
||||
end;
|
||||
|
||||
Procedure WaitSubmit; inline;
|
||||
Var
|
||||
time:Int64;
|
||||
begin
|
||||
time:=Int64(NT_INFINITE);
|
||||
NtDelayExecution(True,@time);
|
||||
end;
|
||||
|
||||
function GFX_thread(p:pointer):ptrint;
|
||||
var
|
||||
time:Int64;
|
||||
backoff:gfx_backoff_exp;
|
||||
work_do:Boolean;
|
||||
begin
|
||||
Result:=0;
|
||||
@ -434,6 +472,7 @@ begin
|
||||
|
||||
SetThreadDebugName(GetCurrentThreadId, 'GFX Thread');
|
||||
|
||||
backoff.Reset;
|
||||
repeat
|
||||
work_do:=False;
|
||||
|
||||
@ -453,24 +492,24 @@ begin
|
||||
//end;
|
||||
end else
|
||||
begin
|
||||
time:=-1000;
|
||||
NtDelayExecution(True,@time);
|
||||
backoff.Wait;
|
||||
Continue;
|
||||
end;
|
||||
work_do:=True;
|
||||
backoff.Reset;
|
||||
end;
|
||||
|
||||
if GFXMicroEngine.Next then
|
||||
begin
|
||||
me_node_submit(GFXMicroEngine.Current);
|
||||
work_do:=True;
|
||||
backoff.Reset;
|
||||
end;
|
||||
|
||||
if not work_do then
|
||||
begin
|
||||
SetEvent(FIdleEvent);
|
||||
time:=Int64(NT_INFINITE);
|
||||
NtDelayExecution(True,@time);
|
||||
WaitSubmit;
|
||||
end;
|
||||
|
||||
until false;
|
||||
|
Loading…
Reference in New Issue
Block a user