Debian Codegraph @

docs/nir/tex.rst

raw
1 NIR Texture Instructions
2 ========================
3
4 Even though texture instructions *could* be supported as intrinsics, the vast
5 number of combinations mean that doing so is practically impossible. Instead,
6 NIR has a dedicated texture instruction. There are several texture operations:
7
8 .. c:autoenum:: nir_texop
9 :file: src/compiler/nir/nir.h
10 :members:
11
12 As with other instruction types, there is still an array of sources, except
13 that each source also has a *type* associated with it. There are various
14 source types, each corresponding to a piece of information that the different
15 texture operations require.
16
17 .. c:autoenum:: nir_tex_src_type
18 :members:
19
20 Of particular interest are the texture/sampler deref/index/handle source types.
21 First, note that textures and samplers are specified separately in NIR. While
22 not required for OpenGL, this is required for Vulkan and OpenCL. Some
23 OpenGL [ES] drivers have to deal with hardware that does not have separate
24 samplers and textures. While not recommended, an OpenGL-only driver may assume
25 that the texture and sampler derefs will always point to the same resource, if
26 needed. Note that this pretty well paints your compiler into a corner and
27 makes any future port to Vulkan or OpenCL harder, so such assumptions should
28 really only be made if targeting OpenGL ES 2.0 era hardware.
29
30 Also, like a lot of other resources, there are multiple ways to represent a
31 texture in NIR. It can be referenced by a variable dereference, an index, or a
32 bindless handle. When using an index or a bindless handle, the texture type
33 information is generally not available. To handle this, various information
34 from the type is redundantly stored in the :c:struct:`nir_tex_instr` itself.
35
36 .. c:autostruct:: nir_tex_instr
37 :members:
38
39 .. c:autostruct:: nir_tex_src
40 :members:
41
42 Texture instruction helpers
43 ---------------------------
44
45 There are a number of helper functions for working with NIR texture
46 instructions. They are documented here in no particular order.
47
48 .. c:autofunction:: nir_tex_instr_create
49
50 .. c:autofunction:: nir_tex_instr_need_sampler
51
52 .. c:autofunction:: nir_tex_instr_result_size
53
54 .. c:autofunction:: nir_tex_instr_dest_size
55
56 .. c:autofunction:: nir_tex_instr_is_query
57
58 .. c:autofunction:: nir_tex_instr_has_implicit_derivative
59
60 .. c:autofunction:: nir_tex_instr_src_type
61
62 .. c:autofunction:: nir_tex_instr_src_size
63
64 .. c:autofunction:: nir_tex_instr_src_index
65
66 .. c:autofunction:: nir_tex_instr_add_src
67
68 .. c:autofunction:: nir_tex_instr_remove_src
69
70 Texture instruction lowering
71 ----------------------------
72
73 Because most hardware only supports some subset of all possible GLSL/SPIR-V
74 texture operations, NIR provides a quite powerful lowering pass which is able
75 to implement more complex texture operations in terms of simpler ones.
76
77 .. c:autofunction:: nir_lower_tex
78
79 .. c:autostruct:: nir_lower_tex_options
80 :members:
81
82 .. c:autoenum:: nir_lower_tex_packing
83 :members: