Lines Matching defs:nir
32 #include "compiler/nir/nir_builder.h"
33 #include "nir/nir_serialize.h"
67 .module = vk_shader_module_handle_from_nir(p_stage->nir),
69 .stage = mesa_to_vk_shader_stage(p_stage->nir->info.stage),
96 ralloc_free(p_stage->nir);
256 NIR_PASS(this_progress, nir, pass, ##__VA_ARGS__); \
263 nir_optimize(nir_shader *nir, bool allow_copies)
319 if (nir_opt_trivial_continues(nir)) {
360 preprocess_nir(nir_shader *nir)
366 NIR_PASS(_, nir, nir_lower_sysvals_to_varyings, &sysvals_to_varyings);
369 nir->info.separate_shader = true;
374 NIR_PASS(_, nir, nir_lower_variable_initializers, nir_var_shader_out);
376 if (nir->info.stage == MESA_SHADER_FRAGMENT)
377 NIR_PASS(_, nir, nir_lower_io_to_vector, nir_var_shader_out);
378 if (nir->info.stage == MESA_SHADER_FRAGMENT) {
379 NIR_PASS(_, nir, nir_lower_input_attachments,
385 NIR_PASS_V(nir, nir_lower_io_to_temporaries,
386 nir_shader_get_entrypoint(nir), true, false);
388 NIR_PASS(_, nir, nir_lower_system_values);
390 NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL);
392 NIR_PASS(_, nir, nir_normalize_cubemap_coords);
394 NIR_PASS(_, nir, nir_lower_global_vars_to_local);
396 NIR_PASS(_, nir, nir_split_var_copies);
397 NIR_PASS(_, nir, nir_split_struct_vars, nir_var_function_temp);
399 nir_optimize(nir, true);
401 NIR_PASS(_, nir, nir_lower_explicit_io,
405 NIR_PASS(_, nir, nir_lower_explicit_io,
409 NIR_PASS(_, nir, nir_lower_explicit_io,
413 NIR_PASS(_, nir, nir_lower_load_const_to_scalar);
416 NIR_PASS(_, nir, nir_lower_var_copies);
418 NIR_PASS(_, nir, nir_lower_indirect_derefs, nir_var_shader_in, UINT32_MAX);
420 NIR_PASS(_, nir, nir_lower_indirect_derefs,
423 NIR_PASS(_, nir, nir_lower_array_deref_of_vec,
427 NIR_PASS(_, nir, nir_lower_frexp);
430 nir_optimize(nir, false);
437 nir_shader *nir;
441 if (unlikely(V3D_DEBUG & V3D_DEBUG_DUMP_SPIRV) && stage->module->nir == NULL)
444 /* vk_shader_module_to_nir also handles internal shaders, when module->nir
454 NULL, &nir);
457 assert(nir->info.stage == broadcom_shader_stage_to_gl(stage->stage));
459 if (unlikely(V3D_DEBUG & V3D_DEBUG_SHADERDB) && stage->module->nir == NULL) {
462 nir->info.name = ralloc_strdup(nir, sha1buf);
471 nir_print_shader(nir, stderr);
475 preprocess_nir(nir);
477 return nir;
977 lower_fs_io(nir_shader *nir)
980 NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
981 NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_shader_out, NULL);
983 nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
986 nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
989 NIR_PASS(_, nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
994 lower_gs_io(struct nir_shader *nir)
996 NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
998 nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
1001 nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
1006 lower_vs_io(struct nir_shader *nir)
1008 NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
1010 nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
1013 nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
1227 if (p_stage->nir->info.fs.untyped_color_outputs) {
1274 p_stage->nir->info.outputs_written & (1ull << VARYING_SLOT_PSIZ);
1430 p_stage->nir = NULL;
1658 nir_print_shader(p_stage->nir, stderr);
1670 p_stage->nir,
1690 /* At this point we don't need anymore the nir shader, but we are freeing
1692 * we finish it, so let's not worry about freeing the nir here.
1748 nir_shader_gather_info(p_stage->nir, nir_shader_get_entrypoint(p_stage->nir));
1769 NIR_PASS(_, p_stage->nir, lower_pipeline_layout_info, pipeline, layout,
1791 const nir_shader *shader = p_stage->nir;
1810 nir_shader *nir = NULL;
1812 nir = v3dv_pipeline_cache_search_for_nir(pipeline, cache,
1816 if (nir) {
1817 assert(nir->info.stage == broadcom_shader_stage_to_gl(p_stage->stage));
1826 return nir;
1829 nir = shader_module_compile_to_nir(pipeline->device, p_stage);
1831 if (nir) {
1835 v3dv_pipeline_cache_upload_nir(pipeline, cache, nir,
1842 v3dv_pipeline_cache_upload_nir(pipeline, default_cache, nir,
1848 return nir;
1861 if (pipeline->vs_bin->nir == NULL) {
1862 assert(pipeline->vs->nir);
1863 pipeline->vs_bin->nir = nir_shader_clone(NULL, pipeline->vs->nir);
1891 if (pipeline->gs_bin->nir == NULL) {
1892 assert(pipeline->gs->nir);
1893 pipeline->gs_bin->nir = nir_shader_clone(NULL, pipeline->gs->nir);
2210 pipeline->vs->nir = pipeline_stage_get_nir(pipeline->vs, pipeline, cache);
2211 nir_shader *vs_nir = pipeline->vs->nir;
2216 nir_shader *nir = b.shader;
2217 nir->info.inputs_read = vs_nir->info.outputs_written;
2218 nir->info.outputs_written = vs_nir->info.outputs_written |
2222 nir->info.gs.input_primitive =
2224 nir->info.gs.output_primitive =
2226 nir->info.gs.vertices_in = vertex_count;
2227 nir->info.gs.vertices_out = nir->info.gs.vertices_in;
2228 nir->info.gs.invocations = 1;
2229 nir->info.gs.active_stream_mask = 0x1;
2240 nir_variable_create(nir, nir_var_shader_in,
2249 nir_variable_create(nir, nir_var_shader_out, out_vs_var->type, name);
2258 nir_variable_create(nir, nir_var_shader_out, glsl_int_type(),
2285 preprocess_nir(nir);
2297 ralloc_free(nir);
2305 p_stage->nir = nir;
2394 * worry about getting the nir shader for now.
2396 p_stage->nir = NULL;
2442 p_stage->nir = b.shader;
2515 if (!pipeline->vs->nir)
2516 pipeline->vs->nir = pipeline_stage_get_nir(pipeline->vs, pipeline, cache);
2517 if (pipeline->gs && !pipeline->gs->nir)
2518 pipeline->gs->nir = pipeline_stage_get_nir(pipeline->gs, pipeline, cache);
2519 if (!pipeline->fs->nir)
2520 pipeline->fs->nir = pipeline_stage_get_nir(pipeline->fs, pipeline, cache);
2524 link_shaders(pipeline->gs->nir, pipeline->fs->nir);
2525 link_shaders(pipeline->vs->nir, pipeline->gs->nir);
2527 link_shaders(pipeline->vs->nir, pipeline->fs->nir);
2531 lower_fs_io(pipeline->fs->nir);
2535 lower_gs_io(pipeline->gs->nir);
2539 lower_vs_io(pipeline->vs->nir);
3130 lower_cs_shared(struct nir_shader *nir)
3132 NIR_PASS(_, nir, nir_lower_vars_to_explicit_types,
3134 NIR_PASS(_, nir, nir_lower_explicit_io,
3172 p_stage->nir = NULL;
3214 p_stage->nir = pipeline_stage_get_nir(p_stage, pipeline, cache);
3215 assert(p_stage->nir);
3217 nir_optimize(p_stage->nir, false);
3219 lower_cs_shared(p_stage->nir);
3363 return pipeline->vs->nir;
3367 return pipeline->vs_bin->nir;
3371 return pipeline->gs->nir;
3375 return pipeline->gs_bin->nir;
3379 return pipeline->fs->nir;
3383 return pipeline->cs->nir;
3491 nir_shader *nir = pipeline_get_nir(pipeline, s);
3492 char *nir_str = nir ?
3493 nir_shader_as_str(nir, pipeline->executables.mem_ctx) : NULL;