Recent

Author Topic: Very slow graphics with Intel N4100 under xubuntu 19.04  (Read 373 times)

msavigo1

  • New member
  • *
  • Posts: 6
Very slow graphics with Intel N4100 under xubuntu 19.04
« on: July 13, 2019, 05:04:24 pm »
I recently changes to a new notebook and facing very slow graphics with a project using TBitmap.
The same project is running on my other computer like a charme.
I don't have any problems with any ohter programm on that notebook.

Scanling a 4896x3264 pixel picture to 580x350 pixel with CopyRect or StretchDraw takes over 20 seconds!

Has anybody an idea how to solve this problem?

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   SourceJpg: TJpegImage;   // Source image
  4.   Bitmap1: TBitmap;        // Original bitmap
  5.   Bitmap2: TBitmap;        // Target bitmap
  6.   Rect1: TRect;            // Original Rect
  7.   Rect2: TRect;            // Target Rect
  8. begin
  9.   // Load SourceJpg from file
  10.   Label1.Caption := 'Load SourceJpg...';
  11.   Label1.Refresh;
  12.   SourceJpg := TJpegImage.Create;
  13.   SourceJpg.LoadFromFile('./Julia.jpg');
  14.  
  15.   // Assign SourceJpg to a bitmap
  16.   Label1.Caption := 'Assign SourceJpg...';
  17.   Label1.Refresh;
  18.   Bitmap1 := TBitmap.Create;
  19.   Bitmap1.Assign(SourceJpg);
  20.  
  21.   // Show bitmap without scaling
  22.   Label1.Caption := 'Show bitmap without scaling...';
  23.   Label1.Refresh;
  24.   Image1.Canvas.Draw(0, 0, Bitmap1);
  25.  
  26.   // Size of original bitmap
  27.   Rect1.Create(0, 0, Bitmap1.Width, Bitmap1.Height);
  28.  
  29.   // Create the target bitmap
  30.   Bitmap2 := TBitmap.Create;
  31.   Bitmap2.SetSize(580, 350);
  32.  
  33.   // Size of target bitmap
  34.   Rect2.Create(0, 0, Bitmap2.Width, Bitmap2.Height);
  35.  
  36.   // Draw a scaled bitmap to the target bitmap
  37.   Label1.Caption := 'Draw a scaled bitmap to the target...';
  38.   Label1.Refresh;
  39.   Bitmap2.Canvas.CopyRect(Rect2, Bitmap1.Canvas, Rect1);
  40.  
  41.   // Show scaled bitmap
  42.   Label1.Caption := 'Show scaled bitmap.';
  43.   Label1.Refresh;
  44.   Image1.Canvas.Draw(0, 0, Bitmap2);
  45.  
  46.   //Label1.Caption := 'Show as stretched bitmap.';
  47.   //Label1.Refresh;
  48.   //Image1.Canvas.StretchDraw(Rect2, Bitmap1);
  49.  
  50. end;

Some infos about the notebook:

Computer
Prozessor   Intel(R) Celeron(R) N4100 CPU @ 1.10GHz
Hauptspeicher   3856MB (489MB used)
Maschinen-Typ   Laptop
Betriebssystem   Ubuntu 19.04
Benutzername   maik (maik)
Date/Time   Sa 13 Jul 2019 16:38:57 CEST
Anzeige
Auflösung   1366x768 pixels
OpenGL-Renderer   Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)
X11-Hersteller   The X.Org Foundation
Audio-Geräte
Audio Adapter   HDA-Intel - HDA Intel PCH
Audio Adapter   ThinkPad EC - ThinkPad Console Audio Control

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #1 on: July 13, 2019, 05:24:46 pm »
Try with BGRABitmap, it has fast resample.
https://wiki.freepascal.org/BGRABitmap_tutorial_2#Stretch_the_image

BTW, is amazing that with these specs it only takes 20 seconds, I remember creating big images on my old PC's and never working, programs stopping and like that  :)
« Last Edit: July 13, 2019, 05:29:58 pm by Lainz »

Handoko

  • Hero Member
  • *****
  • Posts: 3085
  • My goal: build my own game engine using Lazarus
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #2 on: July 13, 2019, 05:32:58 pm »
Hello msavigo1,
Welcome to the forum.

