porting dx9 to dx10 or later - how hard?

Started by
12 comments, last by Syntac_ 7 years, 2 months ago

porting dx9 to dx10 or later - how hard?

dx10 will get me real instancing for grass - and texture arrays. dx11 will get me things like NVIDIA turf effects.

everything i'm finding online about rendering grass is dx10 or newer.

FVF gets replaced by.... i've already done some, but i forget the name!

and i'd have to supply my own basic shaders? right?

anything else really major? minor variations in the matrix declarations as i recall.

i may have to bite the bullet and step up to a newer version of DX. i hate to have to do so, so late in the project, but you have to break a few eggs to make a real mayonnaise.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

dx9 to 11 is not really that hard, and forget dx10, you can use dx11 with feature level from 9 to 11. The most tricky thing will be the constant buffer management and update that replace the old constant register array. Everything is shader on dx11, no more fixed pipeline, but it is usually quite simple to patch that with a few handy shaders.

For your question about matrices, with shaders, everything is up to you, left, right, direct, indirect, row major or column major, it is all about what flavor you prefer :)

Don't bother with the Dx10 API - the Dx11 API can be initializing in a "Dx10 feature level" (and a Dx9 feature level!) for compatibility with old GPUs.

Yep - fixed function is gone.
That means using vertex shaders and Vertex Declarations (in D9 speak), which are now called Input Layouts.

The "texture environment" is gone. That means pixel shaders for everything.

Render states are monolithic objects now instead of many individual properties. If you want to keep using the D3 style of small state changes, you'll probably have to build some kind of hash table to cache these objects.

Most of the D3DX helpers are gone too, though there's some open source libs suchnas DirectXTex to help there.

I would actually recommend porting your game to "modern D3D9c" first, and then porting that to D3D11.

I did it. It's not hard but can take a lot more time than you might think. Consider all the changes and how they might impact your project: https://msdn.microsoft.com/en-us/library/windows/desktop/bb205073(v=vs.85).aspx. I would never do it near the end of a project...because then I would no longer be near the end of the project.

If you are still using the fixed function-pipeline, then maybe before upgrading to DX10+, you should probably start by using shaders. Removing the FFP might prove to be a huge project in and off itself, and if you combine it with changing the entire API surrounding it... I'd just break it off, if you first port your DX9-game to use shaders everywhere, upgrading to DX11 is a lot easier. There are some things that are still different that have been mentioned, but nothing quite as huge as FFP => Shaders.

I'm currently going from 9 to 11 and it's doable. My advice is to learn dx11 separately, small projects, iterate, iterate more and then update (or start from scratch, which I did) your codebase.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

I would actually recommend porting your game to "modern D3D9c" first, and then porting that to D3D11.

by that you mean vertex declarations instead of fvf, and shaders. right? and no d3dx dependencies? i think all i use out of d3dx are the texture and mesh loading code. - and the skinned mesh api. but i have the skinned mesh api as stand alone source code - extracted from tiny.cpp, multi_anim.cpp and dxut.cpp. but wait- that doesn't include the controller api code in d3dx9.lib! : (

i guess turn off d3dx9.lib and see what fails to link? that will instantly tell me exactly which d3dx routines i use - and must replace.

what about basic shaders? example code is readily available? aniso mip map w/ gourard, phong, alpha test or blend, and some two stage tex blending? i've had to do much of that stuff in software in the past, i'd hate to have to look it all up again.

there's one more thing i can try...

there is some sort of pseudo instancing possible in dx9 using indexed buffers in a special way. i suppose i ought to give it a shot before going in the dx10-11 direction just for instancing grass.

or maybe lookup both that and what would have to change in dx9, and figure out whats the best option.

my biggest fear is that i'd end up spending weeks or months writing shaders. although i've done similar coding in the past, and am pretty comfortable with it.

that's also another concern, i may come to like shader coding too much, causing delays on work on the game. its been a long time since i could just get a long pointer to vidram and "party on the bitmap". going to shaders would give me that kind of power again - intoxicating at the very least. my problem is i'm trying to build games, but i also enjoy low level graphics programming. but i only need low level graphics code as required by the game. anything more is technically a waste of time. shader coding may be distractingly fun for me.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

