1848b8605Smrg.. _sampler:
2848b8605Smrg
3848b8605SmrgSampler
4848b8605Smrg=======
5848b8605Smrg
6848b8605SmrgTexture units have many options for selecting texels from loaded textures;
7848b8605Smrgthis state controls an individual texture unit's texel-sampling settings.
8848b8605Smrg
9848b8605SmrgTexture coordinates are always treated as four-dimensional, and referred to
10848b8605Smrgwith the traditional (S, T, R, Q) notation.
11848b8605Smrg
12848b8605SmrgMembers
13848b8605Smrg-------
14848b8605Smrg
15848b8605Smrgwrap_s
16848b8605Smrg    How to wrap the S coordinate. One of PIPE_TEX_WRAP_*.
17848b8605Smrgwrap_t
18848b8605Smrg    How to wrap the T coordinate. One of PIPE_TEX_WRAP_*.
19848b8605Smrgwrap_r
20848b8605Smrg    How to wrap the R coordinate. One of PIPE_TEX_WRAP_*.
21848b8605Smrg
22848b8605SmrgThe wrap modes are:
23848b8605Smrg
24848b8605Smrg* ``PIPE_TEX_WRAP_REPEAT``: Standard coord repeat/wrap-around mode.
25848b8605Smrg* ``PIPE_TEX_WRAP_CLAMP_TO_EDGE``: Clamp coord to edge of texture, the border
26848b8605Smrg  color is never sampled.
27848b8605Smrg* ``PIPE_TEX_WRAP_CLAMP_TO_BORDER``: Clamp coord to border of texture, the
28848b8605Smrg  border color is sampled when coords go outside the range [0,1].
29848b8605Smrg* ``PIPE_TEX_WRAP_CLAMP``: The coord is clamped to the range [0,1] before
30848b8605Smrg  scaling to the texture size.  This corresponds to the legacy OpenGL GL_CLAMP
31848b8605Smrg  texture wrap mode.  Historically, this mode hasn't acted consistantly across
32848b8605Smrg  all graphics hardware.  It sometimes acts like CLAMP_TO_EDGE or
33848b8605Smrg  CLAMP_TO_BORDER.  The behaviour may also vary depending on linear vs.
34848b8605Smrg  nearest sampling mode.
35848b8605Smrg* ``PIPE_TEX_WRAP_MIRROR_REPEAT``: If the integer part of the coordinate
36848b8605Smrg  is odd, the coord becomes (1 - coord).  Then, normal texture REPEAT is
37848b8605Smrg  applied to the coord.
38848b8605Smrg* ``PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE``: First, the absolute value of the
39848b8605Smrg  coordinate is computed.  Then, regular CLAMP_TO_EDGE is applied to the coord.
40848b8605Smrg* ``PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER``: First, the absolute value of the
41848b8605Smrg  coordinate is computed.  Then, regular CLAMP_TO_BORDER is applied to the
42848b8605Smrg  coord.
43848b8605Smrg* ``PIPE_TEX_WRAP_MIRROR_CLAMP``: First, the absolute value of the coord is
44848b8605Smrg  computed.  Then, regular CLAMP is applied to the coord.
45848b8605Smrg
46848b8605Smrg
47848b8605Smrgmin_img_filter
48848b8605Smrg    The image filter to use when minifying texels. One of PIPE_TEX_FILTER_*.
49848b8605Smrgmag_img_filter
50848b8605Smrg    The image filter to use when magnifying texels. One of PIPE_TEX_FILTER_*.
51848b8605Smrg
52848b8605SmrgThe texture image filter modes are:
53848b8605Smrg
54848b8605Smrg* ``PIPE_TEX_FILTER_NEAREST``: One texel is fetched from the texture image
55848b8605Smrg  at the texture coordinate.
56848b8605Smrg* ``PIPE_TEX_FILTER_LINEAR``: Two, four or eight texels (depending on the
57848b8605Smrg  texture dimensions; 1D/2D/3D) are fetched from the texture image and
58848b8605Smrg  linearly weighted and blended together.
59848b8605Smrg
60848b8605Smrgmin_mip_filter
61848b8605Smrg    The filter to use when minifying mipmapped textures. One of
62848b8605Smrg    PIPE_TEX_MIPFILTER_*.
63848b8605Smrg
64848b8605SmrgThe texture mip filter modes are:
65848b8605Smrg
66848b8605Smrg* ``PIPE_TEX_MIPFILTER_NEAREST``: A single mipmap level/image is selected
67848b8605Smrg  according to the texture LOD (lambda) value.
68848b8605Smrg* ``PIPE_TEX_MIPFILTER_LINEAR``: The two mipmap levels/images above/below
69848b8605Smrg  the texture LOD value are sampled from.  The results of sampling from
70848b8605Smrg  those two images are blended together with linear interpolation.
71848b8605Smrg* ``PIPE_TEX_MIPFILTER_NONE``: Mipmap filtering is disabled.  All texels
72848b8605Smrg  are taken from the level 0 image.
73848b8605Smrg
74848b8605Smrg
75848b8605Smrgcompare_mode
76848b8605Smrg    If set to PIPE_TEX_COMPARE_R_TO_TEXTURE, the result of texture sampling
77848b8605Smrg    is not a color but a true/false value which is the result of comparing the
78848b8605Smrg    sampled texture value (typically a Z value from a depth texture) to the
79848b8605Smrg    texture coordinate's R component.
80848b8605Smrg    If set to PIPE_TEX_COMPARE_NONE, no comparison calculation is performed.
81848b8605Smrgcompare_func
82848b8605Smrg    The inequality operator used when compare_mode=1.  One of PIPE_FUNC_x.
83848b8605Smrgnormalized_coords
84848b8605Smrg    If set, the incoming texture coordinates (nominally in the range [0,1])
85848b8605Smrg    will be scaled by the texture width, height, depth to compute texel
86848b8605Smrg    addresses.  Otherwise, the texture coords are used as-is (they are not
87848b8605Smrg    scaled by the texture dimensions).
88848b8605Smrg    When normalized_coords=0, only a subset of the texture wrap modes are
89848b8605Smrg    allowed: PIPE_TEX_WRAP_CLAMP, PIPE_TEX_WRAP_CLAMP_TO_EDGE and
90848b8605Smrg    PIPE_TEX_WRAP_CLAMP_TO_BORDER.
91848b8605Smrglod_bias
92848b8605Smrg    Bias factor which is added to the computed level of detail.
93848b8605Smrg    The normal level of detail is computed from the partial derivatives of
94848b8605Smrg    the texture coordinates and/or the fragment shader TEX/TXB/TXL
95848b8605Smrg    instruction.
96848b8605Smrgmin_lod
97848b8605Smrg    Minimum level of detail, used to clamp LOD after bias.  The LOD values
98848b8605Smrg    correspond to mipmap levels where LOD=0 is the level 0 mipmap image.
99848b8605Smrgmax_lod
100848b8605Smrg    Maximum level of detail, used to clamp LOD after bias.
101848b8605Smrgborder_color
102848b8605Smrg    Color union used for texel coordinates that are outside the [0,width-1],
103848b8605Smrg    [0, height-1] or [0, depth-1] ranges. Interpreted according to sampler
104848b8605Smrg    view format, unless the driver reports
105848b8605Smrg    PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK, in which case special care has to be
106848b8605Smrg    taken (see description of the cap).
107848b8605Smrgmax_anisotropy
108848b8605Smrg    Maximum anistropy ratio to use when sampling from textures.  For example,
109848b8605Smrg    if max_anistropy=4, a region of up to 1 by 4 texels will be sampled.
110848b8605Smrg    Set to zero to disable anisotropic filtering.  Any other setting enables
111848b8605Smrg    anisotropic filtering, however it's not unexpected some drivers only will
112848b8605Smrg    change their filtering with a setting of 2 and higher.
113848b8605Smrgseamless_cube_map
114848b8605Smrg    If set, the bilinear filter of a cube map may take samples from adjacent
115848b8605Smrg    cube map faces when sampled near a texture border to produce a seamless
116848b8605Smrg    look.
117