1NIR Texture Instructions 2======================== 3 4Even though texture instructions *could* be supported as intrinsics, the vast 5number of combinations mean that doing so is practically impossible. Instead, 6NIR 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 12As with other instruction types, there is still an array of sources, except 13that each source also has a *type* associated with it. There are various 14source types, each corresponding to a piece of information that the different 15texture operations require. 16 17.. c:autoenum:: nir_tex_src_type 18 :members: 19 20Of particular interest are the texture/sampler deref/index/handle source types. 21First, note that textures and samplers are specified separately in NIR. While 22not required for OpenGL, this is required for Vulkan and OpenCL. Some 23OpenGL [ES] drivers have to deal with hardware that does not have separate 24samplers and textures. While not recommended, an OpenGL-only driver may assume 25that the texture and sampler derefs will always point to the same resource, if 26needed. Note that this pretty well paints your compiler into a corner and 27makes any future port to Vulkan or OpenCL harder, so such assumptions should 28really only be made if targeting OpenGL ES 2.0 era hardware. 29 30Also, like a lot of other resources, there are multiple ways to represent a 31texture in NIR. It can be referenced by a variable dereference, an index, or a 32bindless handle. When using an index or a bindless handle, the texture type 33information is generally not available. To handle this, various information 34from 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 42Texture instruction helpers 43--------------------------- 44 45There are a number of helper functions for working with NIR texture 46instructions. 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 70Texture instruction lowering 71---------------------------- 72 73Because most hardware only supports some subset of all possible GLSL/SPIR-V 74texture operations, NIR provides a quite powerful lowering pass which is able 75to 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: 84