• Home
Name Date Size #Lines LOC

..--

tests/06-Sep-2024-10,0895,784

.clang-formatD06-Sep-2024155 75

READMED06-Sep-20245.7 KiB11998

meson.buildD06-Sep-202411.5 KiB397374

nir.cD06-Sep-2024100.4 KiB3,4302,692

nir.hD06-Sep-2024216.4 KiB6,6903,564

nir_algebraic.pyD06-Sep-202449.5 KiB1,280956

nir_builder.cD06-Sep-202418.7 KiB629476

nir_builder.hD06-Sep-202461.9 KiB2,0921,644

nir_builder_opcodes_h.pyD06-Sep-20247.8 KiB242212

nir_builtin_builder.cD06-Sep-202415 KiB433256

nir_builtin_builder.hD06-Sep-20247.3 KiB271199

nir_clone.cD06-Sep-202423.6 KiB800543

nir_constant_expressions.hD06-Sep-20241.6 KiB398

nir_constant_expressions.pyD06-Sep-202418.7 KiB636582

nir_control_flow.cD06-Sep-202426.1 KiB863579

nir_control_flow.hD06-Sep-20247.1 KiB18666

nir_control_flow_private.hD06-Sep-20241.5 KiB416

nir_conversion_builder.hD06-Sep-202417.9 KiB522393

nir_deref.cD06-Sep-202449.4 KiB1,5721,073

nir_deref.hD06-Sep-20243 KiB8339

nir_divergence_analysis.cD06-Sep-202442 KiB1,172949

nir_dominance.cD06-Sep-20249.1 KiB341213

nir_format_convert.hD06-Sep-202415.1 KiB465341

nir_from_ssa.cD06-Sep-202442.6 KiB1,290760

nir_functions.cD06-Sep-202417.5 KiB510325

nir_gather_info.cD06-Sep-202440.1 KiB1,053865

nir_gather_types.cD06-Sep-20246.9 KiB196141

nir_gather_xfb_info.cD06-Sep-202417.3 KiB484340

nir_group_loads.cD06-Sep-202416 KiB485296

nir_gs_count_vertices.cD06-Sep-20244.7 KiB12568

nir_inline_helpers.hD06-Sep-20244.3 KiB146130

nir_inline_uniforms.cD06-Sep-202417.9 KiB473258

nir_instr_set.cD06-Sep-202424.3 KiB799581

nir_instr_set.hD06-Sep-20242.8 KiB7110

nir_intrinsics.pyD06-Sep-202494.8 KiB2,189851

nir_intrinsics_c.pyD06-Sep-20242.9 KiB8978

nir_intrinsics_h.pyD06-Sep-20242.2 KiB7054

nir_intrinsics_indices_h.pyD06-Sep-20243.1 KiB9782

nir_legacy.cD06-Sep-202410.4 KiB341239

nir_legacy.hD06-Sep-20242.4 KiB9847

nir_linking_helpers.cD06-Sep-202459.5 KiB1,6951,158

nir_liveness.cD06-Sep-202410.9 KiB328178

nir_loop_analyze.cD06-Sep-202452 KiB1,5891,085

nir_loop_analyze.hD06-Sep-20243.9 KiB12169

nir_lower_alpha_test.cD06-Sep-20243.8 KiB11366

nir_lower_alu.cD06-Sep-20249.1 KiB237145

nir_lower_alu_width.cD06-Sep-202417.3 KiB500358

nir_lower_amul.cD06-Sep-20248.3 KiB278163

nir_lower_array_deref_of_vec.cD06-Sep-20246 KiB16097

nir_lower_atomics_to_ssbo.cD06-Sep-20249.2 KiB258168

nir_lower_bit_size.cD06-Sep-202412.6 KiB369262

nir_lower_bitmap.cD06-Sep-20244.4 KiB12254

nir_lower_blend.cD06-Sep-202420.7 KiB655436

nir_lower_blend.hD06-Sep-20242.1 KiB6625

nir_lower_bool_to_bitsize.cD06-Sep-202413.6 KiB420302

nir_lower_bool_to_float.cD06-Sep-20247 KiB268213

nir_lower_bool_to_int32.cD06-Sep-20246.2 KiB236188

nir_lower_cl_images.cD06-Sep-20249.9 KiB297234

nir_lower_clamp_color_outputs.cD06-Sep-20243.2 KiB10774

nir_lower_clip.cD06-Sep-202416.1 KiB507352

nir_lower_clip_cull_distance_arrays.cD06-Sep-202417.9 KiB532326

nir_lower_clip_disable.cD06-Sep-20245 KiB13273

nir_lower_clip_halfz.cD06-Sep-20242.5 KiB6737

nir_lower_const_arrays_to_uniforms.cD06-Sep-202413.8 KiB418266

nir_lower_continue_constructs.cD06-Sep-20245.5 KiB172105

nir_lower_convert_alu_types.cD06-Sep-20246.2 KiB207149

nir_lower_discard_if.cD06-Sep-20243.7 KiB12550

nir_lower_discard_or_demote.cD06-Sep-20247.3 KiB188123

nir_lower_double_ops.cD06-Sep-202426.4 KiB839511

nir_lower_drawpixels.cD06-Sep-20248.9 KiB259182

nir_lower_fb_read.cD06-Sep-20243.8 KiB9439

nir_lower_flatshade.cD06-Sep-20241.8 KiB5223

nir_lower_flrp.cD06-Sep-202421.1 KiB657310

nir_lower_fp16_conv.cD06-Sep-202413.8 KiB347227

nir_lower_frag_coord_to_pixel_coord.cD06-Sep-20241.1 KiB3724

nir_lower_fragcolor.cD06-Sep-20244 KiB10446

nir_lower_fragcoord_wtrans.cD06-Sep-20242.7 KiB7938

nir_lower_frexp.cD06-Sep-20246.7 KiB196114

nir_lower_global_vars_to_local.cD06-Sep-20243.5 KiB10961

nir_lower_goto_ifs.cD06-Sep-202433.1 KiB986689

nir_lower_gs_intrinsics.cD06-Sep-202419.6 KiB544322

nir_lower_helper_writes.cD06-Sep-20243.9 KiB10955

nir_lower_idiv.cD06-Sep-20246.5 KiB186117

nir_lower_image.cD06-Sep-20248.2 KiB224145

nir_lower_image_atomics_to_global.cD06-Sep-20243.6 KiB10570

nir_lower_indirect_derefs.cD06-Sep-20248.3 KiB244166

nir_lower_input_attachments.cD06-Sep-20247.7 KiB222149

nir_lower_int64.cD06-Sep-202444.7 KiB1,4211,075

nir_lower_int_to_float.cD06-Sep-20248.7 KiB326249

nir_lower_interpolation.cD06-Sep-20244.5 KiB13277

nir_lower_io.cD06-Sep-2024115.3 KiB3,2672,523

nir_lower_io_arrays_to_elements.cD06-Sep-202414.7 KiB432289

nir_lower_io_to_scalar.cD06-Sep-202420.5 KiB583416

nir_lower_io_to_temporaries.cD06-Sep-202413.4 KiB385235

nir_lower_io_to_vector.cD06-Sep-202423.8 KiB721524

nir_lower_is_helper_invocation.cD06-Sep-20244.4 KiB11967

nir_lower_load_const_to_scalar.cD06-Sep-20243.2 KiB9950

nir_lower_locals_to_regs.cD06-Sep-202410.1 KiB320216

nir_lower_mediump.cD06-Sep-202434.6 KiB1,067816

nir_lower_mem_access_bit_sizes.cD06-Sep-202418.2 KiB465349

nir_lower_memcpy.cD06-Sep-20247 KiB202139

nir_lower_memory_model.cD06-Sep-20247.8 KiB250200

nir_lower_multiview.cD06-Sep-202410.5 KiB316181

nir_lower_non_uniform_access.cD06-Sep-202411.1 KiB342235

nir_lower_packing.cD06-Sep-20246.4 KiB194136

nir_lower_passthrough_edgeflags.cD06-Sep-20243.6 KiB10256

nir_lower_patch_vertices.cD06-Sep-20243.4 KiB10249

nir_lower_phis_to_scalar.cD06-Sep-202410.5 KiB302150

nir_lower_pntc_ytransform.cD06-Sep-20244.5 KiB12980

nir_lower_point_size.cD06-Sep-20243 KiB8334

nir_lower_point_size_mov.cD06-Sep-20244.2 KiB10965

nir_lower_point_smooth.cD06-Sep-20243.8 KiB10452

nir_lower_poly_line_smooth.cD06-Sep-20243 KiB8843

nir_lower_printf.cD06-Sep-20245.1 KiB12779

nir_lower_readonly_images_to_tex.cD06-Sep-20247.7 KiB232155

nir_lower_reg_intrinsics_to_ssa.cD06-Sep-20245.3 KiB186138

nir_lower_returns.cD06-Sep-202410.2 KiB313182

nir_lower_robust_access.cD06-Sep-20246.2 KiB217168

nir_lower_samplers.cD06-Sep-20245.2 KiB15281

nir_lower_scratch.cD06-Sep-20247.7 KiB234154

nir_lower_shader_calls.cD06-Sep-202473.5 KiB2,1041,365

nir_lower_single_sampled.cD06-Sep-20244.4 KiB12478

nir_lower_ssbo.cD06-Sep-20242.4 KiB7653

nir_lower_subgroups.cD06-Sep-202440.6 KiB1,100776

nir_lower_system_values.cD06-Sep-202430.1 KiB798532

nir_lower_sysvals_to_varyings.cD06-Sep-20242.7 KiB7330

nir_lower_task_shader.cD06-Sep-202416.8 KiB479299

nir_lower_tess_coord_z.cD06-Sep-20241 KiB4130

nir_lower_tex.cD06-Sep-202461.1 KiB1,8231,325

nir_lower_tex_shadow.cD06-Sep-20245.2 KiB156102

nir_lower_texcoord_replace.cD06-Sep-20245 KiB14290

nir_lower_texcoord_replace_late.cD06-Sep-20243.2 KiB10778

nir_lower_two_sided_color.cD06-Sep-20245.9 KiB191125

nir_lower_ubo_vec4.cD06-Sep-20247.4 KiB19292

nir_lower_undef_to_zero.cD06-Sep-20242.5 KiB6521

nir_lower_uniforms_to_ubo.cD06-Sep-20246.7 KiB17299

nir_lower_var_copies.cD06-Sep-20245.3 KiB14592

nir_lower_variable_initializers.cD06-Sep-202410.5 KiB290193

nir_lower_vars_to_ssa.cD06-Sep-202428.9 KiB885534

nir_lower_vec3_to_vec4.cD06-Sep-20244.8 KiB154105

nir_lower_vec_to_regs.cD06-Sep-20248.6 KiB264152

nir_lower_viewport_transform.cD06-Sep-20244 KiB9938

nir_lower_wpos_center.cD06-Sep-20243.1 KiB8634

nir_lower_wpos_ytransform.cD06-Sep-202412.6 KiB346210

nir_lower_wrmasks.cD06-Sep-20247.4 KiB233122

nir_metadata.cD06-Sep-20243.4 KiB10552

nir_mod_analysis.cD06-Sep-20245.7 KiB185120

nir_move_vec_src_uses_to_dest.cD06-Sep-20246.8 KiB206111

nir_normalize_cubemap_coords.cD06-Sep-20242.6 KiB7535

nir_opcodes.pyD06-Sep-202463.5 KiB1,6441,225

nir_opcodes_c.pyD06-Sep-20245.1 KiB134101

nir_opcodes_h.pyD06-Sep-20241.6 KiB4639

nir_opt_access.cD06-Sep-202411.7 KiB342253

nir_opt_algebraic.pyD06-Sep-2024182.7 KiB3,3702,159

nir_opt_barriers.cD06-Sep-20248.3 KiB250153

nir_opt_combine_stores.cD06-Sep-202414.5 KiB435294

nir_opt_comparison_pre.cD06-Sep-202412.9 KiB408214

nir_opt_conditional_discard.cD06-Sep-20244.4 KiB14185

nir_opt_constant_folding.cD06-Sep-202413.5 KiB422312

nir_opt_copy_prop_vars.cD06-Sep-202452.2 KiB1,5351,069

nir_opt_copy_propagate.cD06-Sep-20244.9 KiB182114

nir_opt_cse.cD06-Sep-20242.2 KiB7335

nir_opt_dce.cD06-Sep-20248.3 KiB261188

nir_opt_dead_cf.cD06-Sep-202414.4 KiB432233

nir_opt_dead_write_vars.cD06-Sep-20248.8 KiB261162

nir_opt_find_array_copies.cD06-Sep-202422.2 KiB686453

nir_opt_fragdepth.cD06-Sep-20244.2 KiB12669

