• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..09-Feb-2022-

tests/H09-Feb-2022-6,9744,501

READMEH A D09-Feb-20225.7 KiB11998

meson.buildH A D09-Feb-202215.9 KiB538501

nir.cH A D09-Feb-202279 KiB2,8112,184

nir.hH A D09-Feb-2022179 KiB5,6863,173

nir_algebraic.pyH A D09-Feb-202246.7 KiB1,206896

nir_builder.hH A D09-Feb-202257 KiB1,8851,485

nir_builder_opcodes_h.pyH A D09-Feb-20225.4 KiB159141

nir_builtin_builder.cH A D09-Feb-202214.8 KiB415250

nir_builtin_builder.hH A D09-Feb-20227.6 KiB258187

nir_clone.cH A D09-Feb-202224.3 KiB816557

nir_constant_expressions.hH A D09-Feb-20221.6 KiB398

nir_constant_expressions.pyH A D09-Feb-202215.9 KiB519482

nir_control_flow.cH A D09-Feb-202224.4 KiB815549

nir_control_flow.hH A D09-Feb-20226.9 KiB18263

nir_control_flow_private.hH A D09-Feb-20221.5 KiB426

nir_conversion_builder.hH A D09-Feb-202218.1 KiB524396

nir_convert_ycbcr.cH A D09-Feb-20225.6 KiB143107

nir_deref.cH A D09-Feb-202245.4 KiB1,425969

nir_deref.hH A D09-Feb-20223 KiB8339

nir_divergence_analysis.cH A D09-Feb-202236 KiB1,019833

nir_dominance.cH A D09-Feb-20229.3 KiB347218

nir_format_convert.hH A D09-Feb-202215.7 KiB467342

nir_from_ssa.cH A D09-Feb-202237.3 KiB1,116647

nir_gather_info.cH A D09-Feb-202235.5 KiB939776

nir_gather_ssa_types.cH A D09-Feb-20228.6 KiB235169

nir_gather_xfb_info.cH A D09-Feb-202210.4 KiB288199

nir_gs_count_vertices.cH A D09-Feb-20224.2 KiB11860

nir_inline_functions.cH A D09-Feb-202210.9 KiB288129

nir_inline_helpers.hH A D09-Feb-20224.7 KiB165145

nir_inline_uniforms.cH A D09-Feb-202215.6 KiB428240

nir_instr_set.cH A D09-Feb-202225.5 KiB854624

nir_instr_set.hH A D09-Feb-20222.8 KiB7110

nir_intrinsics.pyH A D09-Feb-202258.5 KiB1,347593

nir_intrinsics_c.pyH A D09-Feb-20222.9 KiB8978

nir_intrinsics_h.pyH A D09-Feb-20222.2 KiB7054

nir_intrinsics_indices_h.pyH A D09-Feb-20223.1 KiB9580

nir_linking_helpers.cH A D09-Feb-202256.3 KiB1,6431,132

nir_liveness.cH A D09-Feb-202213.7 KiB416235

nir_loop_analyze.cH A D09-Feb-202244.7 KiB1,384968

nir_loop_analyze.hH A D09-Feb-20223.5 KiB10858

nir_lower_alpha_test.cH A D09-Feb-20224.7 KiB12273

nir_lower_alu.cH A D09-Feb-202210.1 KiB260165

nir_lower_alu_to_scalar.cH A D09-Feb-202213 KiB369272

nir_lower_amul.cH A D09-Feb-202210 KiB331212

nir_lower_array_deref_of_vec.cH A D09-Feb-20227.5 KiB198131

nir_lower_atomics_to_ssbo.cH A D09-Feb-20228.6 KiB244154

nir_lower_bit_size.cH A D09-Feb-202212.7 KiB376267

nir_lower_bitmap.cH A D09-Feb-20224.8 KiB14371

nir_lower_blend.cH A D09-Feb-202211.7 KiB393281

nir_lower_blend.hH A D09-Feb-20222.1 KiB7026

nir_lower_bool_to_bitsize.cH A D09-Feb-202214.4 KiB463338

nir_lower_bool_to_float.cH A D09-Feb-20226.4 KiB206152

nir_lower_bool_to_int32.cH A D09-Feb-20226.1 KiB196142

nir_lower_clamp_color_outputs.cH A D09-Feb-20223.9 KiB14199

nir_lower_clip.cH A D09-Feb-202215.5 KiB497340

nir_lower_clip_cull_distance_arrays.cH A D09-Feb-20224.7 KiB15282

nir_lower_clip_disable.cH A D09-Feb-20225.5 KiB14784

nir_lower_clip_halfz.cH A D09-Feb-20222.9 KiB8047

nir_lower_convert_alu_types.cH A D09-Feb-20226.3 KiB210152

nir_lower_discard_or_demote.cH A D09-Feb-20227.8 KiB202133

nir_lower_double_ops.cH A D09-Feb-202225 KiB769447

nir_lower_drawpixels.cH A D09-Feb-202210.2 KiB308223

nir_lower_fb_read.cH A D09-Feb-20224.3 KiB12252

nir_lower_flatshade.cH A D09-Feb-20221.7 KiB5122

nir_lower_flrp.cH A D09-Feb-202221.4 KiB661314

nir_lower_fp16_conv.cH A D09-Feb-20229.6 KiB238161

nir_lower_fragcolor.cH A D09-Feb-20224.2 KiB10849

nir_lower_fragcoord_wtrans.cH A D09-Feb-20222.7 KiB7937

nir_lower_frexp.cH A D09-Feb-20226.9 KiB209119

nir_lower_global_vars_to_local.cH A D09-Feb-20223.7 KiB11664

nir_lower_goto_ifs.cH A D09-Feb-202233.3 KiB997699

nir_lower_gs_intrinsics.cH A D09-Feb-202215 KiB429242

nir_lower_idiv.cH A D09-Feb-20229.4 KiB291194

nir_lower_image.cH A D09-Feb-20223.4 KiB9655

nir_lower_indirect_derefs.cH A D09-Feb-20228.8 KiB253170

nir_lower_input_attachments.cH A D09-Feb-20227.5 KiB226155

nir_lower_int64.cH A D09-Feb-202242.7 KiB1,3121,016

nir_lower_int_to_float.cH A D09-Feb-20226.3 KiB190135

nir_lower_interpolation.cH A D09-Feb-20225.3 KiB16199

nir_lower_io.cH A D09-Feb-202296 KiB2,7342,162

nir_lower_io_arrays_to_elements.cH A D09-Feb-202215.2 KiB441298

nir_lower_io_to_scalar.cH A D09-Feb-202213.6 KiB415277

nir_lower_io_to_temporaries.cH A D09-Feb-202213.6 KiB389238

nir_lower_io_to_vector.cH A D09-Feb-202222.8 KiB690504

nir_lower_is_helper_invocation.cH A D09-Feb-20224.4 KiB12773

nir_lower_load_const_to_scalar.cH A D09-Feb-20223.4 KiB10253

nir_lower_locals_to_regs.cH A D09-Feb-20228.9 KiB291194

nir_lower_mediump.cH A D09-Feb-202221.8 KiB648462

nir_lower_memcpy.cH A D09-Feb-20226.9 KiB196136

nir_lower_memory_model.cH A D09-Feb-20229.5 KiB289240

nir_lower_multiview.cH A D09-Feb-202212.2 KiB352216

nir_lower_non_uniform_access.cH A D09-Feb-202212.7 KiB373268

nir_lower_packing.cH A D09-Feb-20225 KiB157105

nir_lower_passthrough_edgeflags.cH A D09-Feb-20223.7 KiB10558

nir_lower_patch_vertices.cH A D09-Feb-20223.9 KiB11057

nir_lower_phis_to_scalar.cH A D09-Feb-202211.3 KiB326164

nir_lower_pntc_ytransform.cH A D09-Feb-20224.9 KiB13788

nir_lower_point_size.cH A D09-Feb-20223.7 KiB11459

nir_lower_point_size_mov.cH A D09-Feb-20222.9 KiB8242

nir_lower_printf.cH A D09-Feb-20225.9 KiB14488

nir_lower_readonly_images_to_tex.cH A D09-Feb-20227.4 KiB215144

nir_lower_regs_to_ssa.cH A D09-Feb-20229.8 KiB312195

nir_lower_returns.cH A D09-Feb-202210 KiB309182

nir_lower_samplers.cH A D09-Feb-20225.7 KiB179103

nir_lower_scratch.cH A D09-Feb-20227.7 KiB235153

nir_lower_shader_calls.cH A D09-Feb-202240.1 KiB1,130659

nir_lower_ssbo.cH A D09-Feb-20227 KiB219146

nir_lower_subgroups.cH A D09-Feb-202228.7 KiB766544

nir_lower_system_values.cH A D09-Feb-202220.5 KiB526334

nir_lower_sysvals_to_varyings.cH A D09-Feb-20222.5 KiB7330

nir_lower_tex.cH A D09-Feb-202251.5 KiB1,5141,099

nir_lower_texcoord_replace.cH A D09-Feb-20225.5 KiB154100

nir_lower_to_source_mods.cH A D09-Feb-20227.1 KiB234143

nir_lower_two_sided_color.cH A D09-Feb-20226.9 KiB236158

nir_lower_ubo_vec4.cH A D09-Feb-20227.6 KiB19494

nir_lower_undef_to_zero.cH A D09-Feb-20222.5 KiB6420

nir_lower_uniforms_to_ubo.cH A D09-Feb-20226.9 KiB170101

nir_lower_var_copies.cH A D09-Feb-20225.9 KiB174111

nir_lower_variable_initializers.cH A D09-Feb-20227.1 KiB201131

nir_lower_vars_to_ssa.cH A D09-Feb-202226.4 KiB822503

nir_lower_vec3_to_vec4.cH A D09-Feb-20225.5 KiB170119

nir_lower_vec_to_movs.cH A D09-Feb-202210.4 KiB319179

nir_lower_viewport_transform.cH A D09-Feb-20224.3 KiB10644

nir_lower_wpos_center.cH A D09-Feb-20223.9 KiB11659

nir_lower_wpos_ytransform.cH A D09-Feb-202213.3 KiB365227

nir_lower_wrmasks.cH A D09-Feb-20227.5 KiB234123

nir_metadata.cH A D09-Feb-20223.3 KiB10856

nir_move_vec_src_uses_to_dest.cH A D09-Feb-20226.7 KiB214111

nir_normalize_cubemap_coords.cH A D09-Feb-20223.8 KiB11762

nir_opcodes.pyH A D09-Feb-202255.1 KiB1,4831,066

nir_opcodes_c.pyH A D09-Feb-20224.9 KiB12997

nir_opcodes_h.pyH A D09-Feb-20221.6 KiB4639

nir_opt_access.cH A D09-Feb-202213 KiB370279

nir_opt_algebraic.pyH A D09-Feb-2022145.9 KiB2,7621,711

nir_opt_barriers.cH A D09-Feb-20222.7 KiB8650

nir_opt_combine_stores.cH A D09-Feb-202215.9 KiB473327

nir_opt_comparison_pre.cH A D09-Feb-202212.5 KiB385201

nir_opt_conditional_discard.cH A D09-Feb-20224.7 KiB14992

nir_opt_constant_folding.cH A D09-Feb-202211.5 KiB346253

nir_opt_copy_prop_vars.cH A D09-Feb-202245.2 KiB1,332942

nir_opt_copy_propagate.cH A D09-Feb-20225.4 KiB198126

nir_opt_cse.cH A D09-Feb-20222.3 KiB8036

nir_opt_dce.cH A D09-Feb-20227.9 KiB252181

nir_opt_dead_cf.cH A D09-Feb-202214.2 KiB431231

nir_opt_dead_write_vars.cH A D09-Feb-20229.7 KiB286183

nir_opt_find_array_copies.cH A D09-Feb-202222.2 KiB686453

nir_opt_fragdepth.cH A D09-Feb-20223.8 KiB11259

nir_opt_gcm.cH A D09-Feb-202227.2 KiB806491

nir_opt_idiv_const.cH A D09-Feb-20228.7 KiB262200

nir_opt_if.cH A D09-Feb-202251.4 KiB1,560807

nir_opt_intrinsics.cH A D09-Feb-20227 KiB231153

