• Home
Name Date Size #Lines LOC

..--

tests/04-Jul-2025-14,6269,585

.clang-formatD04-Jul-2025155 75

Android.bpD04-Jul-20259.8 KiB374353

READMED04-Jul-20255.7 KiB11998

meson.buildD04-Jul-202511.6 KiB408387

nir.cD04-Jul-2025107.6 KiB3,6752,900

nir.hD04-Jul-2025237.6 KiB7,2773,763

nir_algebraic.pyD04-Jul-202550 KiB1,289964

nir_builder.cD04-Jul-202519.5 KiB652496

nir_builder.hD04-Jul-202568.3 KiB2,3081,827

nir_builder_opcodes_h.pyD04-Jul-20258.5 KiB257227

nir_builtin_builder.cD04-Jul-202513.2 KiB376214

nir_builtin_builder.hD04-Jul-20257.9 KiB284208

nir_clone.cD04-Jul-202526.2 KiB865602

nir_constant_expressions.hD04-Jul-20251.6 KiB398

nir_constant_expressions.pyD04-Jul-202518.6 KiB627574

nir_control_flow.cD04-Jul-202528.6 KiB952642

nir_control_flow.hD04-Jul-20257.3 KiB19876

nir_control_flow_private.hD04-Jul-20251.5 KiB416

nir_conversion_builder.hD04-Jul-202518 KiB525394

nir_defines.hD04-Jul-20251.7 KiB6239

nir_deref.cD04-Jul-202549.7 KiB1,5821,074

nir_deref.hD04-Jul-20253 KiB8339

nir_divergence_analysis.cD04-Jul-202554.4 KiB1,5081,221

nir_dominance.cD04-Jul-20259.1 KiB341213

nir_fixup_is_exported.cD04-Jul-20251.9 KiB6126

nir_format_convert.cD04-Jul-202524.3 KiB765567

nir_format_convert.hD04-Jul-20255.3 KiB13795

nir_from_ssa.cD04-Jul-202542.6 KiB1,289759

nir_functions.cD04-Jul-202519.3 KiB558359

nir_gather_info.cD04-Jul-202541.9 KiB1,095906

nir_gather_tcs_info.cD04-Jul-202512.8 KiB335221

nir_gather_types.cD04-Jul-20256.9 KiB196141

nir_gather_xfb_info.cD04-Jul-202517.3 KiB484340

nir_group_loads.cD04-Jul-202515.9 KiB483294

nir_gs_count_vertices.cD04-Jul-20254.7 KiB12568

nir_inline_helpers.hD04-Jul-20254.8 KiB162144

nir_inline_uniforms.cD04-Jul-202517.8 KiB470255

nir_instr_set.cD04-Jul-202525.9 KiB831605

nir_instr_set.hD04-Jul-20252.7 KiB7011

nir_intrinsics.pyD04-Jul-2025107.3 KiB2,435925

nir_intrinsics_c.pyD04-Jul-20252.9 KiB8978

nir_intrinsics_h.pyD04-Jul-20252.2 KiB7054

nir_intrinsics_indices_h.pyD04-Jul-20253.1 KiB9479

nir_legacy.cD04-Jul-202510.3 KiB340238

nir_legacy.hD04-Jul-20252.4 KiB9847

nir_linking_helpers.cD04-Jul-202556.8 KiB1,6201,111

nir_liveness.cD04-Jul-202510.9 KiB328178

nir_loop_analyze.cD04-Jul-202553.8 KiB1,6241,105

nir_loop_analyze.hD04-Jul-20253.9 KiB12169

nir_lower_alpha_test.cD04-Jul-20253.6 KiB10963

nir_lower_alu.cD04-Jul-20259.9 KiB258157

nir_lower_alu_width.cD04-Jul-202517.1 KiB495353

nir_lower_amul.cD04-Jul-20258.4 KiB283168

nir_lower_array_deref_of_vec.cD04-Jul-20256.3 KiB166100

nir_lower_atomics.cD04-Jul-20254.6 KiB12883

nir_lower_atomics_to_ssbo.cD04-Jul-20259.2 KiB257167

nir_lower_bit_size.cD04-Jul-202512.5 KiB366259

nir_lower_bitmap.cD04-Jul-20254.6 KiB12862

nir_lower_blend.cD04-Jul-202520.8 KiB656436

nir_lower_blend.hD04-Jul-20252.1 KiB6625

nir_lower_bool_to_bitsize.cD04-Jul-202513.5 KiB419301

nir_lower_bool_to_float.cD04-Jul-20256.9 KiB266211

nir_lower_bool_to_int32.cD04-Jul-20256.1 KiB235187

nir_lower_calls_to_builtins.cD04-Jul-20254.9 KiB14781