I have just made this transition. One thing to note is that in D3D11 there is no longer any functionality provided for the loading of mesh .x files as there is in D3D9. So if you are using such files then you will probably have to write your own mesh exporter/importer.

There is also no longer any built in support for loading .tga files or .dds files. And .bmp files won't load the alpha.

It was worth it to move to D3D11 because overall it runs a lot faster, at least for me. A good thing with D3D11 is that you can sample the depth buffer directly, so when doing deferred rendering there is no need to store a separate buffer for that.

I started out with following the tutorials on this site:

http://www.directxtutorial.com/LessonList.aspx?listid=11

A good thing with D3D11 is that you can sample the depth buffer directly, so when doing deferred rendering there is no need to store a separate buffer for that.
It's a bit late for you now, but you can do that in D3D9 as long as the user has a D3D10 capable GPU.

See INTZ here: http://aras-p.info/texts/D3D9GPUHacks.html

RAWZ/DF16/DF24 also worked on a handful of particular D3D9-era GPU's (e.g. RAWZ was GeForce 7 only, maybe?), but INTZ works on all D3D10 GPUs.

well i read the dx9 docs about shaders and effects and HLSL yesterday.

set stream, set constants, set shaders (pre-compileld, already loaded), DIP. that seems to be what it boils down to.

i use d3dx meshes for loading, but copy them into a vb and ib, then release the d3dxmesh. so i have buffers ready to go already.

i think the skinned mesh code in Caveman 3.0 already does this, via simple shaders and a fx file.

i'm not really doing a lot of fancy special effects, animated vegetation, alpha blended flames and smoke.

depth of field seems to be the only post processing effect that's appropriate for a scene as seen by the human eye as opposed to a camera lens. IE the human eye doesn't have lens flare, etc. corona effects, but that's a little different. the problem with DOF is - how do you let the player control the focus distance? in real life its automatic, whatever you "look at", your brain automatically adjusts the eye muscles to focus the lens at that range. rolling the middle mouse wheel is all i can think of.

Snow and three days of lows of 15F ( -9C ) have come to the Washington DC area. In-between dealing with that - getting into the sample code is the next thing on the todo list for today / tomorrow.

It also looks like i can keep the game mostly fixed function, and just use shaders where and as needed, the way i do now for skinned meshes. in fact i've already figured out what you have to save and restore when switching from fixed function to shaders and back again. I did that when I got skinned meshes working.

' draws a caveperson using the specified textures and animation
fn v draw_skinmesh_caveman_nohair i sex i bodT i eyeT i clothT i ani i ctrl double dt D3DXMATRIX *mWorld i topT i cloakT i braT
' sex: 0=male 1=female
' bodT is body mesh texture ID
' eyeT is eye texture ID
' clothT is clothing texture ID
' ani is which ani should be playing
' ctrl is the index of the character`s controller
i a
' a is the skinned_mesh_pool index of the body mesh
= a controller_pool[ctrl].mesh_index
' 1. set textures in the skinned mesh pool
= skinned_mesh_pool[a].body->texID bodT
= skinned_mesh_pool[a].loincloth->texID clothT
== sex 1
= skinned_mesh_pool[a].bra->texID braT
.
= skinned_mesh_pool[a].top->texID topT
= skinned_mesh_pool[a].cloak->texID cloakT
' 2. set animation
c controller_pool_setani ctrl ani
' 3. draw instance ( controllerID, dt, mWorld )
c draw_skinned_mesh_instance ctrl dt mWorld
' set z3d state manager current mesh to none...
= Zcurrentmesh -1
' reset FVF back to z3d FVF...
c Zd3d_device_ptr->SetFVF ZFVF
' 4. draw eyes
c draw_eyeballs2 a eyeT
.

As you can see, the FVF is all you really need to restore. I set the "current mesh" to NONE just to be safe.

apparently set_FVF and set_shader are the two calls that actually do the switch from fixed function to porgramnmable pipeline and back.

so it could be as simple as:

set stream

set shaders

set constants

DIP // draw animated grass

set FVF // back to normal operating mode for the game's "graphics engine".

And that means i can use d3dx9 AND shaders! have my cake AND eat it too! Something which is definitely not against my religion! <g>.

I should know in a day or two.

time to hit the books! <g>.

never stop learning.

and you gotta break a few eggs to make a real mayonnaise

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement