HLSL or ID3DXEffect?

Started by
2 comments, last by MJP 15 years, 6 months ago
Are there any benefits to using ordinary HLSL over Microsoft's .fx (ID3DXEffect) files?
------------Anything prior to 9am should be illegal.
Advertisement
In general, no.

In some cases you may be able to leverage finer control over the system to achieve some particular goal, typically on the asset production level, but in general you'll just end up reinventing large chunks of the Effect framework anyway, so you may as well use it until you find a pressing need for something it can't do.
These two things are not mutually exclusive. You can use both at the same time, i.e. write .fx files that contain HLSL code.

If your question is whether to write shaders in ASM or HLSL, there's no doubt that HLSL is the way to go. Writing ASM from scratch is useless, only when optimizing might you want to take the ASM output of an existing HLSL code and tweak it a bit for a possible performance increase, but writing ASM all the way is just a waste of time.

Then, perhaps your question is that whether to use the D3DXEffect framework or not? Well, I'd suggest using it, as it is very quick to get things running with the effect framework and it does manage some of the stuff ready for you.

Naive use of the effects framework does lead to lots of redundant device state changes, but with careful use of shared parameter pools and switching between effects you can resolve most or all of them, depending on your use case. If you're not using D3DXEffect, you need to store & set all the shader constants, textures and other state using the appropriate D3DDevice functions by yourself, which requires a lot of design to do properly.

In my project I'm now working on dealing with the combinatorial shader explosion problem, which has lead me to abandon D3DXEffect, but it was a good friend to have during most of the development process. I don't consider it a wasted time since it let me focus developing other things instead.
I would very much recommend using the Effects framework. It's extremely robust, and it will say you huge amounts of time you'd need to spend implementing a lot of the features yourself.

You might want to have a look at this thread where wolf talks a but about his approach to organizing shaders using the FX framework.

This topic is closed to new replies.

Advertisement