Recent

Author Topic: BGRA Graphic Speed Test  (Read 592 times)

Gigatron

  • Sr. Member
  • ****
  • Posts: 354
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
BGRA Graphic Speed Test
« on: April 08, 2025, 01:41:42 am »
Hi,
If you know Sysspeed Amiga from Alien Design to test some gfx/mem/cpu/fpu speed.

I made a similar little program with lazarus FPC to test BGRA graphic speed , you can test it on your machine;
Hope the values are correct !

Good Luck !


Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, ExtCtrls, ComCtrls, StdCtrls,
  9.   BGRABitmap, BGRABitmapTypes, BGRAVirtualScreen;
  10.  
  11. const
  12.   MaxTests = 10; // Nombre total de test 0-9
  13.  
  14. type
  15.  
  16.   { TForm1 }
  17.  
  18.   TForm1 = class(TForm)
  19.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  20.     Button1: TButton;
  21.     Memo1: TMemo;
  22.     Timer1: TTimer;
  23.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  24.     procedure Button1Click(Sender: TObject);
  25.     procedure FormCreate(Sender: TObject);
  26.     procedure FormDestroy(Sender: TObject);
  27.     procedure Timer1Timer(Sender: TObject);
  28.   private
  29.  
  30.     procedure DrawScene1(Bm: TBGRABitmap);
  31.     procedure DrawScene2(Bm: TBGRABitmap);
  32.     procedure DrawScene3(Bm: TBGRABitmap);
  33.     procedure DrawScene4(Bm: TBGRABitmap);
  34.     procedure DrawScene5(Bm: TBGRABitmap);
  35.     procedure DrawScene6(Bm: TBGRABitmap);
  36.     procedure DrawScene7(Bm: TBGRABitmap);
  37.     procedure DrawScene8(Bm: TBGRABitmap);
  38.     procedure DrawScene9(Bm: TBGRABitmap);
  39.     procedure DrawScene10(Bm: TBGRABitmap);
  40.  
  41.   end;
  42.  
  43. var
  44.   Form1: TForm1;
  45.   Test : Integer;
  46.   TestElapsed: Integer;
  47.   LinesDrawn: Integer;
  48.   BenchElapsed: Integer;
  49.  
  50. implementation
  51.  
  52. {$R *.lfm}
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. begin
  56.   Randomize;
  57.   Test := -1;
  58.   TestElapsed := 0;
  59.   LinesDrawn := 0;
  60.   BenchElapsed := 0;
  61.  
  62.   Timer1.Interval := 5;
  63.   Timer1.Enabled := False;
  64.  
  65. end;
  66.  
  67. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  68. begin
  69.   case Test of
  70.     0: DrawScene1(Bitmap);
  71.     1: DrawScene2(Bitmap);
  72.     2: DrawScene3(Bitmap);
  73.     3: DrawScene4(Bitmap);
  74.     4: DrawScene5(Bitmap);
  75.     5: DrawScene6(Bitmap);
  76.     6: DrawScene7(Bitmap);
  77.     7: DrawScene8(Bitmap);
  78.     8: DrawScene9(Bitmap);
  79.     9: DrawScene10(Bitmap);
  80.  
  81.   end;
  82.  
  83. end;
  84.  
  85. procedure TForm1.Button1Click(Sender: TObject);
  86. begin
  87.   Memo1.Clear;
  88.   Test := 0;
  89.   TestElapsed := 0;
  90.   BenchElapsed := 0;
  91.   LinesDrawn := 0;
  92.   Timer1.Enabled := True;
  93.   BGRAVirtualScreen1.OnRedraw := @BGRAVirtualScreen1Redraw;
  94. end;
  95.  
  96. // rnd lines
  97. procedure TForm1.DrawScene1(Bm: TBGRABitmap);
  98. var
  99.   T0: QWord;
  100.   x1, y1, x2, y2: Integer;
  101. begin
  102.   Bm.Fill(BGRA(0, 0, 0));
  103.  
  104.   T0 := GetTickCount64;
  105.   while (GetTickCount64 - T0 < 5) do
  106.   begin
  107.     x1 := Random(Bm.Width);
  108.     y1 := Random(Bm.Height);
  109.     x2 := Random(Bm.Width);
  110.     y2 := Random(Bm.Height);
  111.     Bm.DrawLine(x1, y1, x2, y2, BGRA(Random(255), Random(255), Random(255)), False);
  112.     Inc(LinesDrawn);
  113.   end;
  114. end;
  115. // Hlines
  116. procedure TForm1.DrawScene2(Bm: TBGRABitmap);
  117. var
  118.   T0: QWord;
  119.   y: Integer;
  120. begin
  121.   Bm.Fill(BGRA(0, 0, 0));
  122.  
  123.   T0 := GetTickCount64;
  124.   while (GetTickCount64 - T0 < 5) do
  125.   begin
  126.     y := Random(Bm.Height);
  127.     Bm.DrawLine(0, y, Bm.Width, y, BGRA(Random(255), Random(255), Random(255)), False);
  128.     Inc(LinesDrawn);
  129.   end;
  130. end;
  131.  
  132. // Vlines
  133. procedure TForm1.DrawScene3(Bm: TBGRABitmap);
  134. var
  135.   T0: QWord;
  136.   x: Integer;
  137. begin
  138.   Bm.Fill(BGRA(0, 0, 0));
  139.  
  140.   T0 := GetTickCount64;
  141.   while (GetTickCount64 - T0 < 5) do
  142.   begin
  143.     x := Random(Bm.Width);
  144.     Bm.DrawLine(x, 0, x, Bm.Height, BGRA(Random(255), Random(255), Random(255)), False);
  145.     Inc(LinesDrawn);
  146.   end;
  147. end;
  148. // circles
  149. procedure TForm1.DrawScene4(Bm: TBGRABitmap);
  150. var
  151.   T0: QWord;
  152.   x, y, r: Integer;
  153. begin
  154.   Bm.Fill(BGRA(0, 0, 0));
  155.  
  156.   T0 := GetTickCount64;
  157.   while (GetTickCount64 - T0 < 5) do
  158.   begin
  159.     x := Random(Bm.Width);
  160.     y := Random(Bm.Height);
  161.     r := Random(50) + 5;
  162.     Bm.EllipseAntialias(x, y, r, r, BGRA(Random(255), Random(255), Random(255)), 2);
  163.     Inc(LinesDrawn);
  164.   end;
  165. end;
  166. // rectangles
  167. procedure TForm1.DrawScene5(Bm: TBGRABitmap);
  168. var
  169.   T0: QWord;
  170.   x1, y1, x2, y2: Integer;
  171. begin
  172.   Bm.Fill(BGRA(0, 0, 0));
  173.  
  174.   T0 := GetTickCount64;
  175.   while (GetTickCount64 - T0 < 5) do
  176.   begin
  177.     x1 := Random(Bm.Width);
  178.     y1 := Random(Bm.Height);
  179.     x2 := x1 + Random(100);
  180.     y2 := y1 + Random(100);
  181.     Bm.Rectangle(x1, y1, x2, y2, BGRA(Random(255), Random(255), Random(255)), dmDrawWithTransparency);
  182.     Inc(LinesDrawn);
  183.   end;
  184. end;
  185. // carrés
  186. procedure TForm1.DrawScene6(Bm: TBGRABitmap);
  187. var
  188.   T0: QWord;
  189.   x, y, size: Integer;
  190. begin
  191.   Bm.Fill(BGRA(0, 0, 0));
  192.  
  193.   T0 := GetTickCount64;
  194.   while (GetTickCount64 - T0 < 5) do
  195.   begin
  196.     x := Random(Bm.Width);
  197.     y := Random(Bm.Height);
  198.     size := Random(80);
  199.     Bm.Rectangle(x, y, x + size, y + size, BGRA(Random(255), Random(255), Random(255)), dmDrawWithTransparency);
  200.     Inc(LinesDrawn);
  201.   end;
  202. end;
  203. // text
  204. procedure TForm1.DrawScene7(Bm: TBGRABitmap);
  205. var
  206.   T0: QWord;
  207.   x, y: Integer;
  208.   txt: string;
  209. begin
  210.   Bm.Fill(BGRA(0, 0, 0));
  211.   Bm.FontHeight := 20;
  212.  
  213.   T0 := GetTickCount64;
  214.   while (GetTickCount64 - T0 < 5) do
  215.   begin
  216.     x := Random(Bm.Width - 100);
  217.     y := Random(Bm.Height - 30);
  218.     txt := 'TEST ' + IntToStr(Random(999));
  219.     Bm.TextOut(x, y, txt, BGRA(Random(255), Random(255), Random(255)));
  220.     Inc(LinesDrawn);
  221.   end;
  222. end;
  223. // rect plein
  224. procedure TForm1.DrawScene8(Bm: TBGRABitmap);
  225. var
  226.   T0: QWord;
  227.   x1, y1, x2, y2: Integer;
  228. begin
  229.   Bm.Fill(BGRA(0, 0, 0));
  230.  
  231.   T0 := GetTickCount64;
  232.   while (GetTickCount64 - T0 < 5) do
  233.   begin
  234.     x1 := Random(Bm.Width);
  235.     y1 := Random(Bm.Height);
  236.     x2 := x1 + Random(100);
  237.     y2 := y1 + Random(100);
  238.     Bm.FillRect(x1, y1, x2, y2, BGRA(Random(255), Random(255), Random(255), 180));
  239.     Inc(LinesDrawn);
  240.   end;
  241. end;
  242. // carré plein !
  243. procedure TForm1.DrawScene9(Bm: TBGRABitmap);
  244. var
  245.   T0: QWord;
  246.   x, y, size: Integer;
  247. begin
  248.   Bm.Fill(BGRA(0, 0, 0));
  249.  
  250.   T0 := GetTickCount64;
  251.   while (GetTickCount64 - T0 < 5) do
  252.   begin
  253.     x := Random(Bm.Width);
  254.     y := Random(Bm.Height);
  255.     size := Random(80);
  256.     Bm.FillRect(x, y, x + size, y + size, BGRA(Random(255), Random(255), Random(255), 180));
  257.     Inc(LinesDrawn);
  258.   end;
  259. end;
  260. //  cercle plein
  261. procedure TForm1.DrawScene10(Bm: TBGRABitmap);
  262. var
  263.   T0: QWord;
  264.   x, y, r: Integer;
  265. begin
  266.   Bm.Fill(BGRA(0, 0, 0));
  267.  
  268.   T0 := GetTickCount64;
  269.   while (GetTickCount64 - T0 < 5) do
  270.   begin
  271.     x := Random(Bm.Width);
  272.     y := Random(Bm.Height);
  273.     r := Random(50) + 5;
  274.     Bm.FillEllipseAntialias(x, y, r, r, BGRA(Random(255), Random(255), Random(255), 180));
  275.     Inc(LinesDrawn);
  276.   end;
  277. end;
  278.  
  279. procedure TForm1.Timer1Timer(Sender: TObject);
  280. begin
  281.   Inc(TestElapsed, Timer1.Interval);
  282.   BGRAVirtualScreen1.RedrawBitmap;
  283.  
  284.   Inc(BenchElapsed, Timer1.Interval);
  285.  
  286.     if BenchElapsed >= 1000 then
  287.     begin
  288.       Memo1.Lines.Add('Test :' + IntToStr(Test) + '  ' +  IntToStr(LinesDrawn) + '/sec');
  289.       BenchElapsed := 0;
  290.       LinesDrawn := 0;
  291.       inc(Test);
  292.     end;
  293.  
  294.     if Test >= MaxTests then
  295.     begin
  296.       Timer1.Enabled := False;
  297.       Memo1.Lines.Add('All Test Done !');
  298.       BGRAVirtualScreen1.OnRedraw := nil;
  299.     end;
  300.   end;
  301.  
  302. procedure TForm1.FormDestroy(Sender: TObject);
  303. begin
  304. end;
  305.  
  306. end.
  307.  
Coding faster than Light !

Gigatron

  • Sr. Member
  • ****
  • Posts: 354
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
Re: BGRA Graphic Speed Test
« Reply #1 on: April 10, 2025, 06:40:10 pm »
Hi,

This project is now finished, you can see where BGRA component is fast or not.
You can learn how to jump to the different test, like a multipart demo on Amiga :)

Coding faster than Light !

 

TinyPortal © 2005-2018