• Home
Name
Date
Size
#Lines
LOC

..--

tests/12-May-2024-7,3034,721

READMED12-May-20245.7 KiB11998

meson.buildD12-May-202413.1 KiB450422

nir.cD12-May-2024100.6 KiB3,5412,805

nir.hD12-May-2024184.3 KiB5,7273,008

nir_algebraic.pyD12-May-202448.9 KiB1,268946

nir_builder.cD12-May-202414.5 KiB488352

nir_builder.hD12-May-202452.3 KiB1,7271,363

nir_builder_opcodes_h.pyD12-May-20246 KiB172153

nir_builtin_builder.cD12-May-202415.5 KiB436259

nir_builtin_builder.hD12-May-20247.6 KiB259188

nir_clone.cD12-May-202424.9 KiB840578

nir_constant_expressions.hD12-May-20241.6 KiB398

nir_constant_expressions.pyD12-May-202415.9 KiB520483

nir_control_flow.cD12-May-202425.1 KiB834554

nir_control_flow.hD12-May-20246.9 KiB18364

nir_control_flow_private.hD12-May-20241.5 KiB426

nir_conversion_builder.hD12-May-202418.1 KiB524396

nir_convert_ycbcr.cD12-May-20245.6 KiB143107

nir_deref.cD12-May-202447.5 KiB1,5091,031

nir_deref.hD12-May-20243 KiB8339

nir_divergence_analysis.cD12-May-202440.3 KiB1,122932

nir_dominance.cD12-May-20249.3 KiB347218

nir_format_convert.hD12-May-202415.7 KiB467342

nir_from_ssa.cD12-May-202438.4 KiB1,143657

nir_gather_info.cD12-May-202439.1 KiB1,034863

nir_gather_ssa_types.cD12-May-20248.6 KiB235169

nir_gather_xfb_info.cD12-May-202417.5 KiB491343

nir_group_loads.cD12-May-202415.8 KiB485295

nir_gs_count_vertices.cD12-May-20244.2 KiB11860

nir_inline_functions.cD12-May-202410.9 KiB288129

nir_inline_helpers.hD12-May-20244.7 KiB165145

nir_inline_uniforms.cD12-May-202415.7 KiB429241

nir_instr_set.cD12-May-202425.7 KiB857627

nir_instr_set.hD12-May-20242.8 KiB7110

nir_intrinsics.pyD12-May-202466.6 KiB1,539657

nir_intrinsics_c.pyD12-May-20242.9 KiB8978

nir_intrinsics_h.pyD12-May-20242.2 KiB7054

nir_intrinsics_indices_h.pyD12-May-20243.1 KiB9782

nir_linking_helpers.cD12-May-202459.3 KiB1,7071,176

nir_liveness.cD12-May-202411.4 KiB345188

nir_loop_analyze.cD12-May-202446 KiB1,416994

nir_loop_analyze.hD12-May-20243.5 KiB10858

nir_lower_alpha_test.cD12-May-20244.7 KiB12273

nir_lower_alu.cD12-May-202410.1 KiB260165

nir_lower_alu_width.cD12-May-202415.4 KiB449318

nir_lower_amul.cD12-May-202410.2 KiB338215

nir_lower_array_deref_of_vec.cD12-May-20247.5 KiB198131

nir_lower_atomics_to_ssbo.cD12-May-20249.6 KiB270177

nir_lower_bit_size.cD12-May-202412.7 KiB376267

nir_lower_bitmap.cD12-May-20244.8 KiB14371

nir_lower_blend.cD12-May-202417.4 KiB538361

nir_lower_blend.hD12-May-20242.1 KiB7127

nir_lower_bool_to_bitsize.cD12-May-202414.4 KiB463338

nir_lower_bool_to_float.cD12-May-20246.4 KiB206152

nir_lower_bool_to_int32.cD12-May-20246.1 KiB196142

nir_lower_clamp_color_outputs.cD12-May-20243.9 KiB14199

nir_lower_clip.cD12-May-202416.5 KiB517359

nir_lower_clip_cull_distance_arrays.cD12-May-20244.9 KiB15988

nir_lower_clip_disable.cD12-May-20245.5 KiB14784

nir_lower_clip_halfz.cD12-May-20242.9 KiB8047

nir_lower_const_arrays_to_uniforms.cD12-May-202413.9 KiB420268

nir_lower_convert_alu_types.cD12-May-20246.3 KiB210152

nir_lower_discard_if.cD12-May-20243.3 KiB10429

nir_lower_discard_or_demote.cD12-May-20247.8 KiB202133

nir_lower_double_ops.cD12-May-202425 KiB769447

nir_lower_drawpixels.cD12-May-202410.2 KiB308223

nir_lower_fb_read.cD12-May-20244.3 KiB12252

nir_lower_flatshade.cD12-May-20241.7 KiB5122

nir_lower_flrp.cD12-May-202421.4 KiB661314

nir_lower_fp16_conv.cD12-May-20249.6 KiB238161

