Name Date Size #Lines LOC

..--

tests/H25-Apr-2025-14,2149,277

.clang-formatH A D25-Apr-2025155 75

Android.bpH A D25-Apr-20258.8 KiB346325

READMEH A D25-Apr-20255.7 KiB11998

meson.buildH A D25-Apr-202511.4 KiB402381

nir.cH A D25-Apr-2025103 KiB3,5192,769

nir.hH A D25-Apr-2025230.9 KiB7,1133,734

nir_algebraic.pyH A D25-Apr-202549.9 KiB1,287962

nir_builder.cH A D25-Apr-202519.7 KiB658500

nir_builder.hH A D25-Apr-202568.2 KiB2,3091,812

nir_builder_opcodes_h.pyH A D25-Apr-20257.8 KiB242212

nir_builtin_builder.cH A D25-Apr-202513.2 KiB376214

nir_builtin_builder.hH A D25-Apr-20257.9 KiB284208

nir_clone.cH A D25-Apr-202525.1 KiB838578

nir_constant_expressions.hH A D25-Apr-20251.6 KiB398

nir_constant_expressions.pyH A D25-Apr-202518.6 KiB627574

nir_control_flow.cH A D25-Apr-202528.6 KiB952642

nir_control_flow.hH A D25-Apr-20257.3 KiB19876

nir_control_flow_private.hH A D25-Apr-20251.5 KiB416

nir_conversion_builder.hH A D25-Apr-202517.9 KiB522393

nir_deref.cH A D25-Apr-202549.1 KiB1,5641,065

nir_deref.hH A D25-Apr-20253 KiB8339

nir_divergence_analysis.cH A D25-Apr-202548.6 KiB1,3401,087

nir_dominance.cH A D25-Apr-20259.1 KiB341213

nir_format_convert.cH A D25-Apr-202524.3 KiB765567

nir_format_convert.hH A D25-Apr-20255.3 KiB13795

nir_from_ssa.cH A D25-Apr-202542.6 KiB1,289759

nir_functions.cH A D25-Apr-202518.6 KiB539342

nir_gather_info.cH A D25-Apr-202541.8 KiB1,094902

nir_gather_types.cH A D25-Apr-20256.9 KiB196141

nir_gather_xfb_info.cH A D25-Apr-202517.3 KiB484340

nir_group_loads.cH A D25-Apr-202515.8 KiB482293

nir_gs_count_vertices.cH A D25-Apr-20254.7 KiB12568

nir_inline_helpers.hH A D25-Apr-20254.8 KiB162144

nir_inline_uniforms.cH A D25-Apr-202517.8 KiB470255

nir_instr_set.cH A D25-Apr-202525.8 KiB832610

nir_instr_set.hH A D25-Apr-20252.7 KiB7011

nir_intrinsics.pyH A D25-Apr-2025103.1 KiB2,361899

nir_intrinsics_c.pyH A D25-Apr-20252.9 KiB8978

nir_intrinsics_h.pyH A D25-Apr-20252.2 KiB7054

nir_intrinsics_indices_h.pyH A D25-Apr-20253.1 KiB9479

nir_legacy.cH A D25-Apr-202510.3 KiB340238

nir_legacy.hH A D25-Apr-20252.4 KiB9847

nir_linking_helpers.cH A D25-Apr-202557 KiB1,6241,115

nir_liveness.cH A D25-Apr-202510.9 KiB328178

nir_loop_analyze.cH A D25-Apr-202552.4 KiB1,5941,089

nir_loop_analyze.hH A D25-Apr-20253.9 KiB12169

nir_lower_alpha_test.cH A D25-Apr-20253.6 KiB10963

nir_lower_alu.cH A D25-Apr-20259.9 KiB258157

nir_lower_alu_width.cH A D25-Apr-202517.1 KiB495353

nir_lower_amul.cH A D25-Apr-20258.2 KiB277162

