OpenGL initialization performance

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Paul
Newbie
Newbie
Posts: 4
Joined: Thu Jul 24, 2014 12:00 am

OpenGL initialization performance

Post by Paul » Mon Oct 27, 2014 11:28 am

Hi

I know that OpenGL need some time to perform initialization but is it possible to do it without freezing main thread? It's very annoying when I have to wait 2-4 seconds until main window will respond.

Paul

jens.mertelmeyer
Newbie
Newbie
Posts: 60
Joined: Fri Nov 22, 2013 12:00 am

Re: OpenGL initialization performance

Post by jens.mertelmeyer » Mon Oct 27, 2014 3:53 pm

I also wondered the same. It's really taking a lot of time.
In case it has to be the main thread, is it possible to do it in advance? I'd like to do it when my application starts up. For now, it seems to be delayed until the chart becomes visible.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: OpenGL initialization performance

Post by Sandra » Fri Oct 31, 2014 1:12 pm

Hello Paul and Jens,

I would like inform you that we are investigating about the performance problem you are experiencing we try to give you a good answer in shortest time as possible.

Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: OpenGL initialization performance

Post by Yeray » Tue Nov 04, 2014 9:35 am

Hello,

Find here a simple test project we made to check the OpenGL initialization times.
This example only uses a TDraw3D and creates the GLCanvas to measure the initialization time.
GL_Init.zip
(2.42 KiB) Downloaded 1219 times
Here the results we got:

Delphi 7, Run
First run: 9328 millisec
Second run: 6469 millisec

Delphi 7, Running exe directly to avoid debugging
First run: 922 millisec
Second run: 469 millisec

XE7, Run
First run: 6360 millisec
Second run: 6500 millisec

XE7, Run without debugging
First run: 1047 millisec
Second run: 469 millisec

Note a big difference is noticeable between running the project with or without debug mode "Run without debugging".
The test project uses 3 fonts (Arial, Verdana i Courier New). Using one makes it considerably faster.

Also note the tests here have given very similar results when building&running the project for 32 and 63 bits in XE7.

If your times you get are much bigger, it may be due to hardware / driver.
Here the machine specifications we made the tests above with:
OS:Windows 8.1 64-bit
CPU: Intel Core i7-4771 @3.5GHz CPU
Memory: 16GB RAM
Primary drive: Samsung SSD 840 EVO
Graphics: NVIDIA GeForce GTX 760

Also note the Nvidia / Raedon control panels include some 3D settings globally used in all the applications or modifiable for a specific application or exe.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jens.mertelmeyer
Newbie
Newbie
Posts: 60
Joined: Fri Nov 22, 2013 12:00 am

Re: OpenGL initialization performance

Post by jens.mertelmeyer » Tue Nov 04, 2014 9:40 am

Thanks for the Benchmark.

But please note that both of us were perfectly fine with the OpenGL initialization taking a bit of time. Our main gripe was the fact the main thread is blocked. If it really has to be the main thread, please give us a way to do it in advance.

When, for example, the TChart is put on a TPageControl and the user then switches to the chart, the whole application locks up. I'd be perfectly fine with the chart taking its time at application startup but not when the user has started working. :)


Oh and by the way: On my way slower machine it's 1840ms vs. 358ms with XE7 ;-)


Update:
That code example is very useful! :!: :mrgreen:

I did some further profiling- The InitWindow command takes at least half of the time, the font stuff at least a third. The other parts are negligible :)
So:
  • Thanks for showing us the TGLCanvas::InitWindow(..) command. That looks like pretty much what I was looking for
  • Can you elaborate on the font stuff? Why is the number of different fonts used important? Is loading the fonts (and probably rasterizing them to Bitmaps so they can be used) what needs time?

Many thanks in advance

Paul
Newbie
Newbie
Posts: 4
Joined: Thu Jul 24, 2014 12:00 am

Re: OpenGL initialization performance

Post by Paul » Thu Nov 06, 2014 10:28 am

Yeray thanks for response. As Jens mentions the most interesting thing in enclosed project is that if we call InitWindow first time it took on debug mode 550-650ms but second time takes less than 20ms. Now we can use InitWindow on application startup and then all charts will appear much faster.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: OpenGL initialization performance

Post by Yeray » Thu Nov 06, 2014 11:23 am

Hi,
jens.mertelmeyer wrote:
  • Thanks for showing us the TGLCanvas::InitWindow(..) command. That looks like pretty much what I was looking for
Paul wrote:Now we can use InitWindow on application startup and then all charts will appear much faster.
Great to hear that helped you!
jens.mertelmeyer wrote:
  • Can you elaborate on the font stuff? Why is the number of different fonts used important? Is loading the fonts (and probably rasterizing them to Bitmaps so they can be used) what needs time?
The first time a font is used in a TextOut call, OpenGL initializes it and takes its time for it. Then, using the same font in different TextOut calls is almost immediate.
I'm afraid I haven't found a way to initialize a Font apart, that would presumably allow you to move that initialization too.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply