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

..--

tests/23-Nov-2023-6,2564,046

READMED23-Nov-20235.7 KiB11998

meson.buildD23-Nov-202313.9 KiB476443

nir.cD23-Nov-202370.2 KiB2,5191,995

nir.hD23-Nov-2023162.8 KiB5,1892,955

nir_algebraic.pyD23-Nov-202347.2 KiB1,225907

nir_builder.hD23-Nov-202352.4 KiB1,7071,363

nir_builder_opcodes_h.pyD23-Nov-20233.9 KiB120103

nir_builtin_builder.cD23-Nov-202314.6 KiB402241

nir_builtin_builder.hD23-Nov-20238.1 KiB279205

nir_clone.cD23-Nov-202324.5 KiB821555

nir_constant_expressions.hD23-Nov-20231.6 KiB398

nir_constant_expressions.pyD23-Nov-202315.6 KiB513474

nir_control_flow.cD23-Nov-202322.8 KiB766509

nir_control_flow.hD23-Nov-20236.9 KiB18263

nir_control_flow_private.hD23-Nov-20231.5 KiB426

nir_conversion_builder.hD23-Nov-202316.6 KiB483374

nir_convert_ycbcr.cD23-Nov-20235.6 KiB143107

nir_deref.cD23-Nov-202344 KiB1,386940

nir_deref.hD23-Nov-20232.6 KiB7331

nir_divergence_analysis.cD23-Nov-202332 KiB927747

nir_dominance.cD23-Nov-20239.3 KiB347218

nir_format_convert.hD23-Nov-202314.9 KiB445322

nir_from_ssa.cD23-Nov-202333.2 KiB1,026620

nir_gather_info.cD23-Nov-202331.3 KiB836669

nir_gather_ssa_types.cD23-Nov-20238.7 KiB235169

nir_gather_xfb_info.cD23-Nov-202310.4 KiB288199

nir_gs_count_vertices.cD23-Nov-20234.2 KiB11860

nir_inline_functions.cD23-Nov-202310.6 KiB277119

nir_inline_uniforms.cD23-Nov-20237.1 KiB203123

nir_instr_set.cD23-Nov-202325 KiB842616

nir_instr_set.hD23-Nov-20232.4 KiB658

nir_intrinsics.pyD23-Nov-202347.2 KiB1,044486

nir_intrinsics_c.pyD23-Nov-20232.5 KiB7565

nir_intrinsics_h.pyD23-Nov-20232 KiB6147

nir_linking_helpers.cD23-Nov-202345.7 KiB1,325913

nir_liveness.cD23-Nov-202311.8 KiB360200

nir_loop_analyze.cD23-Nov-202341.4 KiB1,294898

nir_loop_analyze.hD23-Nov-20233.4 KiB10758

nir_lower_alpha_test.cD23-Nov-20235 KiB12778

nir_lower_alu.cD23-Nov-202310.1 KiB260165

nir_lower_alu_to_scalar.cD23-Nov-202311.5 KiB317230

nir_lower_amul.cD23-Nov-20239.9 KiB326208

nir_lower_array_deref_of_vec.cD23-Nov-20237.5 KiB198131

nir_lower_atomics_to_ssbo.cD23-Nov-20238.6 KiB243153

nir_lower_bit_size.cD23-Nov-202311.2 KiB333238

nir_lower_bitmap.cD23-Nov-20235 KiB14674

nir_lower_bool_to_bitsize.cD23-Nov-202314 KiB446322

nir_lower_bool_to_float.cD23-Nov-20236 KiB190138

nir_lower_bool_to_int32.cD23-Nov-20235.7 KiB178127

nir_lower_cl_images_to_tex.cD23-Nov-20235.5 KiB163102

nir_lower_clamp_color_outputs.cD23-Nov-20233.9 KiB14199

nir_lower_clip.cD23-Nov-202316.2 KiB515353

nir_lower_clip_cull_distance_arrays.cD23-Nov-20234.7 KiB15282

nir_lower_clip_disable.cD23-Nov-20235.5 KiB14683

nir_lower_clip_halfz.cD23-Nov-20232.9 KiB8047

nir_lower_convert_alu_types.cD23-Nov-20236.2 KiB207149

nir_lower_discard_to_demote.cD23-Nov-20232.6 KiB7134

nir_lower_double_ops.cD23-Nov-202325 KiB769447

nir_lower_drawpixels.cD23-Nov-202310.3 KiB308223

nir_lower_fb_read.cD23-Nov-20234.3 KiB12252