nir_lower_cl_images.cD04-Jul-202510.2 KiB302238

nir_lower_clamp_color_outputs.cD04-Jul-20253 KiB10069

nir_lower_clip.cD04-Jul-202520.8 KiB626443

nir_lower_clip_cull_distance_arrays.cD04-Jul-202517.7 KiB527320

nir_lower_clip_disable.cD04-Jul-20257 KiB186118

nir_lower_clip_halfz.cD04-Jul-20252.5 KiB6636

nir_lower_const_arrays_to_uniforms.cD04-Jul-202513.7 KiB416264

nir_lower_continue_constructs.cD04-Jul-20255.5 KiB172105

nir_lower_convert_alu_types.cD04-Jul-20254.7 KiB142100

nir_lower_discard_if.cD04-Jul-20253.5 KiB11843

nir_lower_double_ops.cD04-Jul-202528.8 KiB912559

nir_lower_drawpixels.cD04-Jul-20259.3 KiB267189

nir_lower_fb_read.cD04-Jul-20253.7 KiB9338

nir_lower_flatshade.cD04-Jul-20252.9 KiB8353

nir_lower_flrp.cD04-Jul-202522.6 KiB676329

nir_lower_fp16_conv.cD04-Jul-202513.8 KiB347227

nir_lower_frag_coord_to_pixel_coord.cD04-Jul-20251.1 KiB3523

nir_lower_fragcolor.cD04-Jul-20254 KiB10345

nir_lower_fragcoord_wtrans.cD04-Jul-20252.6 KiB8139

nir_lower_frexp.cD04-Jul-20256.6 KiB195113

nir_lower_global_vars_to_local.cD04-Jul-20253.5 KiB10860

nir_lower_goto_ifs.cD04-Jul-202533.1 KiB984687

nir_lower_gs_intrinsics.cD04-Jul-202519.6 KiB544322

nir_lower_helper_writes.cD04-Jul-20253.9 KiB10955

nir_lower_idiv.cD04-Jul-20256.5 KiB186117

nir_lower_image.cD04-Jul-20258.2 KiB221143

nir_lower_image_atomics_to_global.cD04-Jul-20253.5 KiB10469

nir_lower_indirect_derefs.cD04-Jul-20258.3 KiB244166

nir_lower_input_attachments.cD04-Jul-20257.8 KiB225152

nir_lower_int64.cD04-Jul-202544.5 KiB1,4181,077

nir_lower_int_to_float.cD04-Jul-20258.6 KiB324247

nir_lower_interpolation.cD04-Jul-20254.4 KiB13176

nir_lower_io.cD04-Jul-2025120.1 KiB3,4072,623

nir_lower_io_arrays_to_elements.cD04-Jul-202514.7 KiB432289

nir_lower_io_to_scalar.cD04-Jul-202521.8 KiB612439

nir_lower_io_to_temporaries.cD04-Jul-202514 KiB397240

nir_lower_io_to_vector.cD04-Jul-202521.8 KiB665480

nir_lower_is_helper_invocation.cD04-Jul-20254.3 KiB11765

nir_lower_load_const_to_scalar.cD04-Jul-20253.1 KiB9748

nir_lower_locals_to_regs.cD04-Jul-202510 KiB319215

nir_lower_mediump.cD04-Jul-202536.8 KiB1,131875

nir_lower_mem_access_bit_sizes.cD04-Jul-202521.5 KiB559428

nir_lower_memcpy.cD04-Jul-20256.9 KiB201138

nir_lower_memory_model.cD04-Jul-20257.8 KiB250200

nir_lower_multiview.cD04-Jul-202511.5 KiB329185

nir_lower_non_uniform_access.cD04-Jul-202516.2 KiB496353

nir_lower_packing.cD04-Jul-20256.7 KiB194137

nir_lower_passthrough_edgeflags.cD04-Jul-20253.1 KiB8743

nir_lower_patch_vertices.cD04-Jul-20253.3 KiB9946

nir_lower_phis_to_scalar.cD04-Jul-202510.5 KiB299148

nir_lower_pntc_ytransform.cD04-Jul-20254.9 KiB14188

nir_lower_point_size.cD04-Jul-20253.3 KiB9443

nir_lower_point_size_mov.cD04-Jul-20254.3 KiB11776

nir_lower_point_smooth.cD04-Jul-20255.7 KiB15890

nir_lower_poly_line_smooth.cD04-Jul-20253 KiB8843

nir_lower_printf.cD04-Jul-202510.7 KiB308212

nir_lower_readonly_images_to_tex.cD04-Jul-20258.5 KiB258180

nir_lower_reg_intrinsics_to_ssa.cD04-Jul-20255.2 KiB188139