nir_lower_array_deref_of_vec.cH A D25-Apr-20256.3 KiB166100

nir_lower_atomics_to_ssbo.cH A D25-Apr-20259.2 KiB257167

nir_lower_bit_size.cH A D25-Apr-202512.5 KiB366259

nir_lower_bitmap.cH A D25-Apr-20254.3 KiB12153

nir_lower_blend.cH A D25-Apr-202520.8 KiB656436

nir_lower_blend.hH A D25-Apr-20252.1 KiB6625

nir_lower_bool_to_bitsize.cH A D25-Apr-202513.5 KiB419301

nir_lower_bool_to_float.cH A D25-Apr-20256.9 KiB266211

nir_lower_bool_to_int32.cH A D25-Apr-20256.1 KiB235187

nir_lower_cl_images.cH A D25-Apr-20259.8 KiB296233

nir_lower_clamp_color_outputs.cH A D25-Apr-20252.9 KiB9968

nir_lower_clip.cH A D25-Apr-202518.4 KiB562401

nir_lower_clip_cull_distance_arrays.cH A D25-Apr-202517.8 KiB532324

nir_lower_clip_disable.cH A D25-Apr-20256.8 KiB180115

nir_lower_clip_halfz.cH A D25-Apr-20252.5 KiB6636

nir_lower_const_arrays_to_uniforms.cH A D25-Apr-202513.7 KiB416264

nir_lower_continue_constructs.cH A D25-Apr-20255.5 KiB172105

nir_lower_convert_alu_types.cH A D25-Apr-20256.1 KiB205147

nir_lower_discard_if.cH A D25-Apr-20253.5 KiB11843

nir_lower_double_ops.cH A D25-Apr-202528.8 KiB912559

nir_lower_drawpixels.cH A D25-Apr-20259 KiB260183

nir_lower_fb_read.cH A D25-Apr-20253.7 KiB9338

nir_lower_flatshade.cH A D25-Apr-20252.9 KiB8353

nir_lower_flrp.cH A D25-Apr-202522.6 KiB676329

nir_lower_fp16_conv.cH A D25-Apr-202513.8 KiB347227

nir_lower_frag_coord_to_pixel_coord.cH A D25-Apr-20251.1 KiB3523

nir_lower_fragcolor.cH A D25-Apr-20254 KiB10345

nir_lower_fragcoord_wtrans.cH A D25-Apr-20252.7 KiB7938

nir_lower_frexp.cH A D25-Apr-20256.6 KiB195113

nir_lower_global_vars_to_local.cH A D25-Apr-20253.5 KiB10860

nir_lower_goto_ifs.cH A D25-Apr-202533.1 KiB984687

nir_lower_gs_intrinsics.cH A D25-Apr-202519.6 KiB544322

nir_lower_helper_writes.cH A D25-Apr-20253.9 KiB10955

nir_lower_idiv.cH A D25-Apr-20256.5 KiB186117

nir_lower_image.cH A D25-Apr-20258.2 KiB221143

nir_lower_image_atomics_to_global.cH A D25-Apr-20253.5 KiB10469

nir_lower_indirect_derefs.cH A D25-Apr-20258.3 KiB244166

nir_lower_input_attachments.cH A D25-Apr-20257.6 KiB221148

nir_lower_int64.cH A D25-Apr-202544.1 KiB1,4081,067

nir_lower_int_to_float.cH A D25-Apr-20258.6 KiB324247

nir_lower_interpolation.cH A D25-Apr-20254.4 KiB13176

nir_lower_io.cH A D25-Apr-2025116.8 KiB3,3112,555

nir_lower_io_arrays_to_elements.cH A D25-Apr-202514.7 KiB432289

nir_lower_io_to_scalar.cH A D25-Apr-202521.6 KiB609436

nir_lower_io_to_temporaries.cH A D25-Apr-202513.3 KiB383233

