There are several ways to access resources. Regardless, Direct3D guarantees to return zero for any resource that is accessed out of bounds.
Access By Byte Offset
Two new buffer types can be accessed using a byte offset:
Access By Index
Resource types can use an index to reference a specific location in the resource. Consider this example:
uint2 pos; Texture2D<float4> myTexture; float4 myVar = myTexture[pos];
This example assigns the 4 float values that are stored at the texel located at the pos position in the myTexture 2D texture resource to the myVar variable.
The default for accessing a texture in this way is mipmap level zero (the most detailed level).
The "float4 myVar = myTexture[pos];" line is equivalent to "float4 myVar = myTexture.Load(uint3(pos,0));". Access by index is a new HLSL syntax enhancement.
The compiler in the June 2010 version of the DirectX SDK and later lets you index all resource types except for byte address buffers.
The June 2010 compiler and later lets you declare local resource variables. You can assign globally defined resources (like myTexture) to these variables and use them the same way as their global counterparts.
Access By Mips Method
Texture objects have a mips method (for example, Texture2D.mips), which you can use to specify the mipmap level. This example reads the color stored at (7,16) on mipmap level 2 in a 2D texture:
uint x = 7; uint y = 16; float4 myColor = myTexture.mips[uint2(x,y)];
This is an enhancement from the June 2010 compiler and later. The "myTexture.mips[uint2(x,y)]" expression is equivalent to "myTexture.Load(uint3(x,y,2))".