I checked the info of N4100, although it is not a high performance processor but it is as fast as most of the Core2 Duo processors and the UHD 600 is good enough to play most of 3D games.

One interesting thing I found is, it has been reported to have poor driver support on Lubuntu 18.04.1 LTS. Maybe the issue still hasn't solved on Ubuntu 19.04.

https://ubuntuforums.org/showthread.php?t=2406273

msavigo1

  • New member
  • *
  • Posts: 6
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #3 on: July 13, 2019, 05:48:22 pm »
Hello Handoko,

the strange thing is, that I don't have problems with any other (graphic) programm on that computer.
Loading an scaling that same jpg is just a click of a button with ohter programms.


Handoko

  • Hero Member
  • *****
  • Posts: 3085
  • My goal: build my own game engine using Lazarus
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #4 on: July 13, 2019, 06:12:41 pm »
If I'm correct, TCanvas drawing procedures are depended/provided by the OS. If your hardward doesn't have graphics driver properly installed it may run very slow.

Alternatively I recommend you to try LazPaint. It is built using Lazarus and it uses BGRABitmap to handle the drawing functions, which in some cases can be faster than using the system widgetset.

If LazPaint runs significant smoothly for the same image on your system compare to TCanvas, I believe it is driver issue.

https://bgrabitmap.github.io/lazpaint/

msavigo1

  • New member
  • *
  • Posts: 6
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #5 on: July 14, 2019, 02:43:27 pm »
I tried different live distributions to see if it is a driver problem.

The programme runs very fast (< 500 ms) on a fresh xubuntu without updates.
Here “glxinfo -B” shows this:
    Device: Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)  (0x3185)
    Version: 18.0.5   :D

After applying all updates it is extremely slow (> 60 s) and “glxinfo -B” shows this:
    Device: Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)  (0x3185)
    Version: 19.0.2   :(

Even with the latest mesa version there is no improvement.
    Device: Mesa DRI Intel(R) UHD Graphics 600 (Geminilake 2x6)  (0x3185)
    Version: 19.2.0   :(

Every Mesa version 18.x seem to work but Mesa 19.x case problems.
All other graphic programmes run very well with any of these mesa versions.
So I’m not sure if it is an Mesa or a Lazarus problem.

Handoko

  • Hero Member
  • *****
  • Posts: 3085
  • My goal: build my own game engine using Lazarus
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #6 on: July 14, 2019, 02:49:05 pm »
Thank you for reporting back what you found. Maybe you should also report it on Ubuntu forum.

msavigo1

  • New member
  • *
  • Posts: 6
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #7 on: July 14, 2019, 05:48:49 pm »
This isn’t just an Ubuntu problem. The same happened with Ferora.
Does the problem come from calling some Mesa functionality (out of Lazarus) the wrong way or does it come from executing the code the wrong way? Sorry for this simple explanation but I’m not an expert on what’s going on behind the scene.

These are the timings in ms for the fast executing (Mesa 18.x):
Load SourceJpg: 1526
Assign SourceJpg: 66
Show bitmap without scaling: 212
Draw a scaled bitmap to the target: 683
Show scaled bitmap: 0

These are the timings in ms for the slow executing (Mesa 19.x):
Load SourceJpg: 1830
Assign SourceJpg: 83
Show bitmap without scaling: 218
Draw a scaled bitmap to the target: 62540
Show scaled bitmap: 0

I’m also not sure how an were to report this problem.

winni

  • New member
  • *
  • Posts: 37
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #8 on: July 14, 2019, 05:58:24 pm »
There were a really lot of updates for Mesa at the end of June and early July.

Look if there is an update for Mesa on Ubuntu.

Winni

msavigo1

  • New member
  • *
  • Posts: 6
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #9 on: July 14, 2019, 07:25:12 pm »
I've already tried the latest Mesa version (19.2.0).

msavigo1

  • New member
  • *
  • Posts: 6
Re: Very slow graphics with Intel N4100 under xubuntu 19.04
« Reply #10 on: July 14, 2019, 10:26:20 pm »
I did a fresh install (no live session) of xubuntu 19.04 with updates during installation.
Now everything runs without problems.  :D

Load SourceJpg: 1575
Assign SourceJpg: 87
Show bitmap without scaling: 248
Draw a scaled bitmap to the target: 413
Show scaled bitmap: 0

Don’t know where the problems came from.