nir_lower_io_to_vector.cH A D25-Apr-202521.8 KiB665480

nir_lower_is_helper_invocation.cH A D25-Apr-20254.3 KiB11765

nir_lower_load_const_to_scalar.cH A D25-Apr-20253.1 KiB9748

nir_lower_locals_to_regs.cH A D25-Apr-202510 KiB319215

nir_lower_mediump.cH A D25-Apr-202535.7 KiB1,107854

nir_lower_mem_access_bit_sizes.cH A D25-Apr-202519.1 KiB491373

nir_lower_memcpy.cH A D25-Apr-20256.9 KiB201138

nir_lower_memory_model.cH A D25-Apr-20257.8 KiB250200

nir_lower_multiview.cH A D25-Apr-202510.6 KiB318183

nir_lower_non_uniform_access.cH A D25-Apr-202511.2 KiB345238

nir_lower_packing.cH A D25-Apr-20256.7 KiB194137

nir_lower_passthrough_edgeflags.cH A D25-Apr-20253.5 KiB10054

nir_lower_patch_vertices.cH A D25-Apr-20253.3 KiB9946

nir_lower_phis_to_scalar.cH A D25-Apr-202510.5 KiB299148

nir_lower_pntc_ytransform.cH A D25-Apr-20254.4 KiB12879

nir_lower_point_size.cH A D25-Apr-20253.2 KiB9040

nir_lower_point_size_mov.cH A D25-Apr-20254.4 KiB11978

nir_lower_point_smooth.cH A D25-Apr-20253.8 KiB10452

nir_lower_poly_line_smooth.cH A D25-Apr-20253 KiB8843

nir_lower_printf.cH A D25-Apr-20258.2 KiB227161

nir_lower_readonly_images_to_tex.cH A D25-Apr-20258.5 KiB258180

nir_lower_reg_intrinsics_to_ssa.cH A D25-Apr-20255.2 KiB188139

nir_lower_returns.cH A D25-Apr-202510.2 KiB313182

nir_lower_robust_access.cH A D25-Apr-20257.2 KiB242189

nir_lower_samplers.cH A D25-Apr-20255.1 KiB15180

nir_lower_scratch.cH A D25-Apr-20257.7 KiB234154

nir_lower_shader_calls.cH A D25-Apr-202572.9 KiB2,0941,355

nir_lower_single_sampled.cH A D25-Apr-20254.3 KiB12276

nir_lower_ssbo.cH A D25-Apr-20252.9 KiB9266

nir_lower_subgroups.cH A D25-Apr-202546.6 KiB1,271892

nir_lower_system_values.cH A D25-Apr-202530.2 KiB811542

nir_lower_sysvals_to_varyings.cH A D25-Apr-20252.7 KiB7330

nir_lower_task_shader.cH A D25-Apr-202516.8 KiB479299

nir_lower_terminate_to_demote.cH A D25-Apr-20253.4 KiB11881

nir_lower_tess_coord_z.cH A D25-Apr-2025996 4029

nir_lower_tex.cH A D25-Apr-202560.9 KiB1,8201,322

nir_lower_tex_shadow.cH A D25-Apr-20255.2 KiB156102

nir_lower_texcoord_replace.cH A D25-Apr-20255.1 KiB14290

nir_lower_texcoord_replace_late.cH A D25-Apr-20253.2 KiB10778

nir_lower_two_sided_color.cH A D25-Apr-20257 KiB210143

nir_lower_ubo_vec4.cH A D25-Apr-20257.4 KiB19292

nir_lower_undef_to_zero.cH A D25-Apr-20252.5 KiB6420

nir_lower_uniforms_to_ubo.cH A D25-Apr-20256.6 KiB16997

nir_lower_var_copies.cH A D25-Apr-20255.3 KiB14491

nir_lower_variable_initializers.cH A D25-Apr-202510.6 KiB292195

