Skip to main content
GameDev.net gamedev.net
🔒 Locked

[DX10] Effect Parameter Blocks Gone?

Started by WOsborn Jan 21, 2008 at 8:42 PM 1 replies 1.3k views
Original Post
WOsborn
WOsborn
How are constant effect variables handled now in DirectX10? Have they gotten rid of paramBlocks? In dx9 for an effect with constant values you would do a: H = _shader->BeginParameterBlock(); H = _shader->SetBool(...) H = _shader->SetFloat(...) H = _shader->SetInt(...) _paramblock = _shader->EndParameterBlock(); then.. void render_loop() { _state_block->Apply(); } How is that handled now in DX10? Also, how would you do this is you were not using the effect system.. just with straight shaders. Can those values be captured in a StateBlock?
jollyjeffers
jollyjeffers
States in general are much less granular in Direct3D 10 so there is less (if any) need for this sort of construct.

Constants are uploaded as 'constant buffers' which are all-or-nothing groupings and therefore somewhat analagous to the D3D9 parameter blocks you're looking for.

This sort of thing isn't made clear via the FX10 API, it's only by using the cbuffer {} syntax in your FX file that it is exposed to you as a developer.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
WOsborn
WOsborn
I still dont get this...

My current system supports both d3d9 and openGL using stateBlocks and
displayLists. I'm looking at getting DX10 up and running now.
The current pre-dx10 material load routine goes something like this....

1. load mesh, get material name
2. Read material's config file.
3. compile vert/pixel shader(s) specified in material's config.
4. save shaders in a std::map for later to skip recompiling.
5. collect desc/param info from shaders. (name/handle/reg.slot)
6. BeginStateBlock()/ genNewList(displayList) <--- unique per material instance
7. loop thru collected param info setting const values read in from mat config.
8. saved_sb = EndStateblock()/End DisplayList

now during render I just call/apply that stateblock

void render_loop()
{
dev->set_shader(blah.vert); <--- shared
dev->set_shader(blah.pixel); <--- shared
call/apply(saved_sb); <--- unique

render....
}

So by looking at that I can't just set constants at compile time and expect them
to be correct at render time... multiple objects share same shader instance
but need to use different textures or values at render time and so they apply
the state_block. The reason I keep shaders in a map is to save memory
of having to recompile the shader multiple times.

So how would this translate to a dx10 material/shader system. Looking at
const_buffers it looks like the app has to have hardcoded knowledge about the
cbuffers in the shaders? Is that correct?

Does a DX10 stateBlock capture same info as it did in dx9 in regards to setting
shader_constants and texture slots?

I'm more interested in raw shaders not using the effect system that way the
material file can stay generic for d3d and openGL.

Thanks,
WOsborn

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.