SetTimerResolution

This commit is contained in:
Pavel 2022-05-31 12:20:33 +03:00
parent 9fd50a1618
commit 3dbab47637
3 changed files with 36 additions and 5 deletions

View File

@ -421,5 +421,16 @@ begin
Result:=0;
end;
Procedure Init;
var
min,max,cur:ULONG;
begin
NtQueryTimerResolution(@min,@max,@cur);
NtSetTimerResolution(max,True,@cur);
end;
initialization
Init;
end.

View File

@ -995,6 +995,8 @@ var
elap:QWORD;
time:DWORD;
//t1,t2:QWORD;
begin
bufferIndex:=node^.u.bufferIndex;
flipMode :=node^.u.flipMode ;
@ -1094,16 +1096,22 @@ begin
time:=0;
end;
//SwSaveTime(t1);
ps4_usleep(time);
//Sleep(_usec2msec(time));
//t2:=SwTimePassedUnits(t1);
//t2:=(t2+9) div 10;
//Writeln('elap=',elap,' time=',time,' usleep=',t2);
if (FGpuFlip<>nil) then
begin
//FGpuFlip.IsComplite(FcurrentBuffer);
While (not FGpuFlip.IsComplite(FcurrentBuffer)) do
begin
ps4_usleep(150);
end;
FGpuFlip.IsComplite(FcurrentBuffer);
//While (not FGpuFlip.IsComplite(FcurrentBuffer)) do
//begin
// ps4_usleep(150);
//end;
end;
end;

View File

@ -81,6 +81,18 @@ function NtQueryPerformanceCounter(
Frequency:PLARGE_INTEGER
):DWORD; stdcall; external 'ntdll';
function NtQueryTimerResolution(
MinimumResolution:PULONG;
MaximumResolution:PULONG;
CurrentResolution:PULONG
):DWORD; stdcall; external 'ntdll';
function NtSetTimerResolution(
DesiredResolution:ULONG;
SetResolution:BOOL;
CurrentResolution:PULONG
):DWORD; stdcall; external 'ntdll';
implementation
end.