mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
912bd9c8f9
commit
5000ec1d00
|
@ -13,6 +13,7 @@ uses
|
||||||
sys_event,
|
sys_event,
|
||||||
time,
|
time,
|
||||||
kern_mtx,
|
kern_mtx,
|
||||||
|
sys_bootparam,
|
||||||
display_interface;
|
display_interface;
|
||||||
|
|
||||||
procedure dce_initialize();
|
procedure dce_initialize();
|
||||||
|
@ -79,18 +80,23 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
callout_lock :mtx;
|
vblank:record
|
||||||
callout_vblank:t_callout;
|
lock :mtx;
|
||||||
callout_refs :Int64=0;
|
callout:t_callout;
|
||||||
|
refs :Int64;
|
||||||
|
|
||||||
vblank_count:QWORD=0;
|
count :QWORD;
|
||||||
vblank_tsc :QWORD=0;
|
tsc :QWORD;
|
||||||
|
|
||||||
|
fps_cnt:QWORD;
|
||||||
|
fps_tsc:QWORD;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure vblank_expire(arg:Pointer);
|
procedure vblank_expire(arg:Pointer);
|
||||||
var
|
var
|
||||||
i:QWORD;
|
i:QWORD;
|
||||||
begin
|
begin
|
||||||
if (callout_refs<>0) then
|
if (vblank.refs<>0) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
mtx_lock(dce_mtx);
|
mtx_lock(dce_mtx);
|
||||||
|
@ -102,16 +108,32 @@ begin
|
||||||
|
|
||||||
mtx_unlock(dce_mtx);
|
mtx_unlock(dce_mtx);
|
||||||
|
|
||||||
vblank_tsc:=rdtsc();
|
vblank.tsc:=rdtsc();
|
||||||
|
|
||||||
i:=vblank_count;
|
i:=vblank.count;
|
||||||
vblank_count:=vblank_count+1;
|
vblank.count:=vblank.count+1;
|
||||||
|
|
||||||
knote_eventid(EVENTID_PREVBLANK, i, 0); //SCE_VIDEO_OUT_EVENT_PRE_VBLANK_START
|
knote_eventid(EVENTID_PREVBLANK, i, 0); //SCE_VIDEO_OUT_EVENT_PRE_VBLANK_START
|
||||||
//
|
//
|
||||||
callout_reset(@callout_vblank, callout_vblank.c_time, @vblank_expire, nil);
|
callout_reset(@vblank.callout, vblank.callout.c_time, @vblank_expire, nil);
|
||||||
//
|
//
|
||||||
knote_eventid(EVENTID_VBLANK , i, 0); //SCE_VIDEO_OUT_EVENT_VBLANK
|
knote_eventid(EVENTID_VBLANK , i, 0); //SCE_VIDEO_OUT_EVENT_VBLANK
|
||||||
|
|
||||||
|
if (vblank.fps_tsc=0) then
|
||||||
|
begin
|
||||||
|
vblank.fps_tsc:=rdtsc();
|
||||||
|
vblank.fps_cnt:=0;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
//Inc(fps_cnt);
|
||||||
|
if ((rdtsc()-vblank.fps_tsc) div tsc_freq)>=1 then
|
||||||
|
begin
|
||||||
|
p_host_ipc.SetCaptionFPS(vblank.fps_cnt);
|
||||||
|
vblank.fps_cnt:=0;
|
||||||
|
vblank.fps_tsc:=rdtsc();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -119,16 +141,16 @@ procedure open_vblank;
|
||||||
var
|
var
|
||||||
time:Int64;
|
time:Int64;
|
||||||
begin
|
begin
|
||||||
if (System.InterlockedIncrement64(callout_refs)=1) then
|
if (System.InterlockedIncrement64(vblank.refs)=1) then
|
||||||
begin
|
begin
|
||||||
time:=round(hz/59.94);
|
time:=round(hz/59.94);
|
||||||
callout_reset(@callout_vblank, time, @vblank_expire, nil);
|
callout_reset(@vblank.callout, time, @vblank_expire, nil);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure close_vblank;
|
procedure close_vblank;
|
||||||
begin
|
begin
|
||||||
System.InterlockedDecrement64(callout_refs);
|
System.InterlockedDecrement64(vblank.refs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -406,6 +428,7 @@ begin
|
||||||
begin
|
begin
|
||||||
dce_handle.event_flip:=@g_video_out_event_flip;
|
dce_handle.event_flip:=@g_video_out_event_flip;
|
||||||
dce_handle.mtx :=@dce_mtx;
|
dce_handle.mtx :=@dce_mtx;
|
||||||
|
dce_handle.p_fps_cnt :=@vblank.fps_cnt;
|
||||||
Result:=dce_handle.Open();
|
Result:=dce_handle.Open();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -673,9 +696,9 @@ begin
|
||||||
|
|
||||||
u.v_vblank:=Default(t_vblank_args);
|
u.v_vblank:=Default(t_vblank_args);
|
||||||
|
|
||||||
u.v_vblank.count :=vblank_count;
|
u.v_vblank.count :=vblank.count;
|
||||||
u.v_vblank.processTime:=vblank_tsc;
|
u.v_vblank.processTime:=vblank.tsc;
|
||||||
u.v_vblank.tsc :=vblank_tsc;
|
u.v_vblank.tsc :=vblank.tsc;
|
||||||
|
|
||||||
Result:=copyout(@u.v_vblank,ptr,len);
|
Result:=copyout(@u.v_vblank,ptr,len);
|
||||||
|
|
||||||
|
@ -1261,8 +1284,8 @@ begin
|
||||||
|
|
||||||
knlist_init_mtx(@g_video_out_event_flip,@knlist_lock_flip);
|
knlist_init_mtx(@g_video_out_event_flip,@knlist_lock_flip);
|
||||||
|
|
||||||
mtx_init(callout_lock,'vblank_lock');
|
mtx_init(vblank.lock,'vblank.lock');
|
||||||
callout_init_mtx(@callout_vblank,callout_lock,0);
|
callout_init_mtx(@vblank.callout,vblank.lock,0);
|
||||||
|
|
||||||
kqueue_add_filteropts(EVFILT_DISPLAY,@filterops_display);
|
kqueue_add_filteropts(EVFILT_DISPLAY,@filterops_display);
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ type
|
||||||
event_flip:p_knlist;
|
event_flip:p_knlist;
|
||||||
mtx:p_mtx;
|
mtx:p_mtx;
|
||||||
last_status:t_flip_status;
|
last_status:t_flip_status;
|
||||||
|
p_fps_cnt:PQWORD;
|
||||||
procedure knote_eventid (event_id:WORD;flipArg:QWORD);
|
procedure knote_eventid (event_id:WORD;flipArg:QWORD);
|
||||||
function Open ():Integer; virtual;
|
function Open ():Integer; virtual;
|
||||||
function GetFlipStatus (status:p_flip_status):Integer; virtual;
|
function GetFlipStatus (status:p_flip_status):Integer; virtual;
|
||||||
|
|
|
@ -87,9 +87,6 @@ type
|
||||||
|
|
||||||
dst_cache:Pointer;
|
dst_cache:Pointer;
|
||||||
|
|
||||||
Ffps :QWORD;
|
|
||||||
Ftsc_prev:QWORD;
|
|
||||||
|
|
||||||
function Open ():Integer; override;
|
function Open ():Integer; override;
|
||||||
Destructor Destroy; override;
|
Destructor Destroy; override;
|
||||||
//function GetFlipStatus (status:p_flip_status):Integer; virtual;
|
//function GetFlipStatus (status:p_flip_status):Integer; virtual;
|
||||||
|
@ -806,19 +803,9 @@ begin
|
||||||
|
|
||||||
knote_eventid(EVENTID_FLIP, submit^.flipArg);
|
knote_eventid(EVENTID_FLIP, submit^.flipArg);
|
||||||
|
|
||||||
if (Ftsc_prev=0) then
|
if (p_fps_cnt<>nil) then
|
||||||
begin
|
begin
|
||||||
Ftsc_prev:=last_status.tsc;
|
System.InterlockedIncrement64(p_fps_cnt^);
|
||||||
Ffps:=1;
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
Inc(Ffps);
|
|
||||||
if ((last_status.tsc-Ftsc_prev) div tsc_freq)>=1 then
|
|
||||||
begin
|
|
||||||
p_host_ipc.SetCaptionFPS(Ffps);
|
|
||||||
Ffps:=0;
|
|
||||||
Ftsc_prev:=last_status.tsc;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue