Skip to main content
gamedev.net
🔒 Locked

D3D matrix vs. own matrix code

Started by Gorky Apr 10, 2001 at 7:21 PM 2 replies 350+ views
Original Post
Gorky
Gorky
I''m curious. Do other programmers use the D3D matrix fuctions? Or do they write their own? I ask because, it seems like there could be a nice preformance gain, if a person could make a better set of matrix functions. I tried to write a better version of D3DXMatrixTranslation. But my version was about the same speed as Microsofts. I really thought I had a faster version. Should I continue trying to find a faster way? Or does everyone everyone else use the D3D matrix functions?
dusik
dusik
I did my own matrix stuff because:

1) I am NOT using D3DX -- no way!
2) I like to do stuff myself so I can actually learn it
3) There is always room for optimization. Say, my rotation matrix functions are optimized for my game's specific purpouses

Not that there's anything WRONG with using D3DX and their functions. If time matters, why not? If quality/knowledge matters (as it does to me) try doing stuff yourself.

------------------------
CRAZY_DUSIK* pCrazyDuSiK;
pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);


Edited by - dusik on April 17, 2001 10:50:09 PM
------------------------CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);pCrazyDuSiK->WebSiteURL = "http://www.geocities.com/dusik2000";
DrunkenHyena
DrunkenHyena
G''day!

I doubt you''ll be able to get a significant increase in speed over the Matrix building functions in D3DX. If you limit what they can do (very app-specific) you might get a slight increase, but nothing significant.
If you want to write your own as a learning excercise, do it. Otherwise you are probably wasting your time. The amount of time spent building matrices is so tiny compared to everything else that even if you could make them take 0 time, no one would notice.
D3DXMatrixTranslation hardly does anything to begin with, no real calculations.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
fdisano
fdisano
I think it all depends HOW you write your own matrix functions. If you write them in assembly language and optmize for cache efficiency and FPU usage, then you can get a nice gain. You can really come out ahead if you use the P3''s SSE instruction set, which directX 7 doesn''t seem to use. I''m not sure about directX 8 though.

What I did for one math library is set up a system whereby all the intensive algebraic functions (matrix * vector, matrix * matrix, cross product, normlization... etc) where written in assembler and optimized for a different platform (Pentium, Pentium Pro/2, Pentium 3, AMD...) and stored in seperate DLL''s. Then, at runtime, I''d determine the CPU type and load in the appropriate DLL. In some cases there was up to 50% improvement in speed over D3D''s functions.

Fred



~----------------------------~ Fredola Coder by day Gamer by night Ottawa.CA~----------------------------~

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.