nir_opt_large_constants.cH A D09-Feb-202213.6 KiB409282

nir_opt_load_store_vectorize.cH A D09-Feb-202249.3 KiB1,4271,097

nir_opt_loop_unroll.cH A D09-Feb-202238.4 KiB1,093614

nir_opt_memcpy.cH A D09-Feb-20226.7 KiB225153

nir_opt_move.cH A D09-Feb-20226 KiB17378

nir_opt_move_discards_to_top.cH A D09-Feb-20228.3 KiB253155

nir_opt_offsets.cH A D09-Feb-20225.2 KiB161101

nir_opt_peephole_select.cH A D09-Feb-202216.7 KiB524325

nir_opt_phi_precision.cH A D09-Feb-202214.1 KiB493262

nir_opt_rematerialize_compares.cH A D09-Feb-20225.9 KiB199125

nir_opt_remove_phis.cH A D09-Feb-20225.8 KiB18796

nir_opt_shrink_vectors.cH A D09-Feb-20229.8 KiB323218

nir_opt_sink.cH A D09-Feb-20227.6 KiB238144

nir_opt_trivial_continues.cH A D09-Feb-20224.8 KiB14083

nir_opt_undef.cH A D09-Feb-20225.7 KiB193119

nir_opt_uniform_atomics.cH A D09-Feb-202210.9 KiB329237

nir_opt_vectorize.cH A D09-Feb-202214.1 KiB447305

nir_phi_builder.cH A D09-Feb-202210.9 KiB302144

nir_phi_builder.hH A D09-Feb-20224.7 KiB12017

nir_print.cH A D09-Feb-202248.9 KiB1,7141,411

nir_propagate_invariant.cH A D09-Feb-20226.7 KiB233163

nir_range_analysis.cH A D09-Feb-202268.3 KiB1,8701,257

nir_range_analysis.hH A D09-Feb-20221.9 KiB6429

nir_remove_dead_variables.cH A D09-Feb-20227 KiB229154

nir_repair_ssa.cH A D09-Feb-20226.6 KiB211135

nir_schedule.cH A D09-Feb-202234.9 KiB1,188763

nir_schedule.hH A D09-Feb-20223.1 KiB8527

nir_search.cH A D09-Feb-202231.3 KiB972697

nir_search.hH A D09-Feb-20226.8 KiB21694

nir_search_helpers.hH A D09-Feb-202217.3 KiB550417

nir_serialize.cH A D09-Feb-202264.3 KiB2,1351,674

nir_serialize.hH A D09-Feb-20221.6 KiB4415

nir_split_per_member_structs.cH A D09-Feb-20226.5 KiB202144

nir_split_var_copies.cH A D09-Feb-20225.5 KiB14267

nir_split_vars.cH A D09-Feb-202258.5 KiB1,7191,254

nir_sweep.cH A D09-Feb-20224.8 KiB17096

nir_to_lcssa.cH A D09-Feb-202213.1 KiB423282

nir_validate.cH A D09-Feb-202260.9 KiB1,8101,338

nir_vla.hH A D09-Feb-20222.1 KiB5710

nir_vulkan.hH A D09-Feb-2022374 139

nir_worklist.cH A D09-Feb-20223.8 KiB15695

nir_worklist.hH A D09-Feb-20224.8 KiB16782

nir_xfb_info.hH A D09-Feb-20222.4 KiB8145

README

