This commit is contained in:
Pavel 2024-08-08 11:10:43 +03:00
parent 3776950a22
commit e11e4ba7b5
2 changed files with 59 additions and 12 deletions

View File

@ -75,7 +75,7 @@ type
end;
//
event:PRTLEvent;
//on_idle:TProcedure;
on_idle:TProcedure;
on_submit_flip_eop:t_on_submit_flip_eop;
//
started:Pointer;
@ -162,7 +162,7 @@ type
//
procedure switch_task;
procedure next_task;
//procedure on_idle;
procedure on_idle;
end;
var
@ -673,7 +673,6 @@ begin
end;
end;
{
procedure t_me_render_context.on_idle;
begin
if (me^.on_idle<>nil) then
@ -681,7 +680,6 @@ begin
me^.on_idle();
end;
end;
}
//
@ -1892,7 +1890,6 @@ begin
ctx.me^.knote_eventid($40,0,curr*NSEC_PER_UNIT,0); //(absolute time) (freq???)
end;
//ctx.on_idle;
end;
procedure pm4_SubmitFlipEop(var ctx:t_me_render_context;node:p_pm4_node_SubmitFlipEop);
@ -1922,7 +1919,6 @@ begin
ctx.me^.knote_eventid($40,0,curr*NSEC_PER_UNIT,0); //(absolute time) (freq???)
end;
//ctx.on_idle;
end;
function get_compute_pipe_id(buft:t_pm4_stream_type):Byte; inline;
@ -2016,7 +2012,6 @@ begin
ctx.me^.knote_eventid(get_compute_pipe_id(ctx.stream^.buft),0,curr*NSEC_PER_UNIT,0); //(absolute time) (freq???)
end;
//ctx.on_idle;
end;
procedure pm4_EventWrite(var ctx:t_me_render_context;node:p_pm4_node_EventWrite);
@ -2104,7 +2099,6 @@ begin
Assert(false,'pm4_EventWriteEos');
end;
//ctx.on_idle;
end;
procedure pm4_WriteData(var ctx:t_me_render_context;node:p_pm4_node_WriteData);
@ -2299,7 +2293,7 @@ begin
begin
Inc(ctx.stream^.hint_loop);
//
if (ctx.stream^.hint_loop>1000) then
if (ctx.stream^.hint_loop>10000) then
begin
//loop detection
Writeln(stderr,'WaitReg loop detected -> skip');
@ -2472,8 +2466,9 @@ begin
me^.reset_sheduler;
ctx.rel_time:=0; //reset time
//
//ctx.on_idle;
ctx.on_idle;
//
RTLEventWaitFor(me^.event);

View File

@ -10,6 +10,9 @@ uses
procedure gc_initialize();
var
sync_me_submit:Boolean=False; //forced wait for all tasks to complete on the GPU side after submit
implementation
uses
@ -158,6 +161,9 @@ var
GC_SRI_event:PRTLEvent=nil;
GC_SRI_label:QWORD=0;
me_idle_event:PRTLEvent=nil;
me_idle_label:QWORD=0;
parse_gfx_started:Pointer=nil;
parse_gfx_td:p_kthread;
@ -431,7 +437,7 @@ begin
end;
end;
procedure gc_idle; {register;}
procedure gc_idle;
begin
if (GC_SRI_event<>nil) then
begin
@ -445,6 +451,38 @@ begin
end;
end;
procedure me_idle; register;
begin
if (me_idle_event<>nil) then
begin
RTLEventSetEvent(me_idle_event);
end;
me_idle_label:=0;
end;
procedure wait_me_idle;
begin
if (me_idle_label=0) then Exit;
if (me_idle_event<>nil) then
begin
RTLEventWaitFor(me_idle_event);
end;
end;
procedure reset_me_idle;
begin
me_idle_label:=1;
if (me_idle_event=nil) then
begin
me_idle_event:=RTLEventCreate;
end else
begin
RTLEventResetEvent(me_idle_event);
end;
end;
procedure gc_imdone;
var
prev:QWORD;
@ -798,6 +836,12 @@ begin
$C0108102: //submit
begin
if sync_me_submit then
begin
reset_me_idle;
end;
//
start_gfx_ring;
rw_wlock(ring_gfx_lock);
@ -811,7 +855,15 @@ begin
if (Result=0) then
begin
retrigger_watchdog;
if sync_me_submit then
begin
//force wait GPU idle
wait_me_idle;
end;
//msleep_td(hz);
end;
end;
$C020810C: //submit eop
@ -1142,7 +1194,7 @@ begin
gc_ring_create(@ring_gfx,GC_RING_SIZE);
pm4_me_gfx.Init(@gc_knlist);
//pm4_me_gfx.on_idle:=@gc_idle;
pm4_me_gfx.on_idle:=@me_idle;
pm4_me_gfx.on_submit_flip_eop:=@dev_dce.TriggerFlipEop;
end;