nir_lower_vars_to_ssa.cH A D25-Apr-202528.7 KiB883532

nir_lower_vec3_to_vec4.cH A D25-Apr-20254.7 KiB153104

nir_lower_vec_to_regs.cH A D25-Apr-20258.5 KiB264151

nir_lower_view_index_to_device_index.cH A D25-Apr-2025557 2514

nir_lower_viewport_transform.cH A D25-Apr-20253.9 KiB9837

nir_lower_wpos_center.cH A D25-Apr-20252.6 KiB6822

nir_lower_wpos_ytransform.cH A D25-Apr-202514 KiB382243

nir_lower_wrmasks.cH A D25-Apr-20257.3 KiB232121

nir_metadata.cH A D25-Apr-20253.4 KiB10552

nir_mod_analysis.cH A D25-Apr-20255.7 KiB185120

nir_move_vec_src_uses_to_dest.cH A D25-Apr-20256.7 KiB205110

nir_normalize_cubemap_coords.cH A D25-Apr-20252.6 KiB7434

nir_opcodes.pyH A D25-Apr-202565.3 KiB1,6871,250

nir_opcodes_c.pyH A D25-Apr-20255.1 KiB134101

nir_opcodes_h.pyH A D25-Apr-20251.6 KiB4639

nir_opt_access.cH A D25-Apr-202511.6 KiB340251

nir_opt_algebraic.pyH A D25-Apr-2025198.5 KiB3,6552,355

nir_opt_barriers.cH A D25-Apr-20258.2 KiB248151

nir_opt_combine_stores.cH A D25-Apr-202514.4 KiB434293

nir_opt_comparison_pre.cH A D25-Apr-202512.8 KiB407213

nir_opt_conditional_discard.cH A D25-Apr-20254.3 KiB13781

nir_opt_constant_folding.cH A D25-Apr-202514.4 KiB452335

nir_opt_copy_prop_vars.cH A D25-Apr-202552.2 KiB1,5341,068

nir_opt_copy_propagate.cH A D25-Apr-20254.8 KiB181113

nir_opt_cse.cH A D25-Apr-20252.2 KiB7638

nir_opt_dce.cH A D25-Apr-20258.6 KiB270197

nir_opt_dead_cf.cH A D25-Apr-202513.9 KiB420228

nir_opt_dead_write_vars.cH A D25-Apr-20258.8 KiB260161

nir_opt_find_array_copies.cH A D25-Apr-202522.1 KiB685452

nir_opt_fragdepth.cH A D25-Apr-20254.1 KiB12568

nir_opt_gcm.cH A D25-Apr-202529.9 KiB881534

nir_opt_generate_bfi.cH A D25-Apr-20254.6 KiB16195

nir_opt_idiv_const.cH A D25-Apr-20257.4 KiB224170

nir_opt_if.cH A D25-Apr-202548.5 KiB1,476789

nir_opt_intrinsics.cH A D25-Apr-202513 KiB409282

nir_opt_large_constants.cH A D25-Apr-202519.3 KiB597421

nir_opt_licm.cH A D25-Apr-20254.1 KiB145111

nir_opt_load_store_vectorize.cH A D25-Apr-202552.4 KiB1,5261,169

nir_opt_loop.cH A D25-Apr-202523.1 KiB729403

nir_opt_loop_unroll.cH A D25-Apr-202543.4 KiB1,199679

nir_opt_memcpy.cH A D25-Apr-20259.8 KiB298199

nir_opt_move.cH A D25-Apr-20255.3 KiB14864

nir_opt_move_discards_to_top.cH A D25-Apr-20259.5 KiB278182

nir_opt_mqsad.cH A D25-Apr-20254.1 KiB147110

nir_opt_non_uniform_access.cH A D25-Apr-20257.3 KiB245186

nir_opt_offsets.cH A D25-Apr-20258.6 KiB241168

