Recent

Author Topic: Which feature of the graphics card is effective in canvas drawing?  (Read 1083 times)

loaded

  • Full Member
  • ***
  • Posts: 113
Hi Everyone,
This is an interesting situation I have encountered with the image canvas,
I wrote a small canvas speed test program;
i3 2350M Processor, Nvidia GT520MX Graphics Card
i3 4150   Processor, Intel    HD 4400  Graphics Card
i5 8250u Processor, Intel    UHD 620  Graphics Card
The time of drawing is almost the same. But in 3D graphic applications and tests, the time is changing. Is there something wrong with me? Or what is the reason?
Installing the spelling, google translate is used :)

Handoko

  • Hero Member
  • *****
  • Posts: 3193
  • My goal: build my own game engine using Lazarus
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #1 on: April 09, 2019, 02:13:28 pm »
Did you meant you used TCanvas?

As far as I know TCanvas is not hardware accelerated graphics library. It is not optimized for performance and the performance depends on the processor not the graphics card.

For GUI applications and simple games, TCanvas should perform good on modern processor. If you want to get the performance benefit from the graphics card, the you should use graphics libraries or game engines that are hardware accelerated. Like: OpenGL, DirectX, Vulcan, SDL, Allegro, Irrlich, etc.

If your test shows that the canvas drawing performance is almost the same running on i3 and i5 ... well, that's interesting. I wrote some demo games using only TCanvas line drawing feature, it runs much faster on my Core2 Quad computer than Dual Core laptop. Maybe you can show us the code.
« Last Edit: April 09, 2019, 02:27:34 pm by Handoko »

loaded

  • Full Member
  • ***
  • Posts: 113
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #2 on: April 09, 2019, 02:45:42 pm »
Thank you very much for your reply, Handoko
I use canvas from the image object.
May be true. But ,  i5 8250u is twice as fast as i3 2350M but I can't understand that the Image.Canvas drawing times are the same.
Simple program that tests the processor and graphics card I created

Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Button2: TButton;
  17.     Image1: TImage;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure Button2Click(Sender: TObject);
  20.   private
  21.  
  22.   public
  23.  
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.   crono:cardinal;
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.Button1Click(Sender: TObject);
  36. var
  37.   i:integer;
  38. begin
  39.   crono:=GetTickCount;
  40.   for i:=0 to high(integer) do
  41.   begin
  42.  
  43.   end;
  44.   button1.Caption:=FloatToStr((GetTickCount-crono)/1000) ;   // result in 3.822 second (i3 4150)
  45. end;
  46.  
  47. procedure TForm1.Button2Click(Sender: TObject);
  48. var
  49. x,y:integer;
  50. begin
  51.   crono:=GetTickCount;
  52.   image1.Width:=756;
  53.   image1.Height:=425;
  54.   image1.Picture.Bitmap.SetSize(756,425);
  55.   for x:=0 to image1.Width do
  56.    begin
  57.      for y:=0 to image1.Height do
  58.       begin
  59.       image1.Canvas.Pen.Color:=x*y mod 65535;
  60.       image1.Canvas.Line(0,0,x,y);
  61.       end;
  62.    end;
  63.   button2.Caption:=FloatToStr((GetTickCount-crono)/1000) ;  // result in 1.716 ( İntel Hd 4400)
  64. end;
  65.  
  66. end.
  67.  
Installing the spelling, google translate is used :)

Mr.Madguy

  • Sr. Member
  • ****
  • Posts: 457
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #3 on: April 10, 2019, 08:19:59 am »
There were dedicated 2D accelerators in the past, but not now. But it doesn't mean, canvas isn't hardware accelerated now. It's 2D trough 3D now, cuz 2D is just a special case of 3D.
DynamicData 3.0 is released!
Since now development is frozen - only optimization passes will be made at some point.
Lack of multiple inheritance turns it into abomination.

loaded

  • Full Member
  • ***
  • Posts: 113
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #4 on: April 10, 2019, 12:32:51 pm »
Mr.Madguy ,Thank you for your answer.
Installing the spelling, google translate is used :)

Handoko

  • Hero Member
  • *****
  • Posts: 3193
  • My goal: build my own game engine using Lazarus
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #5 on: April 13, 2019, 07:49:46 pm »
I just tested on my Core2 Quad Q6600 Ubuntu Mate 64-bit Lazarus 1.8.4 GTK2 computer. The result shows there is no any significant performance difference running loaded's code using its Intel GMA 3100 (G31) integrated VGA and NVidia GeForce 210 PCIe VGA.

So, it means TCanvas of GTK2 isn't hardware accelerated. Maybe future versions of GTK's canvas will be hardware accelerated when performing 2D drawing.

-----
I forgot to mention, the computer has NVidia driver installed properly.
« Last Edit: April 13, 2019, 08:24:46 pm by Handoko »

lucamar

  • Hero Member
  • *****
  • Posts: 2082
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #6 on: April 13, 2019, 08:03:10 pm »
So, it means TCanvas of GTK2 isn't hardware accelerated. Maybe future versions of GTK's canvas will be hardware accelerated when performing 2D drawing.

It depends also on the x-server video driver: to have hardware acceleration some(/most?) cards require privative drivers. GTK2 is quite hardware agnostic in this respect.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

loaded

  • Full Member
  • ***
  • Posts: 113
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #7 on: April 14, 2019, 11:05:08 am »
Handoko and lucamar,  Thank you for your answers.
I think ; the end of this work will end at opengl  :)
Installing the spelling, google translate is used :)

Thaddy

  • Hero Member
  • *****
  • Posts: 9189
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #8 on: April 14, 2019, 11:24:32 am »
So, it means TCanvas of GTK2 isn't hardware accelerated. Maybe future versions of GTK's canvas will be hardware accelerated when performing 2D drawing.
Did you try and disable the Intel driver and hardware? Because GTK definitely supports the NVIDEA card if that is installed properly. It's not GTK btw, but the X-server. You may be able to force X-server to use the NVIDEA card in the linux driver configuration.
« Last Edit: April 14, 2019, 11:26:56 am by Thaddy »
also related to equus asinus.

Handoko

  • Hero Member
  • *****
  • Posts: 3193
  • My goal: build my own game engine using Lazarus
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #9 on: April 14, 2019, 05:10:43 pm »
I plugged the monitor cable to the NVidia card and the driver from NVidia was properly installed. I sometimes play some 3D games. So I believe the card was installed properly.

Maybe the test wasn't use any of the hardware-accelerated features.

Thaddy

  • Hero Member
  • *****
  • Posts: 9189
Re: Which feature of the graphics card is effective in canvas drawing?
« Reply #10 on: April 14, 2019, 07:35:23 pm »
The X-server capabilities are usually chosen at install time. You need to configure an additional graphic cards.
also related to equus asinus.