Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Load (DirectX HLSL Texture Object)

Reads texel data without any filtering or sampling.

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

 

Parameters

Object

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

Location

[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 TypeParameter Type
Bufferint
Texture1D, Texture2DMSint2
Texture1DArray, Texture 2D, Texture2DMSArrayint3
Texture2DArray, Texture3Dint4

 

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

Note  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.

SampleIndex

[in] An optional sampling index.

Texture TypeParameter Type
Texture1D, Texture1DArray, Texture2D, Texture2DArray, Texture3D, Texture2DArray, TextureCube, TextureCubeArraynot supported
Texture2DMS, Texture2DMSArray1int

 

Note  SampleIndex is only available for multi-sample textures.

Offset

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

Texture TypeParameter Type
Texture1D, Texture1DArrayint
Texture2D, Texture2DArray, Texture2DMS, Texture2DMSArrayint2
Texture3D, Texture2DArrayint3

 

Note  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<uint4> myTexture;" has a return value of type uint4.

Minimum Shader Model

This function is supported in the following shader models.

vs_4_0vs_4_11ps_4_0ps_4_11gs_4_0gs_4_11
xxxxxx

 

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

Example

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 );
        ...		
    }
    ...
}	


Related topics

Texture-Object

 

 

Community Additions

Show:
© 2014 Microsoft