sample_d (sm4 - asm)

Samples data from the specified Element/texture using the specified address and the filtering mode identified by the given sampler.

sample_d[_aoffimmi(u,v,w)] dest[.mask], srcAddress[.swizzle], srcResource[.swizzle], srcSampler, srcXDerivatives[.swizzle], srcYDerivatives[.swizzle]
Item Description
dest
[in] The address of the results of the operation.
srcAddress
[in] A set of texture coordinates. For more information see the sample instruction.
srcResource
[in] A texture register. For more information see the sample instruction.
srcSampler
[in] A sampler register. For more information see the sample instruction.
srcXDerivatives
[in] The derivatives for the source address in the x direction. For more information, see the Remarks section.
srcYDerivatives
[in] The derivatives for the source address in the y direction. For more information, see the Remarks section.

Remarks

This instruction behaves like the sample instruction, except that derivatives for the source address in the x direction and the y direction are provided by extra parameters, srcXDerivatives and srcYDerivatives, respectively. These derivatives are in normalized texture coordinate space.

The r, g and b components of srcXDerivatives (POS-swizzle) provide du/dx, dv/dx and dw/dx. The 'a' component (POS-swizzle) is ignored.

The r, g and b components of srcYDerivatives (POS-swizzle) provide du/dy, dv/dy and dw/dy. The 'a' component (POS-swizzle) is ignored.

Unlike the sample instruction, which is permitted to share a single LOD calculation across a 2x2 stamp, sample_d must calculate LOD completely independently, per-pixel when used in the Pixel Shader.

If the derivative inputs to sample_d came from derivative calculation instructions in the Pixel Shader and the values include INF/NaN, the behavior of sample_d may not match the sample instruction, which implicitly computes the derivative. The INF/NaN values may affect the LOD calculation differently.

Fetching from an input slot that has nothing bound to it returns 0 for all components.

Restrictions

  • sample_d inherits the same restrictions as the sample instruction, plus additional an restriction below for its additional parameters.
  • srcXDerivatives and srcYDerivatives must be temp (r#/x#), constantBuffer (cb#), input (v#) registers or immediate value(s).

This instruction applies to the following shader stages:

Vertex Shader Geometry Shader Pixel Shader
X X x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 5 yes
Shader Model 4.1 yes
Shader Model 4 yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

Shader Model 4 Assembly (DirectX HLSL)