• Home
Name Date Size #Lines LOC

..--

tests/03-May-2024-6,2564,046

READMED03-May-20245.7 KiB11998

meson.buildD03-May-202413.9 KiB476443

nir.cD03-May-202470.2 KiB2,5191,995

nir.hD03-May-2024162.8 KiB5,1892,955

nir_algebraic.pyD03-May-202447.2 KiB1,225907

nir_builder.hD03-May-202452.4 KiB1,7071,363

nir_builder_opcodes_h.pyD03-May-20243.9 KiB120103

nir_builtin_builder.cD03-May-202414.6 KiB402241

nir_builtin_builder.hD03-May-20248.1 KiB279205

nir_clone.cD03-May-202424.5 KiB821555

nir_constant_expressions.hD03-May-20241.6 KiB398

nir_constant_expressions.pyD03-May-202415.6 KiB513474

nir_control_flow.cD03-May-202422.8 KiB766509

nir_control_flow.hD03-May-20246.9 KiB18263

nir_control_flow_private.hD03-May-20241.5 KiB426

nir_conversion_builder.hD03-May-202416.6 KiB483374

nir_convert_ycbcr.cD03-May-20245.6 KiB143107

nir_deref.cD03-May-202444 KiB1,386940

nir_deref.hD03-May-20242.6 KiB7331

nir_divergence_analysis.cD03-May-202432 KiB927747

nir_dominance.cD03-May-20249.3 KiB347218

nir_format_convert.hD03-May-202414.9 KiB445322

nir_from_ssa.cD03-May-202433.2 KiB1,026620

nir_gather_info.cD03-May-202431.3 KiB836669

nir_gather_ssa_types.cD03-May-20248.7 KiB235169

nir_gather_xfb_info.cD03-May-202410.4 KiB288199

nir_gs_count_vertices.cD03-May-20244.2 KiB11860

nir_inline_functions.cD03-May-202410.6 KiB277119

nir_inline_uniforms.cD03-May-20247.1 KiB203123

nir_instr_set.cD03-May-202425 KiB842616

nir_instr_set.hD03-May-20242.4 KiB658

nir_intrinsics.pyD03-May-202447.2 KiB1,044486

nir_intrinsics_c.pyD03-May-20242.5 KiB7565

nir_intrinsics_h.pyD03-May-20242 KiB6147

nir_linking_helpers.cD03-May-202445.7 KiB1,325913

nir_liveness.cD03-May-202411.8 KiB360200

nir_loop_analyze.cD03-May-202441.4 KiB1,294898

nir_loop_analyze.hD03-May-20243.4 KiB10758

nir_lower_alpha_test.cD03-May-20245 KiB12778

nir_lower_alu.cD03-May-202410.1 KiB260165

nir_lower_alu_to_scalar.cD03-May-202411.5 KiB317230

nir_lower_amul.cD03-May-20249.9 KiB326208

nir_lower_array_deref_of_vec.cD03-May-20247.5 KiB198131

nir_lower_atomics_to_ssbo.cD03-May-20248.6 KiB243153

nir_lower_bit_size.cD03-May-202411.2 KiB333238

nir_lower_bitmap.cD03-May-20245 KiB14674

nir_lower_bool_to_bitsize.cD03-May-202414 KiB446322

nir_lower_bool_to_float.cD03-May-20246 KiB190138

nir_lower_bool_to_int32.cD03-May-20245.7 KiB178127

nir_lower_cl_images_to_tex.cD03-May-20245.5 KiB163102

nir_lower_clamp_color_outputs.cD03-May-20243.9 KiB14199

nir_lower_clip.cD03-May-202416.2 KiB515353

nir_lower_clip_cull_distance_arrays.cD03-May-20244.7 KiB15282

nir_lower_clip_disable.cD03-May-20245.5 KiB14683

nir_lower_clip_halfz.cD03-May-20242.9 KiB8047

nir_lower_convert_alu_types.cD03-May-20246.2 KiB207149

nir_lower_discard_to_demote.cD03-May-20242.6 KiB7134

nir_lower_double_ops.cD03-May-202425 KiB769447

nir_lower_drawpixels.cD03-May-202410.3 KiB308223

nir_lower_fb_read.cD03-May-20244.3 KiB12252

