You are not logged in.

#1 2008-06-03 13:34:35

Eradest
Member
From: Germany
Registered: 2007-07-18
Posts: 56

Qt 4 faster on Windows?

Hi everyone!
In my attempt to learn a bit of Qt, I wrote a little application that includes a custom widget to draw a Koch Snowflake.
snowflakescrnno3.png

As you can see, there's a slider to change the number of iterations in the recursion. On Linux, when changing from 6 to 7 iterations, there's a considerable lag while the widget updates itself.

When I compiled the app on Windows (XP), it would get repainted instantly even with 6 or 7 iterations selected.

I used exactly the same sourcecode.
How come the windows programm runs faster on exactly the same computer?

Offline

#2 2008-06-03 13:47:49

GogglesGuy
Member
From: Rocket City
Registered: 2005-03-29
Posts: 610
Website

Re: Qt 4 faster on Windows?

Most likely you are drawing using Xrender or Cairo that isn't hardware accelerated

Offline

#3 2008-06-03 13:52:08

Eradest
Member
From: Germany
Registered: 2007-07-18
Posts: 56

Re: Qt 4 faster on Windows?

I'm using the QPainter class for drawing. But why should it run faster on windows then?

Offline

#4 2008-06-03 13:53:35

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Qt 4 faster on Windows?

Windows is just a superior operating system.


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#5 2008-06-04 16:18:39

gnud
Member
Registered: 2005-11-27
Posts: 182

Re: Qt 4 faster on Windows?

What gogglesguy means, is that your xorg-server (that is, your display subsystem) is not hardware accellerated.
Can you open a terminal, type "glxinfo|grep direct" and post the output?

Offline

#6 2008-06-04 22:11:16

mindfall
Member
From: berlin
Registered: 2007-07-03
Posts: 57

Re: Qt 4 faster on Windows?

What about the compiler setting? Is it possible that on Windows your compiler does tail call optimization and on Linux not? Do you compile with -O2 ?

Offline

#7 2008-06-05 12:32:54

Eradest
Member
From: Germany
Registered: 2007-07-18
Posts: 56

Re: Qt 4 faster on Windows?

Can you open a terminal, type "glxinfo|grep direct" and post the output?

$ glxinfo | grep direct
direct rendering: Yes

What about the compiler setting? Is it possible that on Windows your compiler does tail call optimization and on Linux not? Do you compile with -O2 ?

I use GCC both on Linux and Windows (MinGW). The makefile is created by qmake and thus should be similar.
CXXFLAGS on Linux: -pipe -march=i686 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT
Windows equivalent to come shortly.

Offline

#8 2008-06-05 18:56:20

GogglesGuy
Member
From: Rocket City
Registered: 2005-03-29
Posts: 610
Website

Re: Qt 4 faster on Windows?

Eradest wrote:

Can you open a terminal, type "glxinfo|grep direct" and post the output?

$ glxinfo | grep direct
direct rendering: Yes

What about the compiler setting? Is it possible that on Windows your compiler does tail call optimization and on Linux not? Do you compile with -O2 ?

I use GCC both on Linux and Windows (MinGW). The makefile is created by qmake and thus should be similar.
CXXFLAGS on Linux: -pipe -march=i686 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT
Windows equivalent to come shortly.

Optimization probably not going to help you much. It's the underlying drawing mechanism that's being used. QPainter is just a abstraction on top of the rendering system. From the screenshot it looks like you're using some sort of anti-aliased rendering  (or you resized that screenshot) which can be painfully slow if not hardware accelerated. Try and see if you can turn that off (normal line drawing on X should be pretty quick). What hardware do you have?

Offline

#9 2008-06-06 21:02:54

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: Qt 4 faster on Windows?

Did you post the code so others can see? This would help if we could run it and see if our machines are equally slow.

Offline

#10 2008-06-07 11:54:01

Eradest
Member
From: Germany
Registered: 2007-07-18
Posts: 56

Re: Qt 4 faster on Windows?

right, so here you go:

snowflake.tar.gz

just run

qmake && make

to compile and then run.
Of course requires installed qt4

From the screenshot it looks like you're using some sort of anti-aliased rendering  (or you resized that screenshot) which can be painfully slow if not hardware accelerated. Try and see if you can turn that off (normal line drawing on X should be pretty quick).

Exactly, I use antialiasing for the lines. Disabling it (snowflake.cpp, line 17) makes it somewhat faster on linux but still doesn't explain why the antialiased version runs faster on windows.

Last edited by Eradest (2008-06-07 11:58:11)

Offline

#11 2008-06-07 12:58:54

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: Qt 4 faster on Windows?

Thanks for the code, I'll try it later today. Since you say that you are using anti-aliasing, I suppose it could be a poor linux video driver. Note that all but the latest nvidia drivers had trouble with anti-aliasing text - I'm not sure about lines.

Offline

#12 2008-06-08 00:22:25

vsk
Member
Registered: 2008-05-27
Posts: 70

Re: Qt 4 faster on Windows?

Windows is just a superior operating system.

But of course. *facepalm*

Hmm, I compiled it just with plain old -march=native and it seems to work reasonably well at 6 iterations, but slows after.

Offline

#13 2008-06-08 10:26:09

Eradest
Member
From: Germany
Registered: 2007-07-18
Posts: 56

Re: Qt 4 faster on Windows?

vsk wrote:

Hmm, I compiled it just with plain old -march=native and it seems to work reasonably well at 6 iterations, but slows after.

Well, that's exactly the point. 7 iterations will be drawn instantly on Win.

Offline

#14 2008-06-25 18:58:42

maddog39
Member
From: Philadelphia, PA
Registered: 2007-06-03
Posts: 73
Website

Re: Qt 4 faster on Windows?

My thought is that QPainter on windows probably is using DirectDraw which I believe is the DirectX 2D drawing library which is almost definately hardware accelerated and using something like xrender on linux. By the way, cairo is hardware accelerated if you have support for it in your graphics drivers.

http://en.wikipedia.org/wiki/Cairo_(graphics)

Cairo is designed to use hardware acceleration when available.

Last edited by maddog39 (2008-06-25 18:59:27)

Offline

Board footer

Powered by FluxBB