gather4 (sm5 - asm)
Gathers the four texels that would be used in a bi-linear filtering operation and packs them into a single register. This instruction only works with 2D or CubeMap textures, including arrays. Only the addressing modes of the sampler are used and the top level of any mip pyramid is used.
gather4[_aoffimmi(u,v)] dest[.mask], srcAddress[.swizzle], srcResource[.swizzle], srcSampler[.select_component] |
---|
Item | Description |
---|---|
dest |
[in] The address of the results of the operation. |
srcAddress |
[in] A set of texture coordinates. |
srcResource |
[in] A texture register. |
srcSampler |
[in] A sampler register. |
Remarks
This instruction behaves like the sample instruction, but a filtered sample is not generated. The four samples that would contribute to filtering are placed into xyzw in counter clockwise order starting with the sample to the lower left of the queried location. This is the same as point sampling with (u,v) texture coordinate deltas at the following locations: (-,+),(+,+),(+,-),(-,-), where the magnitude of the deltas are always half a texel.
For CubeMap textures, when a bi-linear footprint spans an edge, texels from the neighboring face are used. Corners use the same rules as the sample instruction; that is, the unknown corner is considered the average of the three impinging face corners.
There are texture format restrictions that apply to gather4 which are expressed in the format list.
The swizzle on srcResource allows the returned values to be swizzled arbitrarily before they are written to the destination.
The .select_component on srcSampler chooses which component of the source texture (r/g/b/a) to read 4 texels from.
For formats with float32 components, if the value being fetched is normalized, denormalized, +-0 or +-INF, it is returned to the shader unaltered. NaN is returned as NaN, but the exact bit representation of the NaN may be changed. For TextureCubes, some synthesis of the missing 4th texel must occur at corners, so returning bits unchanged for the synthesized texel does not apply, and denorms could be flushed.
For hardware implementations, optimizations in traditional bilinear filtering that detect samples directly on texels and skip reading of texels that would have weight 0 cannot be leveraged with this instruction. gather4 always returns all requested texels.
This instruction applies to the following shader stages:
Vertex | Hull | Domain | Geometry | Pixel | Compute |
---|---|---|---|---|---|
X | X | X | X | X | X |
Minimum Shader Model
This instruction is supported in the following shader models:
Shader Model | Supported |
---|---|
Shader Model 5 | yes |
Shader Model 4.1 | no |
Shader Model 4 | no |
Shader Model 3 (DirectX HLSL) | no |
Shader Model 2 (DirectX HLSL) | no |
Shader Model 1 (DirectX HLSL) | no |