nir_lower_flatshade.cD03-May-20241.7 KiB5122

nir_lower_flrp.cD03-May-202421.5 KiB661314

nir_lower_fragcolor.cD03-May-20244 KiB11052

nir_lower_fragcoord_wtrans.cD03-May-20242.6 KiB7635

nir_lower_frexp.cD03-May-20246.9 KiB209119

nir_lower_global_vars_to_local.cD03-May-20243.7 KiB11664

nir_lower_goto_ifs.cD03-May-202433.3 KiB997699

nir_lower_gs_intrinsics.cD03-May-202414.5 KiB400229

nir_lower_idiv.cD03-May-20248.5 KiB273182

nir_lower_indirect_derefs.cD03-May-20248 KiB227155

nir_lower_input_attachments.cD03-May-20247.3 KiB226156

nir_lower_int64.cD03-May-202435.1 KiB1,086824

nir_lower_int_to_float.cD03-May-20246.2 KiB186132

nir_lower_interpolation.cD03-May-20245.7 KiB169107

nir_lower_io.cD03-May-202493.5 KiB2,6912,126

nir_lower_io_arrays_to_elements.cD03-May-202415.3 KiB443300

nir_lower_io_to_scalar.cD03-May-202413.8 KiB417279

nir_lower_io_to_temporaries.cD03-May-202413.5 KiB387236

nir_lower_io_to_vector.cD03-May-202419.3 KiB577418

nir_lower_load_const_to_scalar.cD03-May-20243.4 KiB10253

nir_lower_locals_to_regs.cD03-May-20248.9 KiB291194

nir_lower_mediump_outputs.cD03-May-20242.9 KiB8043

nir_lower_memcpy.cD03-May-20246.9 KiB196136

nir_lower_memory_model.cD03-May-20248.9 KiB273224

nir_lower_multiview.cD03-May-202412.1 KiB349213

nir_lower_non_uniform_access.cD03-May-202412.5 KiB349248

nir_lower_packing.cD03-May-20245.2 KiB167111

nir_lower_passthrough_edgeflags.cD03-May-20244 KiB10964

nir_lower_patch_vertices.cD03-May-20243.9 KiB11057

nir_lower_phis_to_scalar.cD03-May-202411.2 KiB319159

nir_lower_pntc_ytransform.cD03-May-20244.8 KiB13586

nir_lower_point_size.cD03-May-20243.7 KiB11459

nir_lower_point_size_mov.cD03-May-20242.9 KiB8141

nir_lower_regs_to_ssa.cD03-May-20249.8 KiB312195

nir_lower_returns.cD03-May-20249.5 KiB299178

nir_lower_samplers.cD03-May-20245.7 KiB179103

nir_lower_scratch.cD03-May-20246.5 KiB185116

nir_lower_ssbo.cD03-May-20247.1 KiB219146

nir_lower_subgroups.cD03-May-202423.1 KiB629486

nir_lower_system_values.cD03-May-202416.5 KiB426284

nir_lower_tex.cD03-May-202440.7 KiB1,216855

nir_lower_to_source_mods.cD03-May-20247.2 KiB235144

nir_lower_two_sided_color.cD03-May-20247.2 KiB244164

nir_lower_ubo_vec4.cD03-May-20247.9 KiB202101

nir_lower_uniforms_to_ubo.cD03-May-20246.3 KiB16296

nir_lower_var_copies.cD03-May-20245.9 KiB174111

nir_lower_variable_initializers.cD03-May-20244.9 KiB13889

nir_lower_vars_to_ssa.cD03-May-202426.5 KiB822503

nir_lower_vec3_to_vec4.cD03-May-20245.5 KiB170119

nir_lower_vec_to_movs.cD03-May-20249.6 KiB290161

nir_lower_viewport_transform.cD03-May-20244.2 KiB10442

nir_lower_wpos_center.cD03-May-20243.9 KiB11659

nir_lower_wpos_ytransform.cD03-May-202413.3 KiB365227

nir_lower_wrmasks.cD03-May-20247.5 KiB234123

nir_metadata.cD03-May-20243.3 KiB10856

nir_move_vec_src_uses_to_dest.cD03-May-20246.7 KiB214111

