# Using Sampler States in Effect file

I have been reading a lot of different shaders and some have the preference of:

sampler depthSampler : register(s1);


Whilst others take the longer route:

texture depthMap;
sampler depthSampler = sampler_state
{
// etc.
};


Is there any real difference between the two? Does one perform faster than the other?

• I think, that performance is the same. In the first case, settings from your application is taken. In the second case, you can set sampler (clamping etc.) on your own. – zacharmarz Feb 16 '12 at 13:05

In the first example the sampler state is left uninitialized and works just like any other parameter (e.g. your WorldMatrix) - this would allow your game to change the sampler at runtime. Conversely your shader won't work if you don't initialize the sampler. Most often you will see this syntax in conjunction with custom SpriteBatch shaders as they would allow the SpriteBatch to provide crucial configuration.