1New IR, or NIR, is an IR for Mesa intended to sit below GLSL IR and Mesa IR.
2Its design inherits from the various IRs that Mesa has used in the past, as
3well as Direct3D assembly, and it includes a few new ideas as well. It is a
4flat (in terms of using instructions instead of expressions), typeless IR,
5similar to TGSI and Mesa IR.  It also supports SSA (although it doesn't require
6it).
7
8Variables
9=========
10
11NIR includes support for source-level GLSL variables through a structure mostly
12copied from GLSL IR. These will be used for linking and conversion from GLSL IR
13(and later, from an AST), but for the most part, they will be lowered to
14registers (see below) and loads/stores.
15
16Registers
17=========
18
19Registers are light-weight; they consist of a structure that only contains its
20size, its index for liveness analysis, and an optional name for debugging. In
21addition, registers can be local to a function or global to the entire shader;
22the latter will be used in ARB_shader_subroutine for passing parameters and
23getting return values from subroutines. Registers can also be an array, in which
24case they can be accessed indirectly. Each ALU instruction (add, subtract, etc.)
25works directly with registers or SSA values (see below).
26
27SSA
28========
29
30Everywhere a register can be loaded/stored, an SSA value can be used instead.
31The only exception is that arrays/indirect addressing are not supported with
32SSA; although research has been done on extensions of SSA to arrays before, it's
33usually for the purpose of parallelization (which we're not interested in), and
34adds some overhead in the form of adding copies or extra arrays (which is much
35more expensive than introducing copies between non-array registers). SSA uses
36point directly to their corresponding definition, which in turn points to the
37instruction it is part of. This creates an implicit use-def chain and avoids the
38need for an external structure for each SSA register.
39
40Functions
41=========
42
43Support for function calls is mostly similar to GLSL IR. Each shader contains a
44list of functions, and each function has a list of overloads. Each overload
45contains a list of parameters, and may contain an implementation which specifies
46the variables that correspond to the parameters and return value. Inlining a
47function, assuming it has a single return point, is as simple as copying its
48instructions, registers, and local variables into the target function and then
49inserting copies to and from the new parameters as appropriate. After functions
50are inlined and any non-subroutine functions are deleted, parameters and return
51variables will be converted to global variables and then global registers. We
52don't do this lowering earlier (i.e. the fortranizer idea) for a few reasons:
53
54- If we want to do optimizations before link time, we need to have the function
55signature available during link-time.
56
57- If we do any inlining before link time, then we might wind up with the
58inlined function and the non-inlined function using the same global
59variables/registers which would preclude optimization.
60
61Intrinsics
62=========
63
64Any operation (other than function calls and textures) which touches a variable
65or is not referentially transparent is represented by an intrinsic. Intrinsics
66are similar to the idea of a "builtin function," i.e. a function declaration
67whose implementation is provided by the backend, except they are more powerful
68in the following ways:
69
70- They can also load and store registers when appropriate, which limits the
71number of variables needed in later stages of the IR while obviating the need
72for a separate load/store variable instruction.
73
74- Intrinsics can be marked as side-effect free, which permits them to be
75treated like any other instruction when it comes to optimizations. This allows
76load intrinsics to be represented as intrinsics while still being optimized
77away by dead code elimination, common subexpression elimination, etc.
78
79Intrinsics are used for:
80
81- Atomic operations
82- Memory barriers
83- Subroutine calls
84- Geometry shader emitVertex and endPrimitive
85- Loading and storing variables (before lowering)
86- Loading and storing uniforms, shader inputs and outputs, etc (after lowering)
87- Copying variables (cases where in GLSL the destination is a structure or
88array)
89- The kitchen sink
90- ...
91
92Textures
93=========
94
95Unfortunately, there are far too many texture operations to represent each one
96of them with an intrinsic, so there's a special texture instruction similar to
97the GLSL IR one. The biggest difference is that, while the texture instruction
98has a sampler dereference field used just like in GLSL IR, this gets lowered to
99a texture unit index (with a possible indirect offset) while the type
100information of the original sampler is kept around for backends. Also, all the
101non-constant sources are stored in a single array to make it easier for
102optimization passes to iterate over all the sources.
103
104Control Flow
105=========
106
107Like in GLSL IR, control flow consists of a tree of "control flow nodes", which
108include if statements and loops, and jump instructions (break, continue, and
109return). Unlike GLSL IR, though, the leaves of the tree aren't statements but
110basic blocks. Each basic block also keeps track of its successors and
111predecessors, and function implementations keep track of the beginning basic
112block (the first basic block of the function) and the ending basic block (a fake
113basic block that every return statement points to). Together, these elements
114make up the control flow graph, in this case a redundant piece of information on
115top of the control flow tree that will be used by almost all the optimizations.
116There are helper functions to add and remove control flow nodes that also update
117the control flow graph, and so usually it doesn't need to be touched by passes
118that modify control flow nodes.
119