nir_lower_returns.cD04-Jul-202510.2 KiB313182

nir_lower_robust_access.cD04-Jul-20256.8 KiB226165

nir_lower_samplers.cD04-Jul-20255.1 KiB15180

nir_lower_scratch.cD04-Jul-20257.7 KiB234154

nir_lower_scratch_to_var.cD04-Jul-20254.2 KiB11662

nir_lower_shader_calls.cD04-Jul-202573 KiB2,0951,356

nir_lower_single_sampled.cD04-Jul-20254.3 KiB12276

nir_lower_ssbo.cD04-Jul-20252.9 KiB9266

nir_lower_subgroups.cD04-Jul-202550.3 KiB1,360960

nir_lower_system_values.cD04-Jul-202530.4 KiB813544

nir_lower_sysvals_to_varyings.cD04-Jul-20252.7 KiB7330

nir_lower_task_shader.cD04-Jul-202516.8 KiB479299

nir_lower_terminate_to_demote.cD04-Jul-20253.4 KiB11881

nir_lower_tess_coord_z.cD04-Jul-2025996 4029

nir_lower_tex.cD04-Jul-202560.9 KiB1,8201,322

nir_lower_tex_shadow.cD04-Jul-20255.2 KiB156102

nir_lower_texcoord_replace.cD04-Jul-20255.1 KiB14290

nir_lower_texcoord_replace_late.cD04-Jul-20253 KiB9870

nir_lower_two_sided_color.cD04-Jul-20256.9 KiB209142

nir_lower_ubo_vec4.cD04-Jul-20257.4 KiB19292

nir_lower_undef_to_zero.cD04-Jul-20252.5 KiB6420

nir_lower_uniforms_to_ubo.cD04-Jul-20256.6 KiB16997

nir_lower_var_copies.cD04-Jul-20255.3 KiB14491

nir_lower_variable_initializers.cD04-Jul-202511 KiB304206

nir_lower_vars_to_ssa.cD04-Jul-202528.7 KiB883532

nir_lower_vec3_to_vec4.cD04-Jul-20254.7 KiB153104

nir_lower_vec_to_regs.cD04-Jul-20258.5 KiB264151

nir_lower_view_index_to_device_index.cD04-Jul-2025557 2514

nir_lower_viewport_transform.cD04-Jul-20254.5 KiB10940

nir_lower_wpos_center.cD04-Jul-20252.6 KiB6822

nir_lower_wpos_ytransform.cD04-Jul-202511.8 KiB333204

nir_lower_wrmasks.cD04-Jul-20257.4 KiB234123

nir_metadata.cD04-Jul-20253.4 KiB10552

nir_mod_analysis.cD04-Jul-20255.7 KiB185120

nir_move_vec_src_uses_to_dest.cD04-Jul-20256.8 KiB206111

nir_normalize_cubemap_coords.cD04-Jul-20252.6 KiB7434

nir_opcodes.pyD04-Jul-202566.5 KiB1,7151,265

nir_opcodes_c.pyD04-Jul-20255.1 KiB134101

nir_opcodes_h.pyD04-Jul-20251.6 KiB4639

nir_opt_access.cD04-Jul-202511.6 KiB340251

nir_opt_algebraic.pyD04-Jul-2025206.8 KiB3,8072,454

nir_opt_barriers.cD04-Jul-20258.2 KiB248151

nir_opt_clip_cull_const.cD04-Jul-20251.4 KiB5430

nir_opt_combine_stores.cD04-Jul-202514.4 KiB434293

nir_opt_comparison_pre.cD04-Jul-202512.8 KiB407213

nir_opt_conditional_discard.cD04-Jul-20254.3 KiB13781

nir_opt_constant_folding.cD04-Jul-202514.4 KiB452335

nir_opt_copy_prop_vars.cD04-Jul-202552.2 KiB1,5341,068

nir_opt_copy_propagate.cD04-Jul-20254.8 KiB181113

nir_opt_cse.cD04-Jul-20252.2 KiB7638

nir_opt_dce.cD04-Jul-20258.6 KiB270197

nir_opt_dead_cf.cD04-Jul-202513.9 KiB421229

nir_opt_dead_write_vars.cD04-Jul-20258.8 KiB260161

nir_opt_find_array_copies.cD04-Jul-202522.1 KiB685452

nir_opt_frag_coord_to_pixel_coord.cD04-Jul-20252.3 KiB9058

nir_opt_fragdepth.cD04-Jul-20254.1 KiB12568

nir_opt_gcm.cD04-Jul-202529.7 KiB877531

nir_opt_generate_bfi.cD04-Jul-20254.6 KiB16195

