texld (Pixel Shader)
Sample a texture at a particular sampler, using provided texture coordinates. This instruction is different from the texld instruction used in pixel shader version 1_4.
Syntax
texld dst[_pp], src0, src1 |
---|
Where:
- dst is a destination register. It must be the predicate register.
- [_pp] optional partial precision. This has been available for pixel shaders since ps_2_0. See Partial Precision.
- src0 is a source register that provides the texture coordinates for the texture sample.
- src1 identifies the source sampler register (s#), where # specifies which texture sampler number to sample. The sampler has associated with it a texture and a control state defined by the D3DSAMPLERSTATETYPE enumeration (ex. D3DSAMP_MINFILTER).
Remarks
Pixel shader versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
---|
texld | | | | | x | x | x | x | x |
---|
Restrictions:
- Occupies 1 addressing instruction slot.
- dst must be r#.
- dst requires no writemask, texld* instructions always write out 4 components. If the source texture contains less than 4 components, defaults are placed in the missing components. Defaults for missing components are either 0 or 1, and depend on the texture format. The reference rasterizer source lists the defaults.
- _sat instruction modifier is NOT allowed on dst.
- src1 must be s#, with no negate or swizzle. The s# must have been declared at the beginning of the shader.
- The number of coordinates required to perform the texture sample depends on how the s# was declared. If it was declared as a cube, a 3 component texture coordinate is required (.rgb). Validation enforces that coordinates provided to texld are sufficient for the texture dimension declared for the sampler. However, it is not guaranteed that the application actually set a texture (through the API) with
dimensions equal to the dimension declared for the sampler. In such a case, the debug runtime will attempt to detect mismatches. Sampling a texture with lower dimensions than are present in the texture coordinate will be allowed, and be assumed to ignore the extra texture coordinate components. Conversely, sampling a texture with higher dimensions than are present in the texture coordinate is illegal.
- For texldb and texldp, in addition to the components of the texture coordinate required to index the texture dimension, the w-component of the coordinate is required.
- src0 (texture coordinate) may be t#/r# registers only, with no negate or swizzle.
- If src0 (texture coordinate) is a t# register, the components required for the lookup (described above) must have been dcl'd.
- If src0 (texture coordinate) is r#, the components required for the lookup (described above) must have been previously written.
- Sampling unsigned RGB textures will result in float values between 0.0 and 1.0. If these textures contain vectors, for example, that are stored as biased-signed values, then an explicit ps instruction can be used to expand them.
def c2, 2, 2, 2, 2
def c5, 1, 1, 1, 1
...
texld r0, t0, s0
mad r0, r0, c2, -c5
- Sampling signed textures will result in float values between -1.0 to 1.0.
- When sampling floating point textures, Float16 means that the data will range within MAX_FLOAT16. Float32 means the maximum range of the pipeline will be used. Sampling outside of either range is undefined.
- A first order dependent tex-op is a tex[ld*|kill] instruction in which either:
- an r# reg is input (NOT t# reg)
- output r# reg was previously written, now being written AGAIN.
A 2nd order dependent tex-op occurs if: a tex-op reads OR WRITES to an r# reg whose contents, BEFORE executing the tex-op, depend (perhaps indirectly) on the outcome of a 1st order dependent tex-op. An (n)th order dependent tex-op derives from an (n-1)th order tex-op. A given tex-op may be dependent to at most 3rd order.