nir_lower_fragcolor.cD12-May-20244.2 KiB10849

nir_lower_fragcoord_wtrans.cD12-May-20242.7 KiB7937

nir_lower_frexp.cD12-May-20247.3 KiB221129

nir_lower_global_vars_to_local.cD12-May-20243.7 KiB11664

nir_lower_goto_ifs.cD12-May-202433.3 KiB997699

nir_lower_gs_intrinsics.cD12-May-202415.8 KiB452257

nir_lower_idiv.cD12-May-20249.1 KiB285188

nir_lower_image.cD12-May-20243.4 KiB9655

nir_lower_indirect_derefs.cD12-May-20248.6 KiB247170

nir_lower_input_attachments.cD12-May-20247.3 KiB220146

nir_lower_int64.cD12-May-202442.6 KiB1,3121,016

nir_lower_int_to_float.cD12-May-20247 KiB221156

nir_lower_interpolation.cD12-May-20245.3 KiB16199

nir_lower_io.cD12-May-2024110.8 KiB3,1352,477

nir_lower_io_arrays_to_elements.cD12-May-202415.2 KiB441298

nir_lower_io_to_scalar.cD12-May-202419.2 KiB554385

nir_lower_io_to_temporaries.cD12-May-202413.6 KiB389238

nir_lower_io_to_vector.cD12-May-202423.7 KiB713521

nir_lower_is_helper_invocation.cD12-May-20244.4 KiB12773

nir_lower_load_const_to_scalar.cD12-May-20243.4 KiB10253

nir_lower_locals_to_regs.cD12-May-202410.5 KiB329219

nir_lower_mediump.cD12-May-202424.8 KiB773575

nir_lower_memcpy.cD12-May-20247.1 KiB199136

nir_lower_memory_model.cD12-May-20249.7 KiB295245

nir_lower_multiview.cD12-May-202413 KiB367231

nir_lower_non_uniform_access.cD12-May-202412.7 KiB373268

nir_lower_packing.cD12-May-20245 KiB157105

nir_lower_passthrough_edgeflags.cD12-May-20243.7 KiB10558

nir_lower_patch_vertices.cD12-May-20243.9 KiB11057

nir_lower_phis_to_scalar.cD12-May-202411.3 KiB326164

nir_lower_pntc_ytransform.cD12-May-20244.9 KiB13788

nir_lower_point_size.cD12-May-20243.7 KiB11459

nir_lower_point_size_mov.cD12-May-20244.5 KiB11671

nir_lower_point_smooth.cD12-May-20243.6 KiB9541

nir_lower_poly_line_smooth.cD12-May-20243 KiB8037

nir_lower_printf.cD12-May-20245.9 KiB14488

nir_lower_readonly_images_to_tex.cD12-May-20247.4 KiB216145

nir_lower_regs_to_ssa.cD12-May-20249.8 KiB312195

nir_lower_returns.cD12-May-202410 KiB309182

nir_lower_samplers.cD12-May-20245.7 KiB179103

nir_lower_scratch.cD12-May-20247.7 KiB235153

nir_lower_shader_calls.cD12-May-202444 KiB1,225721

nir_lower_single_sampled.cD12-May-20244.5 KiB12981

nir_lower_ssbo.cD12-May-20247 KiB219146

nir_lower_subgroups.cD12-May-202431.8 KiB847580

nir_lower_system_values.cD12-May-202422.9 KiB589375

nir_lower_sysvals_to_varyings.cD12-May-20242.5 KiB7330

nir_lower_task_shader.cD12-May-202415.1 KiB433279

nir_lower_tex.cD12-May-202456.6 KiB1,6361,200

nir_lower_tex_shadow.cD12-May-20245.3 KiB155101

nir_lower_texcoord_replace.cD12-May-20245.5 KiB15399

nir_lower_to_source_mods.cD12-May-20247.3 KiB237146

nir_lower_two_sided_color.cD12-May-20246.9 KiB236158

nir_lower_ubo_vec4.cD12-May-20247.5 KiB19393

nir_lower_undef_to_zero.cD12-May-20242.5 KiB6420

nir_lower_uniforms_to_ubo.cD12-May-20246.8 KiB169100

nir_lower_var_copies.cD12-May-20245.9 KiB174111

nir_lower_variable_initializers.cD12-May-20247.1 KiB201131

nir_lower_vars_to_ssa.cD12-May-202426.4 KiB822503

nir_lower_vec3_to_vec4.cD12-May-20245.5 KiB170119

nir_lower_vec_to_movs.cD12-May-202410.4 KiB319179

nir_lower_viewport_transform.cD12-May-20244.3 KiB10644

nir_lower_wpos_center.cD12-May-20243.6 KiB11053

nir_lower_wpos_ytransform.cD12-May-202413.3 KiB365227

nir_lower_wrmasks.cD12-May-20247.5 KiB234123

nir_metadata.cD12-May-20243.6 KiB11458

nir_move_vec_src_uses_to_dest.cD12-May-20246.7 KiB214111

