xref: /aosp_15_r20/external/mesa3d/docs/gallium/cso/sampler.rst (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker.. _sampler:
2*61046927SAndroid Build Coastguard Worker
3*61046927SAndroid Build Coastguard WorkerSampler
4*61046927SAndroid Build Coastguard Worker=======
5*61046927SAndroid Build Coastguard Worker
6*61046927SAndroid Build Coastguard WorkerTexture units have many options for selecting texels from loaded textures;
7*61046927SAndroid Build Coastguard Workerthis state controls an individual texture unit's texel-sampling settings.
8*61046927SAndroid Build Coastguard Worker
9*61046927SAndroid Build Coastguard WorkerTexture coordinates are always treated as four-dimensional, and referred to
10*61046927SAndroid Build Coastguard Workerwith the traditional (S, T, R, Q) notation.
11*61046927SAndroid Build Coastguard Worker
12*61046927SAndroid Build Coastguard WorkerMembers
13*61046927SAndroid Build Coastguard Worker-------
14*61046927SAndroid Build Coastguard Worker
15*61046927SAndroid Build Coastguard Workerwrap_s
16*61046927SAndroid Build Coastguard Worker    How to wrap the S coordinate. One of PIPE_TEX_WRAP_*.
17*61046927SAndroid Build Coastguard Workerwrap_t
18*61046927SAndroid Build Coastguard Worker    How to wrap the T coordinate. One of PIPE_TEX_WRAP_*.
19*61046927SAndroid Build Coastguard Workerwrap_r
20*61046927SAndroid Build Coastguard Worker    How to wrap the R coordinate. One of PIPE_TEX_WRAP_*.
21*61046927SAndroid Build Coastguard Worker
22*61046927SAndroid Build Coastguard WorkerThe wrap modes are:
23*61046927SAndroid Build Coastguard Worker
24*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_REPEAT``: Standard coord repeat/wrap-around mode.
25*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_CLAMP_TO_EDGE``: Clamp coord to edge of texture, the border
26*61046927SAndroid Build Coastguard Worker  color is never sampled.
27*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_CLAMP_TO_BORDER``: Clamp coord to border of texture, the
28*61046927SAndroid Build Coastguard Worker  border color is sampled when coords go outside the range [0,1].
29*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_CLAMP``: The coord is clamped to the range [0,1] before
30*61046927SAndroid Build Coastguard Worker  scaling to the texture size.  This corresponds to the legacy OpenGL GL_CLAMP
31*61046927SAndroid Build Coastguard Worker  texture wrap mode.  Historically, this mode hasn't acted consistently across
32*61046927SAndroid Build Coastguard Worker  all graphics hardware.  It sometimes acts like CLAMP_TO_EDGE or
33*61046927SAndroid Build Coastguard Worker  CLAMP_TO_BORDER.  The behavior may also vary depending on linear vs.
34*61046927SAndroid Build Coastguard Worker  nearest sampling mode.
35*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_MIRROR_REPEAT``: If the integer part of the coordinate
36*61046927SAndroid Build Coastguard Worker  is odd, the coord becomes (1 - coord).  Then, normal texture REPEAT is
37*61046927SAndroid Build Coastguard Worker  applied to the coord.
38*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE``: First, the absolute value of the
39*61046927SAndroid Build Coastguard Worker  coordinate is computed.  Then, regular CLAMP_TO_EDGE is applied to the coord.
40*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER``: First, the absolute value of the
41*61046927SAndroid Build Coastguard Worker  coordinate is computed.  Then, regular CLAMP_TO_BORDER is applied to the
42*61046927SAndroid Build Coastguard Worker  coord.
43*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_WRAP_MIRROR_CLAMP``: First, the absolute value of the coord is
44*61046927SAndroid Build Coastguard Worker  computed.  Then, regular CLAMP is applied to the coord.
45*61046927SAndroid Build Coastguard Worker
46*61046927SAndroid Build Coastguard Worker
47*61046927SAndroid Build Coastguard Workermin_img_filter
48*61046927SAndroid Build Coastguard Worker    The image filter to use when minifying texels. One of PIPE_TEX_FILTER_*.
49*61046927SAndroid Build Coastguard Workermag_img_filter
50*61046927SAndroid Build Coastguard Worker    The image filter to use when magnifying texels. One of PIPE_TEX_FILTER_*.
51*61046927SAndroid Build Coastguard Worker
52*61046927SAndroid Build Coastguard WorkerThe texture image filter modes are:
53*61046927SAndroid Build Coastguard Worker
54*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_FILTER_NEAREST``: One texel is fetched from the texture image
55*61046927SAndroid Build Coastguard Worker  at the texture coordinate.
56*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_FILTER_LINEAR``: Two, four or eight texels (depending on the
57*61046927SAndroid Build Coastguard Worker  texture dimensions; 1D/2D/3D) are fetched from the texture image and
58*61046927SAndroid Build Coastguard Worker  linearly weighted and blended together.
59*61046927SAndroid Build Coastguard Worker
60*61046927SAndroid Build Coastguard Workermin_mip_filter
61*61046927SAndroid Build Coastguard Worker    The filter to use when minifying mipmapped textures. One of
62*61046927SAndroid Build Coastguard Worker    PIPE_TEX_MIPFILTER_*.
63*61046927SAndroid Build Coastguard Worker
64*61046927SAndroid Build Coastguard WorkerThe texture mip filter modes are:
65*61046927SAndroid Build Coastguard Worker
66*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_MIPFILTER_NEAREST``: A single mipmap level/image is selected
67*61046927SAndroid Build Coastguard Worker  according to the texture LOD (lambda) value.
68*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_MIPFILTER_LINEAR``: The two mipmap levels/images above/below
69*61046927SAndroid Build Coastguard Worker  the texture LOD value are sampled from.  The results of sampling from
70*61046927SAndroid Build Coastguard Worker  those two images are blended together with linear interpolation.
71*61046927SAndroid Build Coastguard Worker* ``PIPE_TEX_MIPFILTER_NONE``: Mipmap filtering is disabled.  All texels
72*61046927SAndroid Build Coastguard Worker  are taken from the level 0 image.
73*61046927SAndroid Build Coastguard Worker
74*61046927SAndroid Build Coastguard Worker
75*61046927SAndroid Build Coastguard Workercompare_mode
76*61046927SAndroid Build Coastguard Worker    If set to PIPE_TEX_COMPARE_R_TO_TEXTURE, the result of texture sampling
77*61046927SAndroid Build Coastguard Worker    is not a color but a true/false value which is the result of comparing the
78*61046927SAndroid Build Coastguard Worker    sampled texture value (typically a Z value from a depth texture) to the
79*61046927SAndroid Build Coastguard Worker    texture coordinate's R component.
80*61046927SAndroid Build Coastguard Worker    If set to PIPE_TEX_COMPARE_NONE, no comparison calculation is performed.
81*61046927SAndroid Build Coastguard Workercompare_func
82*61046927SAndroid Build Coastguard Worker    The inequality operator used when compare_mode=1.  One of PIPE_FUNC_x.
83*61046927SAndroid Build Coastguard Workerunnormalized_coords
84*61046927SAndroid Build Coastguard Worker    If set, incoming texture coordinates are used as-is to compute
85*61046927SAndroid Build Coastguard Worker    texel addresses. When set, only a subset of the texture wrap
86*61046927SAndroid Build Coastguard Worker    modes are allowed: PIPE_TEX_WRAP_CLAMP, PIPE_TEX_WRAP_CLAMP_TO_EDGE,
87*61046927SAndroid Build Coastguard Worker    and PIPE_TEX_WRAP_CLAMP_TO_BORDER. If unset, the incoming texture
88*61046927SAndroid Build Coastguard Worker    coordinates are assumed to be normalized to the range [0, 1],
89*61046927SAndroid Build Coastguard Worker    and will be scaled by the texture dimensions to compute texel
90*61046927SAndroid Build Coastguard Worker    addresses.
91*61046927SAndroid Build Coastguard Workerlod_bias
92*61046927SAndroid Build Coastguard Worker    Bias factor which is added to the computed level of detail.
93*61046927SAndroid Build Coastguard Worker    The normal level of detail is computed from the partial derivatives of
94*61046927SAndroid Build Coastguard Worker    the texture coordinates and/or the fragment shader TEX/TXB/TXL
95*61046927SAndroid Build Coastguard Worker    instruction.
96*61046927SAndroid Build Coastguard Workermin_lod
97*61046927SAndroid Build Coastguard Worker    Minimum level of detail, used to clamp LOD after bias.  The LOD values
98*61046927SAndroid Build Coastguard Worker    correspond to mipmap levels where LOD=0 is the level 0 mipmap image.
99*61046927SAndroid Build Coastguard Workermax_lod
100*61046927SAndroid Build Coastguard Worker    Maximum level of detail, used to clamp LOD after bias.
101*61046927SAndroid Build Coastguard Workerborder_color
102*61046927SAndroid Build Coastguard Worker    Color union used for texel coordinates that are outside the [0,width-1],
103*61046927SAndroid Build Coastguard Worker    [0, height-1] or [0, depth-1] ranges. Interpreted according to sampler
104*61046927SAndroid Build Coastguard Worker    view format, unless the driver reports
105*61046927SAndroid Build Coastguard Worker    PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK, in which case special care has to be
106*61046927SAndroid Build Coastguard Worker    taken (see description of the cap).
107*61046927SAndroid Build Coastguard Workermax_anisotropy
108*61046927SAndroid Build Coastguard Worker    Maximum anisotropy ratio to use when sampling from textures.  For example,
109*61046927SAndroid Build Coastguard Worker    if max_anisotropy=4, a region of up to 1 by 4 texels will be sampled.
110*61046927SAndroid Build Coastguard Worker    Set to zero to disable anisotropic filtering.  Any other setting enables
111*61046927SAndroid Build Coastguard Worker    anisotropic filtering, however it's not unexpected some drivers only will
112*61046927SAndroid Build Coastguard Worker    change their filtering with a setting of 2 and higher.
113*61046927SAndroid Build Coastguard Workerseamless_cube_map
114*61046927SAndroid Build Coastguard Worker    If set, the bilinear filter of a cube map may take samples from adjacent
115*61046927SAndroid Build Coastguard Worker    cube map faces when sampled near a texture border to produce a seamless
116*61046927SAndroid Build Coastguard Worker    look.
117