Effect File Changes vs. Constants Changes

Started by
0 comments, last by Zipster 16 years, 10 months ago
Hey everyone, I'm working on a project where I'm implementing the shader management system and am curious about the best architecture. More specifically, I'm currently designing it so that every Effect file (I'm in DX9c ) is loaded into memory only once and a pointer to it is shared across any object that uses it to render. With this implementation the only device state changes are the parameters that have to be set by the specific object ( WorldViewProj, diffuse textures, etc ). From a memory standpoint, this seems right to me. But, I considered that all of those object specific state-changes might be more expensive than just having the same Effect in memory once for each object. That way, the object could set its parameters when it loaded the effect and not have to worry about updating Textures or light positions or diffuse colors during runtime. This would greatly reduce the number of state changes. So long story short, does anyone know if its more expensive to switch Effects ( vertex and pixel shader ), or to make changes to the constants? Thanks and sorry if my wording is confusing. -Winston
Advertisement
Use a hybrid approach. Initially have a single instance of each effect that has the default parameters set. Then allow objects to make clones of the effect if they each want to have their own custom parameters. Link it to the parent effect so that default parameter values can still be set if the object has no overrides.

This topic is closed to new replies.

Advertisement