You are not logged in.
Pages: 1
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.
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
Most likely you are drawing using Xrender or Cairo that isn't hardware accelerated
Offline
I'm using the QPainter class for drawing. But why should it run faster on windows then?
Offline
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
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
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
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
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
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
right, so here you go:
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
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
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
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
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
Pages: 1