Sign in to follow this  

.fx file framework

This topic is 3491 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

Are you using .fx files for your game? Seems like simplest solution to manage shaders and communication between shaders and application. I am making my own little framework to make use of fx files easier and have one question regarding passing parameters. I am not really 100% sure what do I have to pass to the shader and what comes automatically into shader from dx runtime? Simply state: do I have to pass ALL parameters (that shader uses), including all transforms (world, view, projection, worlviewproj etc) or does the runtime pass those basic parameters anyway? Secondly should I pass those at start of each frame (before call to device->Begin()), at start of each technique (before technique->begin()) or before each pass in a technique (effect->BeginPass()? I believe it should be done per frame rendered, not technique or pass, but I am not quite sure. Maybe some combinaton of those? Use of fx file together with FXComposer seems to move a lot of coding from application domain (C, C++ or whatever else) into the shader code, seems that some things are a bit simplified. What are your opinions? Is there any good framework/abstraction already avialable?

Share this post


Link to post
Share on other sites
Quote:
Original post by joe_bubamara
Are you using .fx files for your game?
I don't write games, but yes I do use the FX framework in my applications.

In general the FX framework is robust enough for production usage. The people who DONT use it are usually those who have interests in other platforms (e.g. PS3) or have specific mappings to a tooling pipeline or existing architecture.

Quote:
Original post by joe_bubamara
Seems like simplest solution to manage shaders and communication between shaders and application.
Yup, it is about as simple as you're going to get without rolling your own layer on top of either FX framework or D3D.

Quote:
Original post by joe_bubamara
I am not really 100% sure what do I have to pass to the shader and what comes automatically into shader from dx runtime?
Unless you're using Direct3D 10's system generated values then nothing comes from the runtime automagically. I'm not experienced with OpenGL but I understand their GLSL implementation does provide some automatic values but don't assume the same happens with D3D.

Quote:
Original post by joe_bubamara
Do I have to pass ALL parameters (that shader uses), including all transforms (world, view, projection, worlviewproj etc) or does the runtime pass those basic parameters anyway?
You pass them yourself. However, unless a lost device occurs the register state should be transient between frames therefore in simplistic cases (or with a lazy-eval model) you don't need to (re-)set all constants each frame.

Quote:
Original post by joe_bubamara
Secondly should I pass those at start of each frame (before call to device->Begin()), at start of each technique (before technique->begin()) or before each pass in a technique (effect->BeginPass()?
Less changes the better so design your program accordingly. Reducing these state changes is quite a big win with D3D9 so it pays to do some profiling and monitoring. State managers may be useful. That said, from memory the only case to be careful of is changing pipeline state manually between passes - in that case call ::CommitChanges() before rendering.

Quote:
Original post by joe_bubamara
Use of fx file together with FXComposer seems to move a lot of coding from application domain (C, C++ or whatever else) into the shader code, seems that some things are a bit simplified. What are your opinions?
Yup, and if you look around you'll start to find a number of art or content oriented jobs requiring shader-authoring skills. Separating this from the 'core' programming done by software engineers is a definite win, but ultimately this is the same scenario as adopting scripting languages for game design. I don't know about now, but in phases there has been big demand for game/level designers who can also write high level scripts to describe their vision and thus separate these changes from the core coding...

Tools = Good [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Hej thnks, that was very nice and fast answer!

I have just one further question if you, or anyone else is willing to answer:

Quote:
You pass them yourself. However, unless a lost device occurs the register state should be transient between frames therefore in simplistic cases (or with a lazy-eval model) you don't need to (re-)set all constants each frame.
Could you maybe devleop that with "laze-eval model" and "simplsitic cases"; or at least point me to some good resource in the subject?

Share this post


Link to post
Share on other sites

This topic is 3491 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.

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