Load (DirectX HLSL Texture Object)

Reads texel data without any filtering or sampling.

ret Object.Load(
int Location,
[int SampleIndex, ]
[int Offset ]




A texture-object type (except TextureCube or TextureCubeArray).


[in] The texture coordinates; the last component specifies the mipmap level. This method uses a 0-based coordinate system and not a 0.0-1.0 UV system. The argument type is dependent on the texture-object type.

Object Type Parameter Type
Buffer int
Texture1D, Texture2DMS int2
Texture1DArray, Texture 2D, Texture2DMSArray int3
Texture2DArray, Texture3D int4


For example, to access a 2D texture, supply UV coordinates for the first two components and a mipmap level for the third component.


When one or more of the coordinates in Location exceed the u, v, or w mipmap level dimensions of the texture, Load returns zero in all components. Direct3D guarantees to return zero for any resource that is accessed out of bounds.



[in] An optional sampling index.

Texture Type Parameter Type
Texture1D, Texture1DArray, Texture2D, Texture2DArray, Texture3D, Texture2DArray, TextureCube, TextureCubeArray not supported
Texture2DMS, Texture2DMSArray¹ int



SampleIndex is only available for multi-sample textures.



[in] An optional offset applied to the texture coordinates before sampling. The offset type is dependent on the texture-object type.

Texture Type Parameter Type
Texture1D, Texture1DArray int
Texture2D, Texture2DArray, Texture2DMS, Texture2DMSArray int2
Texture3D, Texture2DArray int3



If you use Offset with multi-sample textures, you must also specify SampleIndex.


Return Value

The return type matches the type in the Object declaration. For example, a Texture2D object that was declared as "Texture2d myTexture;" has a return value of type uint4.

Minimum Shader Model

This function is supported in the following shader models.

vs_4_0 vs_4_1¹ ps_4_0 ps_4_1¹ gs_4_0 gs_4_1¹
x x x x x x


  • Shader Model 4.1 is available in Direct3D 10.1 or higher.


This partial code example is from the Paint.fx file in the AdvancedParticles Sample.

// Object Declarations
Buffer<float4> g_ParticleBuffer;

// Shader body calling the intrinsic function
float4 PSPaint(PSQuadIn input) : SV_Target
    for( int i=g_ParticleStart; i<g_NumParticles; i+=g_ParticleStep )
        // load the particle
        float4 particlePos = g_ParticleBuffer.Load( i*4 );
        float4 particleColor = g_ParticleBuffer.Load( (i*4) + 2 );