• Advertisement
Sign in to follow this  

Do the pros use D3DX

This topic is 4894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quote:
Original post by Ainokea
What is d3ddx? Is it a wrapper class for Direct3d or something?

Oh BTW Doom3 is made in opengl, that is why it performs (slightly) better on nviea cards.


D3DX is a set of functions that are based around 3D rendering. They can be used for Texture loading, Mesh handling, Vector/Matrix math, and a plethora of other things. It is extremely useful. Most people use the math parts, since they are very conveient and faster (development and performance) than writing it yourself. The texture loader are nice as well. Some people do not like the mesh features, since it can be a bit lacking, so they will write there own. Other than that type of thing, the library is extremely useful for n00bs and Pros alike.

Share this post


Link to post
Share on other sites
Advertisement
Quote:

I read somewhere that Carmack doesnt use D3DX?


Since Carmack has never released a D3D renderer for any of his games, of course he doesn't. Carmack has made comments about wanting to switch to D3D because of issues with compatability issues between nVidia & ATI in their extensions, since D3D doesn't allow for as much IHV control there, but he's still a firm believer in OGL.

Anyway...

You can't not use D3DX, unless you feel like writing your own HLSL compiler, or you just don't use shaders (assuming you're using DX).

Show me any cutting edge PC or XBox game that doesn't use shaders, though.

Yes, I'm aware that you can compile your shaders offline, too, but I'm willing to bet that they still used D3DX to do that.

That isn't to say that everyone uses every DX function. I doubt many companies use .x files, and I'm sure plenty don't touch the effects framework.

Quote:

Whooever thinks Doom3 (John Carmack) is OpenGL is a god damn idiot.


Bwahahaha. Ok, chief. [rolleyes]

Share this post


Link to post
Share on other sites
I used d3dx selectively. In every d3dx release there are certain bugs which is something you have to get used to. Also, some parts of d3dx are a moving target that will be changed, removed, or have new bugs in next release. I moved to opengl and wrote my own libs. At first I thought it would be lot of work but it wasn't. I'm glad I did it because now I have full control over the code and I learned few things I can apply to other areas.

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
I read somewhere that Carmack doesnt use D3DX?


He probably doesn't. As far as I can tell, he's got a preference for working at the lowest level he can get away with. I don't think it's necessarily the right thing to do, it's just his personality.

Share this post


Link to post
Share on other sites
Just like most people state probably every D3D project uses D3DX to some degree. You could even use it without using Direct3D itself but then there are probably better solutions for you.

You actually CAN compile shaders without D3DX (Cg compiler). BUT there are many things in D3DX that are just so optimized and handy like matrix- and vector classes or texture loading functions so that you'd just be somewhat too idealistic to write them yourself - they ARE optimized and they have everything you need.

Once it comes to D3DX's mesh class and effect files things look a little different I guess. There are many valid reasons why you chose not to use them (often enough you have engine internal optimisations or abstractions that simply don't fit with the interface imposed by those classes - they might just not be flexible enough).

So basically it boils down to: use it where you see it fits and if it doesn't - write you own code.

Just my 2 cents.

Alex

Share this post


Link to post
Share on other sites
I just want to clear things up about OpenGL and nVidia cards, it's only temporarily. ATi is working hard on the Catalyst drivers and updates are coming each month.

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
I read somewhere that Carmack doesnt use D3DX?

true?

ace


doubtful he uses D3DX, since he doesn't use D3D.

But yes, the D3DX library is used in a large number of major games, certain aspects more then others. For instance, I would estimate over 80% (maybe as high as 95%) of PC games in development are using HLSL and or Effects in some fassion.

D3DX components fall into 2 catagories: high value add, difficult to reproduce modules such as HLSL, PRT simulation, vertex cache optimization, DXT compresser etc. The second category is (relativly) easy to implement commonly used components such as the math/texture loading which are fall under the nuisance catagory of many developers.





Share this post


Link to post
Share on other sites
You can't use the D3DX library if you want to use an alternative compiler/linker such as Borland C++ Builder WITHOUT having to include an extra DLL, AFAIK.

Pros may not use a lot of D3DX because they may want to design their own math/helper function modules because either:
a) D3DX doesn't do exactly what they need
b) If wanting to design an engine which supports multiple graphics APIs (such as DX and OpenGL), it may be more beneficial to write their own common functions (from scratch, or even use a common module library) rather than interface everything to D3DX/Glut, because then they'd be using different matrix systems, etc, and that might confuse things.

