Porting DX8 - DX9. Should I go for HLSL ?

Started by
4 comments, last by joe1024 15 years, 5 months ago
Time has come for me to finish the porting of my DX8-based renderer to DX9-based, since the HW base has finally grown enough to compensate for the effort spent. What about shaders ? My old ones are in pure ASM, so I need to write all of them again. Should I go for HLSL or Cg ? I need something that is easily debuggable - i`ve had my share of no debugging of ASM shaders, so I`d be really glad if I could see the values of registers during the shader (and preferably stepping through them). Also, I`d be glad if there was minimum effort when making the switch to XNA (which I believe uses HLSL, but am not sure). Any ideas ?
Advertisement
Quote:Original post by joe1024
Time has come for me to finish the porting of my DX8-based renderer to DX9-based, since the HW base has finally grown enough to compensate for the effort spent.

What about shaders ? My old ones are in pure ASM, so I need to write all of them again. Should I go for HLSL or Cg ? I need something that is easily debuggable - i`ve had my share of no debugging of ASM shaders, so I`d be really glad if I could see the values of registers during the shader (and preferably stepping through them).

Also, I`d be glad if there was minimum effort when making the switch to XNA (which I believe uses HLSL, but am not sure).

Any ideas ?


HLSL is a fine choice. PIX for Windows allows you to debug shaders, but with HLSL you'll find you debug your shaders less, since you're not dealing with "asm mistakes" like wrong registers, etc. It's also good if you move to XNA and do something on the XBox, since HLSL is your only choice there.
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]
That`s great.

Do you have any other ideas what would be good to do now that I`m putting the effort into this ? Mainly regarding refactoring since I`m trying to do this as API-free as possible, mainly for later XNA usage.
Absolutely go with HLSL - whilst some hardcore console progammers will disagree I personally can't see any place for ASM shaders anymore. Especially for the portability to D3D10/D3D11 and XNA and also the tooling and other examples/tutorials online.

Do realise that DX9 SDK's since the last year (forget exactly when) don't support SM1 compile targets unless you include the legacy compiler (extra D3DX dependency).

Another thing to consider is that if you design your D3D9 renderer well you can take advantage of SM2 and SM3. For any shader taking advantage of SM3 capabilities it'll just be a pain to do that in anything but HLSL.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by joe1024
Do you have any other ideas what would be good to do now that I`m putting the effort into this ? Mainly regarding refactoring since I`m trying to do this as API-free as possible, mainly for later XNA usage.
For the Microsoft platforms HLSL in FX format is pretty stable - the changes between PC/XNA/XBox and across various versions isn't too much to handle. However, going to other platforms - say Cg or GLSL your problem won't be the syntax so much as the semantics. I'm no expert, but the bind points, declarations and so on are going to be subtly different that you'll have to watch out for different meaning rather than how you express your actual functions.

Unless you have a specific goal of running your code on OpenGL platforms you might as well just run with HLSL and FX files. If you're really paranoid about lock-in then drop the FX framework but stick with HLSL...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I definitely plan on adding some SM2/SM3 effects into my pipeline. There have been lots of shaders all over the net but since I was stuck with DX8 I could only stare. Now I can finally implement them.

I definitely don`t need to support OpenGL. It was barely an issue 10 yrs ago, and even less these days (unless you need Mac support, which I don`t).

My only issue is that due to the fact that one doesn`t do such breaking changes often (few times in one`s lifetime), I just need to be sure that it`s the right choice, taking into accounts other MS platforms, mainly XBOX.



I would guess that the next switch will be into DX11, some 3-5 yrs down the road (assuming there won`t be any DX9-era integrated chipsets produced en mass) and since that requires an almost paradigm-like change, there`s probably nothing I can do now to ease my porting efforts when that time comes, right ?

Plus, at that time, it should be clear, whether raytracing is the net big thing or not.



I`m especially eager to seeing that I can debug the shaders - it`s been a MAJOR pain in the *ss trying to guess the values. As far as I noticed I should be able to step into shaders and directly seeing the values of registers/variables (under DX9), right ? Is it better to use PIX or just the tool that is used for my card (nVidia) ?

This topic is closed to new replies.

Advertisement