texldl (Pixel Shader)
Sample a texture with a particular sampler. The particular mipmap level (LOD) being sampled has to be specified as the 4th component of the texture coordinate.
Syntax
Where:
- dst is a destination register.
- 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 |
---|
texldl | | | | | | | | x | x |
---|
texldl (Pixel Shader) looks up the texture set at the sampler stage referenced by src1. The LOD is selected from src0.w. This value can be negative in which case the LOD selected is the zero'th one (biggest map) with the MAGFILTER. Since src0.w is a floating point value, the fractional value is used to interpolate (if MIPFILTER is LINEAR) between two mip levels. Sampler states MIPMAPLODBIAS and MAXMIPLEVEL are honored. For more information about sampler states, see D3DSAMPLERSTATETYPE.
If a shader program samples from a sampler that does not have a texture set, then 0001 is obtained in the destination register.
The following rough algorithm has been provided for reference, that the reference device follows.
LOD = src0.w + LODBIAS;
if (LOD <= 0 )
{
LOD = 0;
Filter = MagFilter;
tex = Lookup( MAX(MAXMIPLEVEL, LOD), Filter );
}
else
{
Filter = MinFilter;
LOD = MAX( MAXMIPLEVEL, LOD);
tex = Lookup( Floor(LOD), Filter );
if( MipFilter == LINEAR )
{
tex1 = Lookup( Ceil(LOD), Filter );
tex = (1 - frac(src0.w))*tex + frac(src0.w)*tex1;
}
}
Restrictions:
- The texture coordinates should not be scaled by texture size.
- dst must be r#
- dst can accept a writemask.
- Defaults for missing components are either 0 or 1, and depend on the texture format.
- src1 must be s#, with no negate, but can have swizzle. The s# must have been declared (using dcl) at the beginning of the shader. The swizzle specifies how to output each component result of the sample.
- 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 runtime will attempt to detect mismatches (possibly in debug only). 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.
- If the 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.
- 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.
- There is no dependent read limit.
Minimum operating system | Windows 98 |
---|