If you're not in this situation, however, I guess it can only be beneficial to use it.

PS: Please feel free to correct me if I'm wrong.

Share this post


Link to post
Share on other sites
Even though the D3DXMatrix class makes use of SSE2 instructions I have read in Vector Math for Game Processors book is that they are not fully optimized. D3DXMATRIX uses a special version of the mov instruction just incase your data isn't 16 byte aligned. Recall SIMD, etc can;t work with unaligned data- there is an additional performance penalty to align your data. There maybe some way to get around this perhaps- like if ya use the D3DXMATRIXA16 structure instead of D3DXMatrix (not sure).

Most engines write their own math functions and collision libraries- at least the ones I have worked with. simply because most of them must run on the Playstation 2 which lacks any sort of API.

I have not met anyone that works on strictly XBox games so I don't know about them. It only takes a pro a few secs to write their own math libraries. This is usually a prerequisite to getting a job as a senior engine programmer (write matrix,vector, plane math libraries).

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
is it not possible to refine the performance of D3DX functions more by rewriting them?


You can't simply rewrite them because the implementation is supplied in the libs within DX SDK.

Share this post


Link to post
Share on other sites
Quote:
Original post by circlesoft
Unless you are as experienced with pure ASM as the Intel programmers are, I seriously doubt that this is true. The math D3DX functions have been extensivly optimized by Intel, Microsoft, and the IHV's. This includes all the matrix, quaternion, and vector operations.


He's right. If you ever look at a profile of all functions in practically any D3D program, the D3DX functions are way down at the bottom of the list. Hundreds of calls to D3DXMatrixMultiply, for example, take less time than a single sprintf() function.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by vajuras
...It only takes a pro a few secs to write their own math libraries...


That's the problem with the logic of some of the posts here (regarding bugs, doing it yourself, etc.) - I can write a lot of things in a couple of secs, but chances are that the results will not be fully tested or optimized.

Long story short, a "pro" would never really use something that was whipped together in a few secs if it was a essential as a matrix multiply or similar.

Share this post


Link to post
Share on other sites
Well I am speaking for my personal experience in the game industry. D3DX math routines are a major no-no for most commercial engines because that stuff isn't portable to consoles (Playstation 2). A matrix routine is a very trivial thing to write. If you want to optimize it- you optimize to use parallel vector multiplication and 16 byte alignment. It's not rocket science.

