Where in previous XNA versions you used to write:
effect.Begin(); effect.CurrentTechnique.Passes.Begin(); DrawStuff(); effect.CurrentTechnique.Passes.End(); effect.End();
With Game Studio 4.0 this becomes just:
What in previous versions would be:
effect.Begin(); effect.CurrentTechnique.Passes.Begin(); DrawStuff(); effect.Parameters["lives"].SetValue(9); effect.CommitChanges(); DrawOtherStuff(); effect.CurrentTechnique.Passes.End(); effect.End();
effect.CurrentTechnique.Passes.Apply(); DrawStuff(); effect.Parameters["lives"].SetValue(9); effect.CurrentTechnique.Passes.Apply(); DrawOtherStuff();
Editors note: if you profile the new Apply method with the 4.0 CTP, you may notice it is slower than the old CommitChanges. Don't worry: this is just a temporary state of affairs due to some missing optimizations that didn't make it in time for the CTP release.
We also took out a bunch of stuff:
- Removed the low level shader APIs (VertexShader, PixelShader, SetVertexShaderConstant, SetPixelShaderConstant, GetVertexShaderConstant, GetPixelShaderConstant, ShaderConstantTable, ShaderProfile, ShaderRegisterSet, and ShaderSemantic). These duplicated the same functionality that is also available using Effect and EffectParameter, but in a form that was closely tied to DirectX 9, and which could not be efficiently implemented with DirectX 10 or 11. Effects provide an abstraction that sits naturally on top of multiple native layers, and the vast majority of our customers preferred the Effect API in any case.
- Removed EffectPool. This was confusing, and turned out to be nowhere near as useful as it seemed on the surface like it ought to be.
- Removed EffectParameterBlock. This looked like it could be a useful optimization technique, but in fact always made things slower anytime anyone tried to use it :-)
- Removed assorted other boring and rarely used doodads (EffectFunction, Effect.Creator, EffectParameter.SetArrayRange, and EffectTechnique.IsParameterUsed).
Finally, we upgraded to a more recent version of the Windows HLSL compiler, which means that:
- You can use newer HLSL features such as loop control attributes.
- Shader model 1.x is no longer supported. Game Studio 4.0 requires at least shader model 2.0.