nir_normalize_cubemap_coords.cD03-May-20243.8 KiB11762

nir_opcodes.pyD03-May-202442 KiB1,156853

nir_opcodes_c.pyD03-May-20245 KiB13198

nir_opcodes_h.pyD03-May-20241.6 KiB4840

nir_opt_access.cD03-May-202411.5 KiB350243

nir_opt_algebraic.pyD03-May-2024118.9 KiB2,3111,420

nir_opt_barriers.cD03-May-20242.7 KiB8650

nir_opt_combine_stores.cD03-May-202415.8 KiB471325

nir_opt_comparison_pre.cD03-May-202412.7 KiB389204

nir_opt_conditional_discard.cD03-May-20244.7 KiB14992

nir_opt_constant_folding.cD03-May-202411.6 KiB347253

nir_opt_copy_prop_vars.cD03-May-202443.2 KiB1,296915

nir_opt_copy_propagate.cD03-May-20248.1 KiB304216

nir_opt_cse.cD03-May-20242.8 KiB9744

nir_opt_dce.cD03-May-20244.6 KiB169110

nir_opt_dead_cf.cD03-May-202412.7 KiB394207

nir_opt_dead_write_vars.cD03-May-20249 KiB268169

nir_opt_find_array_copies.cD03-May-202422.2 KiB686453

nir_opt_gcm.cD03-May-202422.2 KiB666375

nir_opt_idiv_const.cD03-May-20246.3 KiB203144

nir_opt_if.cD03-May-202448.3 KiB1,483764

nir_opt_intrinsics.cD03-May-20246.3 KiB215145

nir_opt_large_constants.cD03-May-202413.8 KiB412285

nir_opt_load_store_vectorize.cD03-May-202446.8 KiB1,3431,040

nir_opt_loop_unroll.cD03-May-202435 KiB996551

nir_opt_memcpy.cD03-May-20246.7 KiB225153

nir_opt_move.cD03-May-20246 KiB17378

nir_opt_peephole_select.cD03-May-202410.1 KiB330198

nir_opt_rematerialize_compares.cD03-May-20245.9 KiB199125

nir_opt_remove_phis.cD03-May-20245.9 KiB18796

nir_opt_shrink_vectors.cD03-May-20247.8 KiB265176

nir_opt_sink.cD03-May-20248.3 KiB260152

nir_opt_trivial_continues.cD03-May-20244.8 KiB14083

nir_opt_undef.cD03-May-20245.7 KiB193119

nir_opt_uniform_atomics.cD03-May-202411.4 KiB341248

nir_opt_vectorize.cD03-May-202415.5 KiB509341

nir_phi_builder.cD03-May-202411.5 KiB322158

nir_phi_builder.hD03-May-20244.7 KiB12017

nir_print.cD03-May-202448.7 KiB1,6901,391

nir_propagate_invariant.cD03-May-20245.8 KiB206141

nir_range_analysis.cD03-May-202455 KiB1,497994

nir_range_analysis.hD03-May-20241.6 KiB4920

nir_remove_dead_variables.cD03-May-20246.8 KiB220151

nir_repair_ssa.cD03-May-20246.6 KiB211135

nir_schedule.cD03-May-202434.9 KiB1,188763

nir_schedule.hD03-May-20243.1 KiB8527

nir_search.cD03-May-202431.1 KiB971695

nir_search.hD03-May-20246.8 KiB21694

nir_search_helpers.hD03-May-202413.1 KiB430322

nir_serialize.cD03-May-202464.5 KiB2,1431,681

nir_serialize.hD03-May-20241.6 KiB4415

nir_split_per_member_structs.cD03-May-20246.5 KiB202144

nir_split_var_copies.cD03-May-20245.5 KiB14267

nir_split_vars.cD03-May-202458.6 KiB1,7191,253

nir_sweep.cD03-May-20244.8 KiB178103

nir_to_lcssa.cD03-May-202412.9 KiB418276

nir_validate.cD03-May-202456.9 KiB1,6951,244

nir_vla.hD03-May-20242.1 KiB5710

nir_vulkan.hD03-May-2024374 139

nir_worklist.cD03-May-20243.4 KiB13982

nir_worklist.hD03-May-20244.7 KiB16581

nir_xfb_info.hD03-May-20242.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