[Edited by - vajuras on August 28, 2004 7:01:25 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by vajuras
Recall SIMD, etc can;t work with unaligned data- there is an additional performance penalty to align your data. There maybe some way to get around this perhaps- like if ya use the D3DXMATRIXA16 structure instead of D3DXMatrix (not sure).


That was the exact reason why D3DXMATRIXA16 was created. From what I understand, it was actually created by Intel programmers.

Either way, the math stuff is irrelevant, as it's all pretty easy. Optimizations abound, of course, but there's no reason not to use the D3DX stuff in a D3D app if it'll yield better benefits than your home grown functions:

#ifdef USING_D3D
typedef D3DXMATRIXA16 Matrix;
#else
class Matrix
{
//..stuff
};
#endif

It seems likely to me that you're going to have a completely different set of Matrix / Vector functions for the PS2 anyway, so you might as well use the D3DX ones for the PC / XBox release.

And, yes, you could write generic, unoptimized ones, too, but I doubt that's a great idea for stuff like this.

Share this post


Link to post
Share on other sites
Well I decided to pull out my high precision timer and see how well my hand written, unoptimized matrix class fared against D3DX. Here's the result:

My Matrix 0.000003
D3DXMATRIX Time 0.000003
D3DXMATRIXA16 Time 0.000003

As you can see my matrix matches D3DXMATRIX. Sometimes they vary by 1 clock. In any case, this goes to show the D3DX math functions are not as fast as most folks believe.

A similar thread at flipcode- they did some profiles and got their stuff to beat D3DX w/o much effort: http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00010878&forum=3dtheory&id=-1

In any case D3DX is still priceless. It would suck trying to write an engine w/o D3DXLoadTexture from file, X files, and all the other goodies that make directx priceless. I was talking with a friend the other day that works at a game company that is using directx .X files to import content.

[Edited by - vajuras on August 29, 2004 1:37:37 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by vajuras
Well I decided to pull out my high precision timer and see how well my hand written, unoptimized matrix class fared against D3DX. Here's the result:

My Matrix 0.000003
D3DXMATRIX Time 0.000003
D3DXMATRIXA16 Time 0.000003

As you can see my matrix matches D3DXMATRIX. Sometimes they vary by 1 clock. In any case, this goes to show the D3DX math functions are not as fast as most folks believe.

That is very interesting . Could you run that code through a commercial profiler (ie Intel VTune)? If not, try timing thousands of operations at a time.

All the timers I have ever used aren't very accurate for single-call events. Timing an entire batch of them should be a better representation of the facts. [smile]

Share this post


Link to post
Share on other sites
the point remains I have never seen a commercial engine rely on D3DXMATRIX/D3DXVECTOR (Unreal engine, etc) for core ops. so even if you ran VTune and proved that D3DXMATRIX was 1 clock cycle faster than the avg 3 loop matrix mul function it would not make any diff.

D3DX math functions are okay, nothing special, nothing the avg senior programmer can;t write in 1 day.

Btw, nice user rating you have there :D

Share this post


Link to post
Share on other sites
Who is Carmack? Gee you guys wouldn't be his fan club would you?
If you base all your descisions on what one man does then you fall short of being sheep.

Well I heard Michael Jackson uses Head & Shoulders Shampoo, so I would advise everyone to do the same, I mean look at him, he's rich!

Share this post


Link to post
Share on other sites
Quote:
Original post by vajuras
the point remains I have never seen a commercial engine rely on D3DXMATRIX/D3DXVECTOR (Unreal engine, etc) for core ops. so even if you ran VTune and proved that D3DXMATRIX was 1 clock cycle faster than the avg 3 loop matrix mul function it would not make any diff.

D3DX math functions are okay, nothing special, nothing the avg senior programmer can;t write in 1 day.
Of course Unreal2/2x/3 doesn't use D3DX - it's targeted for PC, Mac, Linux, Xbox, PS2, and Gamecube. However, some commercial developers (perhaps those that only develop for XBOX and PC) do use D3DX for the core math operations (as well as texture loaders and shader compilers).

If the average senior programmer can replicate D3DX math functions in one day, then why does it take Intel and Microsoft programmers months to code them in the first place? The fact of the matter is, the D3DX math functions are much faster than the math functions that some programmer slaps together in one day. Do a proper profiling of the code, and you will find that out for yourself.

Share this post


Link to post
Share on other sites
When did I say no one uses D3DX functions for compiling shaders, etc?

Unreal Engine/Doom 3 are undoubtably the top 5 commercial engines out there. If D3DXMATRIX was so great- trust me they would use it. Instead, they use plain vanilla matrix ops. It is not rocket science coding a matrix/vector class. It is not hard to write stuff that outperforms microsoft math functions. I am sorry if I have upset you but this is the truth. Every game company I have ever worked at, we wrote our own math libs. Every game company i ever visited, they wrote their own.

[Edited by - vajuras on August 29, 2004 1:24:49 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by vajuras
Is that the best you can do is list a freaking puzzle game, lol.

You said "name one game that uses D3DX". He did. You then edited your post to remove your request for a single game.

Share this post


Link to post
Share on other sites
You asked for an XBOX game, he gave you one. If you've been following the DIRECTXDEV list, you'll notice people ask D3DXMATRIX related questions there.
The 2004 update bug (matrices not transposed when set with effects) bit many of them, and they all added workarounds - that's saying something, isn't it?

Regarding your timing test: What functionality did you test exactly? Take a look at the list of matrix functions supported by D3DX, implement your own, and then send me a copy and let's profile together.
Also, don't forget to write a version against aligned matrices.

Also, I hope you did that timing test on a release build, not a debug one. And that you've also tested it on a PC capable of SSE.

Share this post


Link to post
Share on other sites
Of course Unreal, Doom, etc. use their own matrix functions. They are going to be used on other platforms.

Doom is, of course, OPENGL, and probably wouldn't have much use for using DX functions anyway (so why use D3DX?)

Unreal needs to operate on at least 6 different platforms. Using a platform-specific implementation would be kind of silly.

Share this post


Link to post
Share on other sites

This topic is 4894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement