|
|
| High-Performance Matrix Library? | | |
 Sponsor | Kibiyama | Jun 2, 2007 3:49pm | This is for a 2d software renderer.
Looking for a better one than the matrix class from uBLAS via Boost.
I implemented the matrix class from uBLAS in my render function and, well... take a look at this benchmark:
1969ms for 100 calls to matrix_sprite() <-- matrix render
31ms for 100 calls to rotate_scaled_sprite() <-- fixed-point value render
Both perform the task, but the matrix one was *meant* to make things easier and more efficient...
The main problem is matrix multiplication. If I comment out just the multiply line, I get a time of 219ms per 100 calls.
I did a better job of writing my own multiply function in 5 minutes, improving speed by 200ms. I don't know why uBLAS has such piss-poor performance! |
|
| 
| Zephyr-The-Zeph | Jun 4, 2007 6:07am | | So whats the question? If you've written your own multiply function and gotten it down to 200ms, Which seems relatively reasonable, Why do you need another? |
|
|  Sponsor | Kibiyama | Jun 4, 2007 9:49am | No no no, I didn't get it down to 200ms, I got it down by 200ms. Which means it's still ~1700ms per 100 calls, which is ridiculous considering I aim to make somewhere between 5 and 100 calls, 60 times per second!
And the question is pretty much "Is there a good matrix library out there, or do I have to enter the realm of hardware for fast transforms?" |
|
| 
| Zephyr-The-Zeph | Jun 4, 2007 10:04am | | I don't have specific experience with mathematical libraries, But I imagine there is without making assembly calls. |
|
| | | DevModMan | Jun 5, 2007 8:27am | Check out this site for a little help on matrix libraries
ibm.com/developerworks/linux/library/l-matrix.html [ibm.com/developerworks/linux/library/l-matrix.html]
Blitz is a great library kind of odd but a great library. I had plans to use blitz in a 3d game library but never got around to it.
Matrix multiplications are not a good thing to be doing on the cpu unless you are using sse instructions and even then its a resource hog.
My only thought is why are you using a matrix for a 2d game. A simple x and y point system is much easer and FASTER for a 2d system. In 3d programming using direct x almost all of the rendering matrix math gets done on the GPU and the cpu just pushes data off to it.
My recommendation is to simply use X and Y coordinates and use simple 2d math methods for doing the rendering and offsets |
|
|  Sponsor | Kibiyama | Jun 5, 2007 9:15am | Hm. Blitz looks like a good option.
And yeah, I know matrices seem like a bad idea. But they seemed like a good idea at the time, seeing as they incorporate position, rotation, and scaling, and bypass calling trig functions.
I'm thinking about switching to AllegroGL, since I can keep a lot of the code I already have and still take advantage of hardware acceleration, and maybe put in some fancy particle effects while I'm at it. (yay over-ambition)
The trouble will likely arise from using a 3d API for something that's 2d only.
I'm completely aware of how foolish I look, and I do not care one bit.
"The only true wisdom is in knowing you know nothing." |
|
| | | DevModMan | Jun 10, 2007 10:59pm | Hey learning is a active process. But you could code the entire thing in 3d like direct x or opengl and put it into orthogonal rendering mode (i think its the one that makes it all appear 2d) which would give you hardware acceleration and that way you have a more modern way of doing 2d games.
EDIT: All that matrix stuff gets really nasty. Alot of the students i worked with on the direct x toolkit still have problems with them. I even have issues sometimes. Often its just easer to do the trig to figure things out :D |
|
|  Sponsor | Kibiyama | Jun 11, 2007 12:17pm | Well, I've decided to do it in Allegro, and see what kind of performance I get. If it's not enough, I'll go to AllegroGL for hardware acceleration. It's not *much* work to swap out the calls, especially since I can keep a lot of plain Allegro calls in there.
I could use DX or GL with another library, but I've been using Allegro for little games for so long, I feel like I owe the community something, and I'd like to show that it's possible to make a good game with Allegro. :D |
|
| High-Performance Matrix Library? | | | You need to Sign-up for StumbleUpon to post to this forum
| |
|