added thread priority control
This commit is contained in:
parent
92b97a9b01
commit
fe7d7253cf
@ -562,6 +562,15 @@ object RenderForm: TRenderForm
|
||||
end
|
||||
end
|
||||
end
|
||||
object chkThreadPriority: TCheckBox
|
||||
Left = 176
|
||||
Top = 358
|
||||
Width = 73
|
||||
Height = 17
|
||||
Caption = 'Low priority'
|
||||
TabOrder = 10
|
||||
OnClick = chkThreadPriorityClick
|
||||
end
|
||||
object SaveDialog: TSaveDialog
|
||||
Left = 136
|
||||
Top = 360
|
||||
|
@ -74,6 +74,7 @@ type
|
||||
chkLimitMem: TCheckBox;
|
||||
cbBitsPerSample: TComboBox;
|
||||
Output: TMemo;
|
||||
chkThreadPriority: TCheckBox;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure btnRenderClick(Sender: TObject);
|
||||
@ -96,6 +97,7 @@ type
|
||||
procedure chkMaintainClick(Sender: TObject);
|
||||
procedure chkSaveIncompleteRendersClick(Sender: TObject);
|
||||
procedure cbBitsPerSampleSelect(Sender: TObject);
|
||||
procedure chkThreadPriorityClick(Sender: TObject);
|
||||
private
|
||||
StartTime, EndTime, oldElapsed, edt: TDateTime;
|
||||
oldProg: double;
|
||||
@ -510,6 +512,11 @@ begin
|
||||
Renderer := TRenderThread.Create;
|
||||
assert(Renderer <> nil);
|
||||
|
||||
if chkThreadPriority.Checked then
|
||||
Renderer.SetPriority(tpLower)
|
||||
else
|
||||
Renderer.SetPriority(tpNormal);
|
||||
|
||||
Renderer.BitsPerSample := BitsPerSample;
|
||||
if chkLimitMem.checked then
|
||||
Renderer.MaxMem := MaxMemory;//StrToInt(cbMaxMemory.text);
|
||||
@ -577,6 +584,12 @@ begin
|
||||
|
||||
Renderer := TRenderThread.Create;
|
||||
assert(Renderer <> nil);
|
||||
|
||||
if chkThreadPriority.Checked then
|
||||
Renderer.SetPriority(tpLower)
|
||||
else
|
||||
Renderer.SetPriority(tpNormal);
|
||||
|
||||
Renderer.BitsPerSample := BitsPerSample;
|
||||
if chkLimitMem.checked then
|
||||
Renderer.MaxMem := MaxMemory;//StrToInt(cbMaxMemory.text);
|
||||
@ -640,6 +653,7 @@ begin
|
||||
ShowMemoryStatus;
|
||||
Ratio := ImageWidth / ImageHeight;
|
||||
chkSaveIncompleteRenders.Checked := SaveIncompleteRenders;
|
||||
chkThreadPriority.Checked := LowerRenderPriority;
|
||||
end;
|
||||
|
||||
procedure TRenderForm.txtWidthChange(Sender: TObject);
|
||||
@ -1038,5 +1052,17 @@ begin
|
||||
ShowMemoryStatus;
|
||||
end;
|
||||
|
||||
procedure TRenderForm.chkThreadPriorityClick(Sender: TObject);
|
||||
begin
|
||||
LowerRenderPriority := chkThreadPriority.Checked;
|
||||
|
||||
if Assigned(Renderer) then begin
|
||||
if LowerRenderPriority then
|
||||
Renderer.SetPriority(tpLower)
|
||||
else
|
||||
Renderer.SetPriority(tpNormal);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -151,6 +151,7 @@ var
|
||||
|
||||
SaveIncompleteRenders: boolean;
|
||||
ShowRenderStats: boolean;
|
||||
LowerRenderPriority: boolean;
|
||||
|
||||
SymmetryType: integer;
|
||||
SymmetryOrder: integer;
|
||||
|
@ -556,6 +556,7 @@ begin
|
||||
ShowProgress := true;
|
||||
end;
|
||||
|
||||
{ FormRender }
|
||||
if Registry.ValueExists('SaveIncompleteRenders') then begin
|
||||
SaveIncompleteRenders := Registry.ReadBool('SaveIncompleteRenders');
|
||||
end else begin
|
||||
@ -566,6 +567,11 @@ begin
|
||||
end else begin
|
||||
ShowRenderStats := false;
|
||||
end;
|
||||
if Registry.ValueExists('LowerRenderPriority') then begin
|
||||
LowerRenderPriority := Registry.ReadBool('LowerRenderPriority');
|
||||
end else begin
|
||||
LowerRenderPriority := false;
|
||||
end;
|
||||
|
||||
if Registry.ValueExists('PNGTransparency') then begin
|
||||
PNGTransparency := Registry.ReadInteger('PNGTransparency');
|
||||
@ -675,6 +681,7 @@ begin
|
||||
// ResizeOnLoad := False;
|
||||
ShowProgress := true;
|
||||
SaveIncompleteRenders := false;
|
||||
LowerRenderPriority := false;
|
||||
ShowRenderStats := false;
|
||||
PNGTransparency := 1;
|
||||
ShowTransparency := False;
|
||||
@ -1132,6 +1139,7 @@ begin
|
||||
|
||||
Registry.WriteBool('SaveIncompleteRenders', SaveIncompleteRenders);
|
||||
Registry.WriteBool('ShowRenderStats', ShowRenderStats);
|
||||
Registry.WriteBool('LowerRenderPriority', LowerRenderPriority);
|
||||
|
||||
Registry.WriteInteger('NrTreads', NrTreads);
|
||||
Registry.WriteInteger('UseNrThreads', UseNrThreads);
|
||||
|
@ -66,6 +66,7 @@ type
|
||||
FCompatibility: integer;
|
||||
FNumThreads: integer;
|
||||
FNumBatches: integer;//int64;
|
||||
FThreadPriority: TThreadPriority;
|
||||
|
||||
FMinDensity: double;
|
||||
FMinBatches: integer;
|
||||
@ -112,6 +113,7 @@ type
|
||||
procedure BreakRender; virtual;
|
||||
procedure Pause; virtual;
|
||||
procedure UnPause; virtual;
|
||||
procedure SetThreadPriority(p: TThreadPriority); virtual;
|
||||
|
||||
function Failed: boolean;
|
||||
|
||||
@ -187,6 +189,7 @@ begin
|
||||
FNumSlices := 1;
|
||||
FSlice := 0;
|
||||
FStop := 0; // False;
|
||||
FThreadPriority := tpNormal;
|
||||
|
||||
FImageMaker := TImageMaker.Create;
|
||||
end;
|
||||
@ -242,6 +245,11 @@ begin
|
||||
TimeTrace('Resuming render');
|
||||
end;
|
||||
|
||||
procedure TBaseRenderer.SetThreadPriority(p: TThreadPriority);
|
||||
begin
|
||||
FThreadPriority := p;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure TBaseRenderer.Stop;
|
||||
begin
|
||||
@ -311,7 +319,7 @@ begin
|
||||
strOutput.Add(Format(' Max Count: %2.3f bits', [Abits]));
|
||||
strOutput.Add(Format(' Point hit ratio: %2.2f%%', [100.0*(TotalA/TotalSamples)]));
|
||||
if RenderTime > 0 then // hmm
|
||||
strOutput.Add(Format(' Average speed: %n points per second', [TotalSamples / (RenderTime * 24 * 60 * 60)]));
|
||||
strOutput.Add(Format(' Average speed: %n iterations per second', [TotalSamples / (RenderTime * 24 * 60 * 60)]));
|
||||
strOutput.Add(' Pure rendering time:' + TimeToString(RenderTime));
|
||||
end;
|
||||
end;
|
||||
@ -324,7 +332,7 @@ begin
|
||||
|
||||
TotalSamples := int64(FNumBatches) * SUB_BATCH_SIZE; // * fcp.nbatches ?
|
||||
if RenderTime > 0 then // hmm
|
||||
strOutput.Add(Format(' Average speed: %n points per second', [TotalSamples / (RenderTime * 24 * 60 * 60)]));
|
||||
strOutput.Add(Format(' Average speed: %n iterations per second', [TotalSamples / (RenderTime * 24 * 60 * 60)]));
|
||||
strOutput.Add(' Pure rendering time:' + TimeToString(RenderTime));
|
||||
end;
|
||||
|
||||
|
@ -49,6 +49,7 @@ type
|
||||
|
||||
procedure Pause; override;
|
||||
procedure UnPause; override;
|
||||
procedure SetThreadPriority(p: TThreadPriority); override;
|
||||
|
||||
end;
|
||||
|
||||
@ -96,9 +97,9 @@ begin
|
||||
|
||||
Progress(batchcounter / FNumBatches);
|
||||
bc := batchcounter;
|
||||
finally
|
||||
LeaveCriticalSection(CriticalSection);
|
||||
end;
|
||||
finally
|
||||
LeaveCriticalSection(CriticalSection);
|
||||
end;
|
||||
end;
|
||||
|
||||
for i := 0 to High(WorkingThreads) do begin
|
||||
@ -165,11 +166,22 @@ begin
|
||||
WorkingThreads[i].Resume;
|
||||
end;
|
||||
|
||||
procedure TBaseMTRenderer.SetThreadPriority(p: TThreadPriority);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
for i := 0 to High(WorkingThreads) do
|
||||
WorkingThreads[i].Priority := p;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function TBaseMTRenderer.NewThread: TBucketFillerThread;
|
||||
begin
|
||||
Result := TBucketFillerThread.Create(fcp);
|
||||
assert(Result<>nil);
|
||||
Result.Priority := FThreadPriority;
|
||||
|
||||
if FCP.FAngle = 0 then
|
||||
Result.AddPointsProc := self.AddPointsToBuckets
|
||||
|
@ -73,6 +73,7 @@ type
|
||||
procedure Suspend;
|
||||
procedure Resume;
|
||||
procedure BreakRender;
|
||||
procedure SetPriority(p: TThreadPriority);
|
||||
|
||||
// procedure GetBucketStats(var Stats: TBucketStats);
|
||||
procedure ShowBigStats;
|
||||
@ -203,6 +204,7 @@ begin
|
||||
end;
|
||||
|
||||
FRenderer.SetCP(FCP);
|
||||
FRenderer.SetThreadPriority(self.Priority);
|
||||
// FRenderer.compatibility := compatibility;
|
||||
FRenderer.MinDensity := FMinDensity;
|
||||
FRenderer.OnProgress := FOnProgress;
|
||||
@ -275,6 +277,14 @@ begin
|
||||
FRenderer.BreakRender;
|
||||
end;
|
||||
|
||||
procedure TRenderThread.SetPriority(p: TThreadPriority);
|
||||
begin
|
||||
Priority := p;
|
||||
|
||||
if assigned(FRenderer) then
|
||||
FRenderer.SetThreadPriority(p);
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function TRenderThread.GetNrSlices: integer;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user