nir_normalize_cubemap_coords.cD12-May-20243.8 KiB11762

nir_opcodes.pyD12-May-202456.6 KiB1,5171,085

nir_opcodes_c.pyD12-May-20244.9 KiB12997

nir_opcodes_h.pyD12-May-20241.6 KiB4639

nir_opt_access.cD12-May-202413.5 KiB382292

nir_opt_algebraic.pyD12-May-2024156 KiB2,9051,826

nir_opt_barriers.cD12-May-20242.7 KiB8650

nir_opt_combine_stores.cD12-May-202415.9 KiB471325

nir_opt_comparison_pre.cD12-May-202412.5 KiB385201

nir_opt_conditional_discard.cD12-May-20244.7 KiB14992

nir_opt_constant_folding.cD12-May-202413.1 KiB406295

nir_opt_copy_prop_vars.cD12-May-202445.1 KiB1,330940

nir_opt_copy_propagate.cD12-May-20245.4 KiB198126

nir_opt_cse.cD12-May-20242.3 KiB8036

nir_opt_dce.cD12-May-20247.9 KiB252181

nir_opt_dead_cf.cD12-May-202414.4 KiB436236

nir_opt_dead_write_vars.cD12-May-20249.7 KiB286183

nir_opt_find_array_copies.cD12-May-202422.2 KiB686453

nir_opt_fragdepth.cD12-May-20243.8 KiB11259

nir_opt_gcm.cD12-May-202429.2 KiB869531

nir_opt_idiv_const.cD12-May-20248.7 KiB262200

nir_opt_if.cD12-May-202457.3 KiB1,765902

nir_opt_intrinsics.cD12-May-20247 KiB231153

nir_opt_large_constants.cD12-May-202413.6 KiB409282

nir_opt_load_store_vectorize.cD12-May-202454.4 KiB1,5441,197

nir_opt_loop_unroll.cD12-May-202441.6 KiB1,169659

nir_opt_memcpy.cD12-May-202410 KiB302203

nir_opt_move.cD12-May-20246.1 KiB17887

nir_opt_move_discards_to_top.cD12-May-20248.3 KiB253155

nir_opt_offsets.cD12-May-20248.3 KiB232160

nir_opt_peephole_select.cD12-May-202416.8 KiB526327

nir_opt_phi_precision.cD12-May-202414.1 KiB491262

nir_opt_preamble.cD12-May-202419 KiB598397

nir_opt_ray_queries.cD12-May-20244.7 KiB156104

nir_opt_rematerialize_compares.cD12-May-20245.9 KiB199125

nir_opt_remove_phis.cD12-May-20245.8 KiB18796

nir_opt_shrink_stores.cD12-May-20244.2 KiB13081

nir_opt_shrink_vectors.cD12-May-202410.8 KiB389246

nir_opt_sink.cD12-May-20247.7 KiB241147

nir_opt_trivial_continues.cD12-May-20244.8 KiB14083

nir_opt_undef.cD12-May-20245.7 KiB193119

nir_opt_uniform_atomics.cD12-May-202411.5 KiB348256

nir_opt_vectorize.cD12-May-202413.3 KiB420276

nir_phi_builder.cD12-May-202410.9 KiB302144

nir_phi_builder.hD12-May-20244.7 KiB12017

nir_print.cD12-May-202452.2 KiB1,8231,499

nir_propagate_invariant.cD12-May-20246.7 KiB233163

nir_range_analysis.cD12-May-202470 KiB1,9161,292

nir_range_analysis.hD12-May-20241.9 KiB6429

nir_remove_dead_variables.cD12-May-20247 KiB229154

nir_repair_ssa.cD12-May-20246.6 KiB211135

nir_scale_fdiv.cD12-May-20243 KiB7636

nir_schedule.cD12-May-202435.9 KiB1,221788

nir_schedule.hD12-May-20243.3 KiB9329

nir_search.cD12-May-202431.6 KiB973698

nir_search.hD12-May-20248.1 KiB254111

nir_search_helpers.hD12-May-202419 KiB603458

nir_serialize.cD12-May-202467.3 KiB2,2371,755

nir_serialize.hD12-May-20241.6 KiB4415

nir_split_64bit_vec3_and_vec4.cD12-May-202411.1 KiB332241

nir_split_per_member_structs.cD12-May-20246.5 KiB202144

nir_split_var_copies.cD12-May-20245.5 KiB14267

nir_split_vars.cD12-May-202458.2 KiB1,7081,245

nir_sweep.cD12-May-20245 KiB176102

nir_to_lcssa.cD12-May-202413.1 KiB423282

nir_validate.cD12-May-202462.3 KiB1,8531,370

nir_vla.hD12-May-20242.1 KiB5710

nir_vulkan.hD12-May-2024374 139

nir_worklist.cD12-May-20241.7 KiB5421

nir_worklist.hD12-May-20244.2 KiB14879

nir_xfb_info.hD12-May-20242.7 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