nir_opt_idiv_const.cD04-Jul-20257.4 KiB224170

nir_opt_if.cD04-Jul-202548.5 KiB1,476789

nir_opt_intrinsics.cD04-Jul-202514.2 KiB441302

nir_opt_large_constants.cD04-Jul-202519.3 KiB597421

nir_opt_licm.cD04-Jul-20254.1 KiB145111

nir_opt_load_store_vectorize.cD04-Jul-202555.8 KiB1,6081,217

nir_opt_loop.cD04-Jul-202523.4 KiB735407

nir_opt_loop_unroll.cD04-Jul-202543.4 KiB1,199679

nir_opt_memcpy.cD04-Jul-20259.8 KiB298199

nir_opt_move.cD04-Jul-20255.3 KiB14864

nir_opt_move_discards_to_top.cD04-Jul-202513.1 KiB382264

nir_opt_mqsad.cD04-Jul-20254.1 KiB147110

nir_opt_non_uniform_access.cD04-Jul-20257.2 KiB242184

nir_opt_offsets.cD04-Jul-20258.8 KiB247173

nir_opt_peephole_select.cD04-Jul-202518.8 KiB581379

nir_opt_phi_precision.cD04-Jul-202513.5 KiB471249

nir_opt_preamble.cD04-Jul-202531.6 KiB974625

nir_opt_ray_queries.cD04-Jul-202513.1 KiB422271

nir_opt_reassociate_bfi.cD04-Jul-20254.8 KiB13652

nir_opt_rematerialize_compares.cD04-Jul-20259.9 KiB326218

nir_opt_remove_phis.cD04-Jul-20256.4 KiB212126

nir_opt_shrink_stores.cD04-Jul-20253.9 KiB12476

nir_opt_shrink_vectors.cD04-Jul-202517.2 KiB591390

nir_opt_sink.cD04-Jul-20258.6 KiB270172

nir_opt_undef.cD04-Jul-202510.8 KiB345219

nir_opt_uniform_atomics.cD04-Jul-202511.4 KiB346250

nir_opt_uniform_subgroup.cD04-Jul-20255.1 KiB162114

nir_opt_varyings.cD04-Jul-2025208.2 KiB5,3203,198

nir_opt_vectorize.cD04-Jul-202519.7 KiB618402

nir_opt_vectorize_io.cD04-Jul-202520.8 KiB587376

nir_passthrough_gs.cD04-Jul-202511 KiB301225

nir_passthrough_tcs.cD04-Jul-20254.6 KiB11661

nir_phi_builder.cD04-Jul-202510.9 KiB305147

nir_phi_builder.hD04-Jul-20254.7 KiB12017

nir_precompiled.hD04-Jul-202523.8 KiB693375

nir_print.cD04-Jul-202586.1 KiB2,9472,456

nir_propagate_invariant.cD04-Jul-20256.4 KiB225155

nir_range_analysis.cD04-Jul-202577.1 KiB2,2151,545

nir_range_analysis.hD04-Jul-20251.9 KiB6630

nir_remove_dead_variables.cD04-Jul-20256.8 KiB219146

nir_remove_tex_shadow.cD04-Jul-20253.6 KiB10970

nir_repair_ssa.cD04-Jul-20255.9 KiB191117

nir_scale_fdiv.cD04-Jul-20252.8 KiB7535

nir_schedule.cD04-Jul-202538.5 KiB1,296865

nir_schedule.hD04-Jul-20253.3 KiB9329

nir_search.cD04-Jul-202531.2 KiB961698

nir_search.hD04-Jul-20258 KiB252105

nir_search_helpers.hD04-Jul-202528.6 KiB933706

nir_serialize.cD04-Jul-202567.6 KiB2,2461,758

nir_serialize.hD04-Jul-20251.6 KiB4415

nir_split_64bit_vec3_and_vec4.cD04-Jul-202510.9 KiB327239

nir_split_per_member_structs.cD04-Jul-20256 KiB185128

nir_split_var_copies.cD04-Jul-20254.9 KiB11046

nir_split_vars.cD04-Jul-202559.9 KiB1,7441,274

nir_sweep.cD04-Jul-20255.3 KiB188114

nir_to_lcssa.cD04-Jul-202512.8 KiB420277

nir_trivialize_registers.cD04-Jul-202517 KiB511272

nir_use_dominance.cD04-Jul-202512.7 KiB389218

nir_validate.cD04-Jul-202562.6 KiB1,8431,369

nir_vla.hD04-Jul-20252.1 KiB5410

nir_worklist.cD04-Jul-20251.6 KiB4720

nir_worklist.hD04-Jul-20254.1 KiB14480

nir_xfb_info.hD04-Jul-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