nir_opt_gcm.cD06-Sep-202429.9 KiB880533

nir_opt_idiv_const.cD06-Sep-20247.7 KiB230175

nir_opt_if.cD06-Sep-202444.7 KiB1,355710

nir_opt_intrinsics.cD06-Sep-202412.9 KiB404289

nir_opt_large_constants.cD06-Sep-202419.5 KiB601425

nir_opt_load_store_vectorize.cD06-Sep-202450.5 KiB1,4751,129

nir_opt_loop.cD06-Sep-202410.6 KiB360183

nir_opt_loop_unroll.cD06-Sep-202441.6 KiB1,156647

nir_opt_memcpy.cD06-Sep-20249.8 KiB299200

nir_opt_move.cD06-Sep-20245.4 KiB14965

nir_opt_move_discards_to_top.cD06-Sep-20249.6 KiB278182

nir_opt_non_uniform_access.cD06-Sep-20247.3 KiB245186

nir_opt_offsets.cD06-Sep-20248 KiB228156

nir_opt_peephole_select.cD06-Sep-202417.9 KiB557357

nir_opt_phi_precision.cD06-Sep-202413.5 KiB472250

nir_opt_preamble.cD06-Sep-202431.7 KiB977625

nir_opt_ray_queries.cD06-Sep-202413.2 KiB423272

nir_opt_reassociate_bfi.cD06-Sep-20245.1 KiB14559

nir_opt_rematerialize_compares.cD06-Sep-202410 KiB328220

nir_opt_remove_phis.cD06-Sep-20245.6 KiB17588

nir_opt_reuse_constants.cD06-Sep-20241.3 KiB5036

nir_opt_shrink_stores.cD06-Sep-20243.9 KiB12476

nir_opt_shrink_vectors.cD06-Sep-202415.6 KiB555361

nir_opt_sink.cD06-Sep-20249.4 KiB289174

nir_opt_undef.cD06-Sep-202410.2 KiB328197

nir_opt_uniform_atomics.cD06-Sep-202411.6 KiB370274

nir_opt_uniform_subgroup.cD06-Sep-20245.1 KiB162114

nir_opt_vectorize.cD06-Sep-202412.5 KiB402260

nir_passthrough_gs.cD06-Sep-20249.8 KiB275214

nir_passthrough_tcs.cD06-Sep-20244.6 KiB11661

nir_phi_builder.cD06-Sep-202410.9 KiB306148

nir_phi_builder.hD06-Sep-20244.7 KiB12017

nir_print.cD06-Sep-202478.9 KiB2,7112,258

nir_propagate_invariant.cD06-Sep-20246.4 KiB225155

nir_range_analysis.cD06-Sep-202476.8 KiB2,2041,535

nir_range_analysis.hD06-Sep-20241.9 KiB6630

nir_remove_dead_variables.cD06-Sep-20246.8 KiB220147

nir_remove_tex_shadow.cD06-Sep-20243.6 KiB10970

nir_repair_ssa.cD06-Sep-20246 KiB193119

nir_scale_fdiv.cD06-Sep-20243 KiB8039

nir_schedule.cD06-Sep-202438 KiB1,282853

nir_schedule.hD06-Sep-20243.3 KiB9329

nir_search.cD06-Sep-202430.7 KiB944687

nir_search.hD06-Sep-20247.7 KiB240101

nir_search_helpers.hD06-Sep-202423.2 KiB744571

nir_serialize.cD06-Sep-202465.1 KiB2,1671,693

nir_serialize.hD06-Sep-20241.9 KiB5221

nir_split_64bit_vec3_and_vec4.cD06-Sep-202410.9 KiB327239

nir_split_per_member_structs.cD06-Sep-20246.2 KiB192133

nir_split_var_copies.cD06-Sep-20245 KiB11147

nir_split_vars.cD06-Sep-202460.1 KiB1,7471,277

nir_sweep.cD06-Sep-20245.2 KiB185111

nir_to_lcssa.cD06-Sep-202412.5 KiB408271

nir_trivialize_registers.cD06-Sep-202417 KiB511272

nir_validate.cD06-Sep-202459 KiB1,7401,279

nir_vla.hD06-Sep-20242.1 KiB5410

nir_worklist.cD06-Sep-20241.6 KiB4720

nir_worklist.hD06-Sep-20244.1 KiB14480

nir_xfb_info.hD06-Sep-20242.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