nir_lower_flatshade.cD23-Nov-20231.7 KiB5122

nir_lower_flrp.cD23-Nov-202321.5 KiB661314

nir_lower_fragcolor.cD23-Nov-20234 KiB11052

nir_lower_fragcoord_wtrans.cD23-Nov-20232.6 KiB7635

nir_lower_frexp.cD23-Nov-20236.9 KiB209119

nir_lower_global_vars_to_local.cD23-Nov-20233.7 KiB11664

nir_lower_goto_ifs.cD23-Nov-202333.3 KiB997699

nir_lower_gs_intrinsics.cD23-Nov-202314.5 KiB400229

nir_lower_idiv.cD23-Nov-20238.5 KiB273182

nir_lower_indirect_derefs.cD23-Nov-20238 KiB227155

nir_lower_input_attachments.cD23-Nov-20237.3 KiB226156

nir_lower_int64.cD23-Nov-202335.1 KiB1,086824

nir_lower_int_to_float.cD23-Nov-20236.2 KiB186132

nir_lower_interpolation.cD23-Nov-20235.7 KiB169107

nir_lower_io.cD23-Nov-202393.5 KiB2,6912,126

nir_lower_io_arrays_to_elements.cD23-Nov-202315.3 KiB443300

nir_lower_io_to_scalar.cD23-Nov-202313.8 KiB417279

nir_lower_io_to_temporaries.cD23-Nov-202313.5 KiB387236

nir_lower_io_to_vector.cD23-Nov-202319.3 KiB577418

nir_lower_load_const_to_scalar.cD23-Nov-20233.4 KiB10253

nir_lower_locals_to_regs.cD23-Nov-20238.9 KiB291194

nir_lower_mediump_outputs.cD23-Nov-20232.9 KiB8043

nir_lower_memcpy.cD23-Nov-20236.9 KiB196136

nir_lower_memory_model.cD23-Nov-20238.9 KiB273224

nir_lower_multiview.cD23-Nov-202312.1 KiB349213

nir_lower_non_uniform_access.cD23-Nov-202312.5 KiB349248

nir_lower_packing.cD23-Nov-20235.2 KiB167111

nir_lower_passthrough_edgeflags.cD23-Nov-20234 KiB10964

nir_lower_patch_vertices.cD23-Nov-20233.9 KiB11057

nir_lower_phis_to_scalar.cD23-Nov-202311.2 KiB319159

nir_lower_pntc_ytransform.cD23-Nov-20234.8 KiB13586

nir_lower_point_size.cD23-Nov-20233.7 KiB11459

nir_lower_point_size_mov.cD23-Nov-20232.9 KiB8141

nir_lower_regs_to_ssa.cD23-Nov-20239.8 KiB312195

nir_lower_returns.cD23-Nov-20239.5 KiB299178

nir_lower_samplers.cD23-Nov-20235.7 KiB179103

nir_lower_scratch.cD23-Nov-20236.5 KiB185116

nir_lower_ssbo.cD23-Nov-20237.1 KiB219146

nir_lower_subgroups.cD23-Nov-202323.1 KiB629486

nir_lower_system_values.cD23-Nov-202316.5 KiB426284

nir_lower_tex.cD23-Nov-202340.7 KiB1,216855

nir_lower_to_source_mods.cD23-Nov-20237.2 KiB235144

nir_lower_two_sided_color.cD23-Nov-20237.2 KiB244164

nir_lower_ubo_vec4.cD23-Nov-20237.9 KiB202101

nir_lower_uniforms_to_ubo.cD23-Nov-20236.3 KiB16296

nir_lower_var_copies.cD23-Nov-20235.9 KiB174111

nir_lower_variable_initializers.cD23-Nov-20234.9 KiB13889

nir_lower_vars_to_ssa.cD23-Nov-202326.5 KiB822503

nir_lower_vec3_to_vec4.cD23-Nov-20235.5 KiB170119

nir_lower_vec_to_movs.cD23-Nov-20239.6 KiB290161

nir_lower_viewport_transform.cD23-Nov-20234.2 KiB10442

nir_lower_wpos_center.cD23-Nov-20233.9 KiB11659

nir_lower_wpos_ytransform.cD23-Nov-202313.3 KiB365227

nir_lower_wrmasks.cD23-Nov-20237.5 KiB234123

nir_metadata.cD23-Nov-20233.3 KiB10856

nir_move_vec_src_uses_to_dest.cD23-Nov-20236.7 KiB214111

nir_normalize_cubemap_coords.cD23-Nov-20233.8 KiB11762

nir_opcodes.pyD23-Nov-202342 KiB1,156853

nir_opcodes_c.pyD23-Nov-20235 KiB13198

nir_opcodes_h.pyD23-Nov-20231.6 KiB4840

nir_opt_access.cD23-Nov-202311.5 KiB350243

nir_opt_algebraic.pyD23-Nov-2023118.9 KiB2,3111,420

nir_opt_barriers.cD23-Nov-20232.7 KiB8650

nir_opt_combine_stores.cD23-Nov-202315.8 KiB471325

nir_opt_comparison_pre.cD23-Nov-202312.7 KiB389204

nir_opt_conditional_discard.cD23-Nov-20234.7 KiB14992

nir_opt_constant_folding.cD23-Nov-202311.6 KiB347253

nir_opt_copy_prop_vars.cD23-Nov-202343.2 KiB1,296915

nir_opt_copy_propagate.cD23-Nov-20238.1 KiB304216

nir_opt_cse.cD23-Nov-20232.8 KiB9744

nir_opt_dce.cD23-Nov-20234.6 KiB169110

nir_opt_dead_cf.cD23-Nov-202312.7 KiB394207

nir_opt_dead_write_vars.cD23-Nov-20239 KiB268169

nir_opt_find_array_copies.cD23-Nov-202322.2 KiB686453

nir_opt_gcm.cD23-Nov-202322.2 KiB666375

nir_opt_idiv_const.cD23-Nov-20236.3 KiB203144

nir_opt_if.cD23-Nov-202348.3 KiB1,483764

nir_opt_intrinsics.cD23-Nov-20236.3 KiB215145

nir_opt_large_constants.cD23-Nov-202313.8 KiB412285

nir_opt_load_store_vectorize.cD23-Nov-202346.8 KiB1,3431,040

nir_opt_loop_unroll.cD23-Nov-202335 KiB996551

nir_opt_memcpy.cD23-Nov-20236.7 KiB225153

nir_opt_move.cD23-Nov-20236 KiB17378

nir_opt_peephole_select.cD23-Nov-202310.1 KiB330198

nir_opt_rematerialize_compares.cD23-Nov-20235.9 KiB199125

nir_opt_remove_phis.cD23-Nov-20235.9 KiB18796

nir_opt_shrink_vectors.cD23-Nov-20237.8 KiB265176

nir_opt_sink.cD23-Nov-20238.3 KiB260152

nir_opt_trivial_continues.cD23-Nov-20234.8 KiB14083

nir_opt_undef.cD23-Nov-20235.7 KiB193119

nir_opt_uniform_atomics.cD23-Nov-202311.4 KiB341248

nir_opt_vectorize.cD23-Nov-202315.5 KiB509341

nir_phi_builder.cD23-Nov-202311.5 KiB322158

nir_phi_builder.hD23-Nov-20234.7 KiB12017

nir_print.cD23-Nov-202348.7 KiB1,6901,391

nir_propagate_invariant.cD23-Nov-20235.8 KiB206141

nir_range_analysis.cD23-Nov-202355 KiB1,497994

nir_range_analysis.hD23-Nov-20231.6 KiB4920

nir_remove_dead_variables.cD23-Nov-20236.8 KiB220151

nir_repair_ssa.cD23-Nov-20236.6 KiB211135

nir_schedule.cD23-Nov-202334.9 KiB1,188763

nir_schedule.hD23-Nov-20233.1 KiB8527

nir_search.cD23-Nov-202331.1 KiB971695

nir_search.hD23-Nov-20236.8 KiB21694

nir_search_helpers.hD23-Nov-202313.1 KiB430322

nir_serialize.cD23-Nov-202364.5 KiB2,1431,681

nir_serialize.hD23-Nov-20231.6 KiB4415

nir_split_per_member_structs.cD23-Nov-20236.5 KiB202144

nir_split_var_copies.cD23-Nov-20235.5 KiB14267

nir_split_vars.cD23-Nov-202358.6 KiB1,7191,253

nir_sweep.cD23-Nov-20234.8 KiB178103

nir_to_lcssa.cD23-Nov-202312.9 KiB418276

nir_validate.cD23-Nov-202356.9 KiB1,6951,244

nir_vla.hD23-Nov-20232.1 KiB5710

nir_vulkan.hD23-Nov-2023374 139

nir_worklist.cD23-Nov-20233.4 KiB13982

nir_worklist.hD23-Nov-20234.7 KiB16581

nir_xfb_info.hD23-Nov-20232.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