nir_opt_peephole_select.cH A D25-Apr-202518.7 KiB579377

nir_opt_phi_precision.cH A D25-Apr-202513.5 KiB471249

nir_opt_preamble.cH A D25-Apr-202531.9 KiB981629

nir_opt_ray_queries.cH A D25-Apr-202513.1 KiB422271

nir_opt_reassociate_bfi.cH A D25-Apr-20254.8 KiB13652

nir_opt_rematerialize_compares.cH A D25-Apr-20259.9 KiB326218

nir_opt_remove_phis.cH A D25-Apr-20255.5 KiB17386

nir_opt_reuse_constants.cH A D25-Apr-20251.4 KiB5238

nir_opt_shrink_stores.cH A D25-Apr-20253.8 KiB12375

nir_opt_shrink_vectors.cH A D25-Apr-202516.6 KiB581378

nir_opt_sink.cH A D25-Apr-20258.7 KiB271167

nir_opt_undef.cH A D25-Apr-202510.6 KiB330198

nir_opt_uniform_atomics.cH A D25-Apr-202512.3 KiB385288

nir_opt_uniform_subgroup.cH A D25-Apr-20255.1 KiB162114

nir_opt_varyings.cH A D25-Apr-2025169.3 KiB4,3672,509

nir_opt_vectorize.cH A D25-Apr-202519.7 KiB618402

nir_opt_vectorize_io.cH A D25-Apr-202520.5 KiB579373

nir_passthrough_gs.cH A D25-Apr-20259.8 KiB275214

nir_passthrough_tcs.cH A D25-Apr-20254.6 KiB11661

nir_phi_builder.cH A D25-Apr-202510.9 KiB305147

nir_phi_builder.hH A D25-Apr-20254.7 KiB12017

nir_print.cH A D25-Apr-202584.1 KiB2,8882,407

nir_propagate_invariant.cH A D25-Apr-20256.4 KiB225155

nir_range_analysis.cH A D25-Apr-202576.8 KiB2,2041,535

nir_range_analysis.hH A D25-Apr-20251.9 KiB6630

nir_remove_dead_variables.cH A D25-Apr-20256.8 KiB219146

nir_remove_tex_shadow.cH A D25-Apr-20253.6 KiB10970

nir_repair_ssa.cH A D25-Apr-20255.9 KiB191117

nir_scale_fdiv.cH A D25-Apr-20252.8 KiB7535

nir_schedule.cH A D25-Apr-202538.5 KiB1,296865

nir_schedule.hH A D25-Apr-20253.3 KiB9329

nir_search.cH A D25-Apr-202531 KiB953693

nir_search.hH A D25-Apr-20257.9 KiB249104

nir_search_helpers.hH A D25-Apr-202525.6 KiB835638

nir_serialize.cH A D25-Apr-202567.7 KiB2,2491,760

nir_serialize.hH A D25-Apr-20251.9 KiB5221

nir_split_64bit_vec3_and_vec4.cH A D25-Apr-202510.9 KiB327239

nir_split_per_member_structs.cH A D25-Apr-20256 KiB185128

nir_split_var_copies.cH A D25-Apr-20254.9 KiB11046

nir_split_vars.cH A D25-Apr-202559.9 KiB1,7441,274

nir_sweep.cH A D25-Apr-20255.3 KiB188114

nir_to_lcssa.cH A D25-Apr-202512.5 KiB407270

nir_trivialize_registers.cH A D25-Apr-202517 KiB511272

nir_use_dominance.cH A D25-Apr-202512.7 KiB389218

nir_validate.cH A D25-Apr-202562.5 KiB1,8421,368

nir_vla.hH A D25-Apr-20252.1 KiB5410

nir_worklist.cH A D25-Apr-20251.6 KiB4720

nir_worklist.hH A D25-Apr-20254.1 KiB14480

nir_xfb_info.hH A D25-Apr-20252.6 KiB9655

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