   Is it better practice to use several effects files or one large file?
  Hi, thanks for reading this.  Hope this question isn't too dumb.Is it better practice to use several effects files or one large file?  I'm using XNA 3.1.  I'm not sure how the GPU uses memory.  It seems to me that one large effect file is better because you always have to pass a lot of common parameters to the effect, such as Position, View, etc..  With one large file then wouldn't you only have to pass these parameters at the top of every loop, instead of repeatedly for every component/effect file, and wouldn't the GPU only have to store this data once?I suppose the argument for several effects files is resuable code and easier to manage, but is this at the cost of performance?  Or is the GPU so damn fast it simply doesn't matter?How wrong am I?Thanks!   
  You can organize your effect files in whichever way makes sense for you, it won't have an impact on performance. This is because the effects framework is just a layer on top of the low-level shader interface in D3D9, which means that how you lay out your effect doesn't reflect how the actual low-level resources are created. On a low-level, there are no resources created for shader constants. Instead D3D9 exposes a flat register file of constant registers, and the effects system automatically maps your constants to registers for every single shader in that effect file that uses it. Then when you apply a technique and pass that uses a shader (or when you call CommitChanges), the effects framework uses SetVertexShaderConstant or SetPixelShaderConstant calls to set the values of constant registers used by that shader.   ;  THanks Matt.Does this mean then that if I have two different effects files and both have a Position variable that I only need to pass the variable once?   ;Quote:Original post by danromeoTHanks Matt.Does this mean then that if I have two different effects files and both have a Position variable that I only need to pass the variable once?No...you see an Effect will internally hold a value for each EffectParameter. Then when you apply that Effect, it will set that internally cached value as the register value. So for instance if you have a bunch of Effect's with a ViewMatrix parameter, you'll need to set the value for each Effect.;  I think what the OP was getting at is that if you have 10 seperate effect _files_, each with a ViewProj matrix param, if you use each of those effects per frame, you'll have to set the ViewProj param 10 times per frame.As opposed to having one huge effect file to do everything (perhaps with runtime switches) which will mean only needing to set ViewProj once per frame.Apologies for stepping in, Matt, but were you talking about different effects in one file rather than lots of effects each having its own file?  I've often wondered which is best too.   ;  I don't think it matters as MJP said. What matters is what technique is applied and if you are not using the same technique, then you will have to set the particular param for n invocation of the shader. Unless the parameter is declared as shared, each technique will get its own copy of the parameter regardless if its defined once and used in multiple files, or in the same file with multiple shaders.   