# Difference between texture.Load() and texture.Sample() methods in DirectX?

The question is simply that: What is the difference between texture.Load() and texture.Sample() in DirectX?

I've used a Texture2D to store the depth in a pass of a DirectX Shader (with SharpDX), and now that I want to extract the depth from the texture I'm not sure which of the two methods I should use

The Sample method accepts a UV coordinate (where the texture covers the [0, 1] range), does mipmap selection based on the UV derivatives, applies addressing modes (clamp, wrap, border) and does filtering (bilinear, trilinear, aniso).

The Load method accepts a texel coordinate in the [0, textureWidth - 1] x [0, textureHeight - 1] range, and the desired mip level, and simply loads a single texel. Coordinates outside the texture's range just return zero, and no filtering is done.

When trying to map a texture 1:1 to the screen, it's convenient to combine Load with the SV_Position input semantic in a pixel shader, as they're in the same units. So you can do this:

void ps_main(float4 screenPos : SV_Position, ...)
{

That way you don't need to calculate any UVs. However, this only works if the texture is the same size as the screen; so you can't load half-res or quarter-res textures this way. For those, you'd have to calculate UVs and use Sample.