mirror of
https://github.com/red-prig/fpPS4.git
synced 2025-02-17 04:27:55 +00:00
Time calculation corrected, tests needed
This commit is contained in:
parent
a2d29a180c
commit
4f21129183
@ -319,21 +319,22 @@ end;
|
||||
const
|
||||
GpuCoreClockFrequency=800000000;
|
||||
|
||||
function mul_div_u64(m,d,v:QWORD):QWORD; sysv_abi_default; assembler; nostackframe;
|
||||
asm
|
||||
movq v,%rax
|
||||
mulq m
|
||||
divq d
|
||||
end;
|
||||
|
||||
function GetGpuTickCount:QWORD;
|
||||
var
|
||||
pc,pf:QWORD;
|
||||
DW0,DW1:QWORD;
|
||||
begin
|
||||
pc:=0;
|
||||
pf:=1;
|
||||
NtQueryPerformanceCounter(@pc,@pf);
|
||||
|
||||
//DW0*GF/pf + SHL_32* DW1*GF/pf
|
||||
|
||||
DW0:=(DWORD(pc shr 00)*GpuCoreClockFrequency) div pf;
|
||||
DW1:=(DWORD(pc shr 32)*GpuCoreClockFrequency) div pf;
|
||||
|
||||
Result:=DW0+(DW1 shl 32);
|
||||
Result:=mul_div_u64(GpuCoreClockFrequency,pf,pc);
|
||||
end;
|
||||
|
||||
Function me_eop(node:pvMeEopInfo):Boolean;
|
||||
|
@ -67,7 +67,6 @@ uses
|
||||
ps4_elf,
|
||||
ps4_pthread,
|
||||
ps4_program,
|
||||
ps4_elf_tls,
|
||||
|
||||
ps4_videodrv,
|
||||
vMemory,
|
||||
|
@ -177,10 +177,6 @@ begin
|
||||
end;
|
||||
|
||||
function ps4_clock_getres(clock_id:Integer;tp:Ptimespec):Integer; SysV_ABI_CDecl;
|
||||
var
|
||||
pc,pf:QWORD;
|
||||
TimeAdjustment,TimeIncrement:DWORD;
|
||||
TimeAdjustmentDisabled:BOOL;
|
||||
begin
|
||||
if (tp=nil) then Exit(_set_errno(EINVAL));
|
||||
|
||||
@ -200,40 +196,16 @@ begin
|
||||
CLOCK_REALTIME_PRECISE,
|
||||
CLOCK_REALTIME_FAST:
|
||||
begin
|
||||
|
||||
TimeAdjustment:=0;
|
||||
TimeIncrement:=0;
|
||||
TimeAdjustmentDisabled:=false;
|
||||
|
||||
_sig_lock;
|
||||
GetSystemTimeAdjustment(TimeAdjustment,TimeIncrement,TimeAdjustmentDisabled);
|
||||
_sig_unlock;
|
||||
|
||||
tp^.tv_sec :=0;
|
||||
tp^.tv_nsec:=TimeIncrement*100;
|
||||
|
||||
if (tp^.tv_nsec<1) then
|
||||
begin
|
||||
tp^.tv_nsec:=1;
|
||||
end;
|
||||
|
||||
tp^.tv_nsec:=100;
|
||||
end;
|
||||
|
||||
CLOCK_MONOTONIC,
|
||||
CLOCK_MONOTONIC_PRECISE,
|
||||
CLOCK_MONOTONIC_FAST:
|
||||
begin
|
||||
|
||||
SwQueryPerformanceCounter(pc,pf);
|
||||
|
||||
tp^.tv_sec :=0;
|
||||
tp^.tv_nsec:=(POW10_9+(pf shr 1)) div pf;
|
||||
|
||||
if (tp^.tv_nsec<1) then
|
||||
begin
|
||||
tp^.tv_nsec:=1;
|
||||
end;
|
||||
|
||||
tp^.tv_nsec:=100;
|
||||
end;
|
||||
|
||||
else
|
||||
@ -242,6 +214,13 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
function mul_div_u64(m,d,v:QWORD):QWORD; sysv_abi_default; assembler; nostackframe;
|
||||
asm
|
||||
movq v,%rax
|
||||
mulq m
|
||||
divq d
|
||||
end;
|
||||
|
||||
function ps4_clock_gettime(clock_id:Integer;tp:Ptimespec):Integer; SysV_ABI_CDecl;
|
||||
var
|
||||
pc,pf:QWORD;
|
||||
@ -256,7 +235,6 @@ begin
|
||||
SwGetSystemTimeAsFileTime(TFILETIME(pc));
|
||||
pc:=pc-DELTA_EPOCH_IN_100NS;
|
||||
tp^.tv_sec :=pc div POW10_7;
|
||||
//tp^.tv_nsec:=(QWORD(pc) mod POW10_7)*100;
|
||||
tp^.tv_nsec:=0;
|
||||
end;
|
||||
|
||||
@ -279,40 +257,12 @@ begin
|
||||
CLOCK_MONOTONIC_PRECISE,
|
||||
CLOCK_MONOTONIC_FAST:
|
||||
begin
|
||||
|
||||
//this stabilize timers, why? idk
|
||||
//Int64(pc):=-100*100;
|
||||
//SwDelayExecution(False,@pc); //100ms
|
||||
|
||||
SwQueryPerformanceCounter(pc,pf);
|
||||
|
||||
tp^.tv_sec :=pc div pf;
|
||||
tp^.tv_nsec:=((pc mod pf)*POW10_9+(pf shr 1)) div pf;
|
||||
|
||||
if (tp^.tv_nsec>=POW10_9) then
|
||||
begin
|
||||
Inc(tp^.tv_sec);
|
||||
Dec(tp^.tv_nsec,POW10_9);
|
||||
end;
|
||||
|
||||
//tp^.tv_nsec:=(tp^.tv_nsec shr 8) shl 8;
|
||||
//tp^.tv_nsec:=tp^.tv_nsec shr 2;
|
||||
|
||||
{
|
||||
if (old_tp.tv_sec=tp^.tv_sec) then
|
||||
begin
|
||||
if (old_tp.tv_nsec>tp^.tv_nsec) then
|
||||
begin
|
||||
DebugBreak;
|
||||
end;
|
||||
end else
|
||||
if (old_tp.tv_sec>tp^.tv_sec) then
|
||||
begin
|
||||
DebugBreak;
|
||||
end;
|
||||
old_tp:=tp^;
|
||||
}
|
||||
pc:=mul_div_u64(POW10_7,pf,pc);
|
||||
|
||||
tp^.tv_sec :=(pc div POW10_7);
|
||||
tp^.tv_nsec:=(pc mod POW10_7)*100;
|
||||
end;
|
||||
|
||||
CLOCK_PROCTIME:
|
||||
@ -346,21 +296,17 @@ begin
|
||||
end;
|
||||
|
||||
function ps4_sceKernelGetTscFrequency():QWORD; SysV_ABI_CDecl;
|
||||
var
|
||||
pc:QWORD;
|
||||
begin
|
||||
SwQueryPerformanceCounter(pc,Result);
|
||||
Result:=POW10_7;
|
||||
end;
|
||||
|
||||
function ps4_sceKernelReadTsc():QWORD; SysV_ABI_CDecl;
|
||||
var
|
||||
pf:QWORD;
|
||||
pc,pf:QWORD;
|
||||
begin
|
||||
//this stabilize timers, why? idk
|
||||
//Int64(pf):=-100*100;
|
||||
//SwDelayExecution(False,@pf); //100ms
|
||||
SwQueryPerformanceCounter(pc,pf);
|
||||
|
||||
SwQueryPerformanceCounter(Result,pf);
|
||||
Result:=mul_div_u64(POW10_7,pf,pc);
|
||||
end;
|
||||
|
||||
function ps4_sceKernelClockGettime(clockId:Integer;tp:Ptimespec):Integer; SysV_ABI_CDecl;
|
||||
|
@ -9,9 +9,6 @@ uses
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
sys_types;
|
||||
|
||||
const
|
||||
SCE_CONTENT_EXPORT_ERROR_CANCELED =$809D3001;
|
||||
SCE_CONTENT_EXPORT_ERROR_NOTACCEPT =$809D3002;
|
||||
|
@ -5,8 +5,7 @@ unit ps4_libSceVideoRecording;
|
||||
interface
|
||||
|
||||
uses
|
||||
ps4_program,
|
||||
sys_types;
|
||||
ps4_program;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -118,6 +118,13 @@ begin
|
||||
_sig_unlock;
|
||||
end;
|
||||
|
||||
function mul_div_u64(m,d,v:QWORD):QWORD; sysv_abi_default; assembler; nostackframe;
|
||||
asm
|
||||
movq v,%rax
|
||||
mulq m
|
||||
divq d
|
||||
end;
|
||||
|
||||
procedure SwSaveTime(var pc:QWORD);
|
||||
var
|
||||
pf:QWORD;
|
||||
@ -127,17 +134,14 @@ begin
|
||||
_sig_lock;
|
||||
NtQueryPerformanceCounter(@pc,@pf);
|
||||
_sig_unlock;
|
||||
|
||||
pc:=mul_div_u64(POW10_7,pf,pc);
|
||||
end;
|
||||
|
||||
function SwTimePassedUnits(ot:QWORD):QWORD;
|
||||
var
|
||||
pc:QWORD;
|
||||
pf:QWORD;
|
||||
|
||||
//sec:QWORD;
|
||||
//uec:QWORD;
|
||||
|
||||
DW0,DW1:QWORD;
|
||||
begin
|
||||
pc:=0;
|
||||
pf:=1;
|
||||
@ -145,32 +149,20 @@ begin
|
||||
NtQueryPerformanceCounter(@pc,@pf);
|
||||
_sig_unlock;
|
||||
|
||||
pc:=mul_div_u64(POW10_7,pf,pc);
|
||||
|
||||
if (pc>ot) then
|
||||
pc:=pc-ot
|
||||
else
|
||||
pc:=(ot+High(QWORD))+pc;
|
||||
|
||||
//DW0*POW10_7/pf + SHL_32* DW1*POW10_7/pf
|
||||
|
||||
DW0:=(DWORD(pc shr 00)*POW10_7) div pf;
|
||||
DW1:=(DWORD(pc shr 32)*POW10_7) div pf;
|
||||
|
||||
Result:=DW0+(DW1 shl 32);
|
||||
|
||||
//sec:=pc div pf;
|
||||
//uec:=((pc mod pf)*POW10_7{POW10_11}+(pf shr 1)) div pf;
|
||||
//Result:=sec*POW10_7{POW10_11}+uec;
|
||||
Result:=pc;
|
||||
end;
|
||||
|
||||
function SwGetTimeUnits:Int64;
|
||||
var
|
||||
pc:QWORD;
|
||||
pf:QWORD;
|
||||
|
||||
//sec:QWORD;
|
||||
//uec:QWORD;
|
||||
|
||||
DW0,DW1:QWORD;
|
||||
begin
|
||||
pc:=0;
|
||||
pf:=1;
|
||||
@ -178,16 +170,7 @@ begin
|
||||
NtQueryPerformanceCounter(@pc,@pf);
|
||||
_sig_unlock;
|
||||
|
||||
//DW0*POW10_7/pf + SHL_32* DW1*POW10_7/pf
|
||||
|
||||
DW0:=(DWORD(pc shr 00)*POW10_7) div pf;
|
||||
DW1:=(DWORD(pc shr 32)*POW10_7) div pf;
|
||||
|
||||
Result:=DW0+(DW1 shl 32);
|
||||
|
||||
//sec:=pc div pf;
|
||||
//uec:=((pc mod pf)*POW10_7{POW10_11}+(pf shr 1)) div pf;
|
||||
//Result:=sec*POW10_7{POW10_11}+uec;
|
||||
Result:=mul_div_u64(POW10_7,pf,pc);
|
||||
end;
|
||||
|
||||
function SwGetProcessTime(var ut:QWORD):Boolean;
|
||||
@ -283,8 +266,6 @@ end;
|
||||
function SwGetTimeUsec:QWORD;
|
||||
var
|
||||
pc,pf:QWORD;
|
||||
|
||||
DW0,DW1:QWORD;
|
||||
begin
|
||||
pc:=0;
|
||||
pf:=1;
|
||||
@ -292,12 +273,7 @@ begin
|
||||
NtQueryPerformanceCounter(@pc,@pf);
|
||||
_sig_unlock;
|
||||
|
||||
//DW0*1000000/pf + SHL_32* DW1*1000000/pf
|
||||
|
||||
DW0:=(DWORD(pc shr 00)*1000000) div pf;
|
||||
DW1:=(DWORD(pc shr 32)*1000000) div pf;
|
||||
|
||||
Result:=DW0+(DW1 shl 32);
|
||||
Result:=mul_div_u64(1000000,pf,pc);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
x
Reference in New Issue
Block a user