Sign in to follow this  
Klarre

Port D3D9 to D3D10

Recommended Posts

The engine I am coding on has support for both D3D8 and D3D9. I began with implementing the D3D9 support and then added the support for D3D8. I found it very easy to do the port between them. I almost just copied the D3D9 code and changes the data type names to fit the D3D8 system instead. So to my question: Is it as easy to port D3D9 code to D3D10 as it is to D3D8?

Share this post


Link to post
Share on other sites
IMO, its not worth it to support DX10 unless you're going to use the features it offers. We know Windows Vista supports DX9 and earlier, and the Vista market is so small there's really no point in catering to it yet.

As Driv3MeFar said, the programming model of DX10 is potentially quite different than that of DX9, so you may be looking at far more sweeping changes than your DX8 port required.

Share this post


Link to post
Share on other sites
In my experience with 10 (which is MUCH faster, by the way, if you can port your code over to it, and you have DX10 hardware, and your client is running Vista), it's not worth porting to it yet. However, in the event that you do, there's not *too* much of a programming difference between D3D9 and D3D10 other than (as the above posters mentioned) the removal of the fixed-function pipeline (you have to write shaders to do everything now), and the complete re-write of the initialization process for Direct3D.

Share this post


Link to post
Share on other sites
It's not a huge change for most things, but cleanly supporting it in a way that lets you take advantage of its performance improvements will depend on how agile your existing codebase is.

Performance-wise, you'll get the best results if you start to group your states the way that D3D10 does, and treat them as lockable hardware resources, then create and sort them in whatever manner fits in with your existing material/scene sorting methodology. Modifying a state object while it is in use does appear to incur a penalty, from some very sloppy PIX runs I did, so you'll want to avoid that unless there's no alternative. If you do need modifiable states, then I'd recommend using a pool of states and an async query to work as a sort of frame fence. When that fence is hit, then you can mark the range of states that were in use for that frame as available, eliminating the cpu->gpu penalty at the expense of a little cpu legwork.

The switch from vertex declarations to input layouts is a tricky one as well since they now need the input signature of a vertex shader in order to be created. I never came up with what I felt was a great solution for this.

What I ended up doing was to defer layout creation time to draw time and embed layout info in my stream resources. At draw time, since the shaders and all streams would be bound, I would assemble a full layout from all bound streams, and check for the existence of a matching layout in a cache. If it didn't exist, I would create the layout resource and insert it into my cache, removing the least recently used layout (respecting the frame fence to avoid stalls) if I had gone over my fixed resource limit. Again, this forces a little more work on the cpu for the benefit of eliminating stalls. This fit in well with the 'legacy' DX8/9 paths, since in FF the vertex stream also contains its layout/FVF, and in DX9 it was simple enough to just create the vertex declaration based on the bound streams, caching it like in DX10, and not having to bother validating it against the shader.

Other than that, I don't recall any big gotchas. DX10 is really much faster when you use it properly, I've been impressed so far.

Share this post


Link to post
Share on other sites
Thank you all guys for your thoughts! I have got the impression that D3D10 is faster and better, but D3D9 is still good enough. I am probably going to lower the priority on the D3D10 rendering system implementation.

Thanks again!

/Klarre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this