Lines Matching full:nir
14 #include "nir.h"
123 hk_preprocess_nir_internal(struct vk_physical_device *vk_pdev, nir_shader *nir) in hk_preprocess_nir_internal() argument
126 if (nir->info.stage == MESA_SHADER_FRAGMENT) { in hk_preprocess_nir_internal()
127 NIR_PASS(_, nir, nir_lower_terminate_to_demote); in hk_preprocess_nir_internal()
128 NIR_PASS(_, nir, nir_shader_instructions_pass, lower_halt_to_return, in hk_preprocess_nir_internal()
130 NIR_PASS(_, nir, nir_lower_returns); in hk_preprocess_nir_internal()
135 NIR_PASS(_, nir, nir_lower_global_vars_to_local); in hk_preprocess_nir_internal()
139 NIR_PASS(progress, nir, nir_lower_vars_to_ssa); in hk_preprocess_nir_internal()
140 NIR_PASS(progress, nir, nir_copy_prop); in hk_preprocess_nir_internal()
141 NIR_PASS(progress, nir, nir_opt_dce); in hk_preprocess_nir_internal()
142 NIR_PASS(progress, nir, nir_opt_constant_folding); in hk_preprocess_nir_internal()
143 NIR_PASS(progress, nir, nir_opt_loop); in hk_preprocess_nir_internal()
144 NIR_PASS(progress, nir, nir_opt_loop_unroll); in hk_preprocess_nir_internal()
147 if (nir->info.stage == MESA_SHADER_FRAGMENT) { in hk_preprocess_nir_internal()
152 nir_lower_sysvals_to_varyings(nir, &sysvals_opts); in hk_preprocess_nir_internal()
155 NIR_PASS(_, nir, nir_lower_system_values); in hk_preprocess_nir_internal()
160 nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); in hk_preprocess_nir_internal()
162 NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), in hk_preprocess_nir_internal()
165 NIR_PASS(_, nir, nir_lower_global_vars_to_local); in hk_preprocess_nir_internal()
167 NIR_PASS(_, nir, nir_split_var_copies); in hk_preprocess_nir_internal()
168 NIR_PASS(_, nir, nir_split_struct_vars, nir_var_function_temp); in hk_preprocess_nir_internal()
171 agx_preprocess_nir(nir, NULL); in hk_preprocess_nir_internal()
173 NIR_PASS(_, nir, nir_lower_load_const_to_scalar); in hk_preprocess_nir_internal()
174 NIR_PASS(_, nir, nir_lower_var_copies); in hk_preprocess_nir_internal()
178 hk_preprocess_nir(struct vk_physical_device *vk_pdev, nir_shader *nir) in hk_preprocess_nir() argument
180 hk_preprocess_nir_internal(vk_pdev, nir); in hk_preprocess_nir()
184 NIR_PASS(_, nir, nir_lower_compute_system_values, &csv_options); in hk_preprocess_nir()
395 hk_lower_multiview(nir_shader *nir) in hk_lower_multiview() argument
401 nir, nir_var_shader_out, VARYING_SLOT_LAYER); in hk_lower_multiview()
406 nir_fixup_deref_modes(nir); in hk_lower_multiview()
411 nir_builder_at(nir_after_impl(nir_shader_get_entrypoint(nir))); in hk_lower_multiview()
414 nir_variable_create(nir, nir_var_shader_out, glsl_uint_type(), NULL); in hk_lower_multiview()
428 hk_nir_insert_psiz_write(nir_shader *nir) in hk_nir_insert_psiz_write() argument
430 nir_function_impl *impl = nir_shader_get_entrypoint(nir); in hk_nir_insert_psiz_write()
432 if (nir->info.outputs_written & VARYING_BIT_PSIZ) { in hk_nir_insert_psiz_write()
444 nir->info.outputs_written |= VARYING_BIT_PSIZ; in hk_nir_insert_psiz_write()
533 agx_nir_lower_custom_border(nir_shader *nir) in agx_nir_lower_custom_border() argument
535 return nir_shader_instructions_pass(nir, lower, nir_metadata_none, NULL); in agx_nir_lower_custom_border()
593 hk_lower_nir(struct hk_device *dev, nir_shader *nir, in hk_lower_nir() argument
605 NIR_PASS_V(nir, nir_opt_access, &access_options); in hk_lower_nir()
607 if (nir->info.stage == MESA_SHADER_FRAGMENT) { in hk_lower_nir()
608 NIR_PASS(_, nir, nir_lower_input_attachments, in hk_lower_nir()
615 NIR_PASS(_, nir, nir_shader_instructions_pass, lower_subpass_dim, in hk_lower_nir()
617 NIR_PASS(_, nir, nir_lower_wpos_center); in hk_lower_nir()
621 if (nir->info.stage == MESA_SHADER_VERTEX) { in hk_lower_nir()
623 hk_lower_multiview(nir); in hk_lower_nir()
626 if (nir->info.stage == MESA_SHADER_TESS_EVAL) { in hk_lower_nir()
627 NIR_PASS(_, nir, nir_lower_patch_vertices, in hk_lower_nir()
628 nir->info.tess.tcs_vertices_out, NULL); in hk_lower_nir()
635 NIR_PASS(_, nir, nir_vk_lower_ycbcr_tex, lookup_ycbcr_conversion, in hk_lower_nir()
639 NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_push_const, in hk_lower_nir()
642 // NIR_PASS(_, nir, nir_opt_large_constants, NULL, 32); in hk_lower_nir()
645 NIR_PASS(_, nir, nir_lower_memory_model); in hk_lower_nir()
647 NIR_PASS(_, nir, nir_lower_robust_access, should_lower_robust, NULL); in hk_lower_nir()
652 NIR_PASS(_, nir, agx_nir_lower_texture_early, true /* support_lod_bias */); in hk_lower_nir()
655 NIR_PASS(_, nir, agx_nir_lower_custom_border); in hk_lower_nir()
658 NIR_PASS(_, nir, hk_nir_lower_descriptors, rs, set_layout_count, in hk_lower_nir()
660 NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_global, in hk_lower_nir()
662 NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_ssbo, in hk_lower_nir()
664 NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_ubo, in hk_lower_nir()
674 NIR_PASS(progress, nir, nir_opt_constant_folding); in hk_lower_nir()
675 NIR_PASS(progress, nir, nir_opt_algebraic); in hk_lower_nir()
676 NIR_PASS(progress, nir, nir_copy_prop); in hk_lower_nir()
677 NIR_PASS(progress, nir, nir_opt_dce); in hk_lower_nir()
681 NIR_PASS(_, nir, nir_shader_intrinsics_pass, in hk_lower_nir()
685 if (!nir->info.shared_memory_explicit_layout) { in hk_lower_nir()
690 nir->info.shared_size = 0; in hk_lower_nir()
692 NIR_PASS(_, nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared, in hk_lower_nir()
695 NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_shared, in hk_lower_nir()
698 if (nir->info.zero_initialize_shared_memory && nir->info.shared_size > 0) { in hk_lower_nir()
700 nir->info.shared_size = align(nir->info.shared_size, 16); in hk_lower_nir()
701 NIR_PASS(_, nir, nir_zero_initialize_shared_memory, nir->info.shared_size, in hk_lower_nir()
708 NIR_PASS(_, nir, nir_lower_compute_system_values, NULL); in hk_lower_nir()
713 if (nir->info.stage == MESA_SHADER_FRAGMENT) in hk_lower_nir()
715 else if (nir->info.stage == MESA_SHADER_VERTEX) in hk_lower_nir()
718 NIR_PASS(_, nir, nir_lower_indirect_derefs, lower_indirect_modes, in hk_lower_nir()
721 NIR_PASS(_, nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out, in hk_lower_nir()
726 if (nir->info.stage == MESA_SHADER_FRAGMENT) { in hk_lower_nir()
727 NIR_PASS(_, nir, nir_shader_intrinsics_pass, lower_viewport_fs, in hk_lower_nir()
731 NIR_PASS(_, nir, agx_nir_lower_texture); in hk_lower_nir()
732 NIR_PASS(_, nir, agx_nir_lower_multisampled_image_store); in hk_lower_nir()
734 agx_preprocess_nir(nir, dev->dev.libagx); in hk_lower_nir()
735 NIR_PASS(_, nir, nir_opt_conditional_discard); in hk_lower_nir()
736 NIR_PASS(_, nir, nir_opt_if, in hk_lower_nir()
797 nir_shader *nir, VkShaderCreateFlagsEXT shader_flags, in hk_compile_nir() argument
810 shader->info.fs.interp = agx_gather_interp_info(nir); in hk_compile_nir()
811 shader->info.fs.writes_memory = nir->info.writes_memory; in hk_compile_nir()
814 NIR_PASS(_, nir, agx_nir_lower_discard_zs_emit); in hk_compile_nir()
815 NIR_PASS(_, nir, agx_nir_lower_fs_output_to_epilog, in hk_compile_nir()
817 NIR_PASS(_, nir, agx_nir_lower_sample_mask); in hk_compile_nir()
819 if (nir->info.fs.uses_sample_shading) { in hk_compile_nir()
822 nir_builder_at(nir_after_impl(nir_shader_get_entrypoint(nir))); in hk_compile_nir()
829 NIR_PASS(_, nir, agx_nir_lower_to_per_sample); in hk_compile_nir()
832 NIR_PASS(_, nir, agx_nir_lower_fs_active_samples_to_register); in hk_compile_nir()
833 NIR_PASS(_, nir, agx_nir_lower_interpolation); in hk_compile_nir()
837 shader->info.tess.info.ccw = nir->info.tess.ccw; in hk_compile_nir()
838 shader->info.tess.info.points = nir->info.tess.point_mode; in hk_compile_nir()
839 shader->info.tess.info.spacing = nir->info.tess.spacing; in hk_compile_nir()
840 shader->info.tess.info.mode = nir->info.tess._primitive_mode; in hk_compile_nir()
844 nir->info.tess.tcs_vertices_out; in hk_compile_nir()
846 agx_tcs_per_vertex_outputs(nir); in hk_compile_nir()
848 util_last_bit(nir->info.patch_outputs_written); in hk_compile_nir()
849 shader->info.tess.tcs_output_stride = agx_tcs_output_stride(nir); in hk_compile_nir()
852 NIR_PASS(_, nir, agx_nir_lower_tes, dev->dev.libagx, hw); in hk_compile_nir()
856 uint64_t outputs = nir->info.outputs_written; in hk_compile_nir()
859 nir->info.stage = MESA_SHADER_COMPUTE; in hk_compile_nir()
860 memset(&nir->info.cs, 0, sizeof(nir->info.cs)); in hk_compile_nir()
861 nir->xfb_info = NULL; in hk_compile_nir()
865 NIR_PASS(_, nir, hk_lower_uvs_index, vs_uniform_base); in hk_compile_nir()
880 .no_stop = nir->info.stage == MESA_SHADER_FRAGMENT, in hk_compile_nir()
881 .has_scratch = !nir->info.internal, in hk_compile_nir()
886 if (nir->info.stage == MESA_SHADER_FRAGMENT && in hk_compile_nir()
887 nir->info.fs.uses_sample_shading) in hk_compile_nir()
897 agx_compile_shader_nir(nir, &backend_key, NULL, &shader->b); in hk_compile_nir()
906 shader->info.clip_distance_array_size = nir->info.clip_distance_array_size; in hk_compile_nir()
907 shader->info.cull_distance_array_size = nir->info.cull_distance_array_size; in hk_compile_nir()
916 typed_memcpy(shader->info.xfb_stride, nir->info.xfb_stride, 4); in hk_compile_nir()
919 if (nir->constant_data_size > 0) { in hk_compile_nir()
920 uint32_t data_size = align(nir->constant_data_size, HK_MIN_UBO_ALIGNMENT); in hk_compile_nir()
924 ralloc_free(nir); in hk_compile_nir()
928 memcpy(data, nir->constant_data, nir->constant_data_size); in hk_compile_nir()
930 assert(nir->constant_data_size <= data_size); in hk_compile_nir()
931 memset(data + nir->constant_data_size, 0, in hk_compile_nir()
932 data_size - nir->constant_data_size); in hk_compile_nir()
938 ralloc_free(nir); in hk_compile_nir()
993 hk_lower_hw_vs(nir_shader *nir, struct hk_shader *shader) in hk_lower_hw_vs() argument
1000 NIR_PASS(_, nir, nir_lower_point_size, 1.0f, 511.95f); in hk_lower_hw_vs()
1003 NIR_PASS(_, nir, hk_nir_insert_psiz_write); in hk_lower_hw_vs()
1005 NIR_PASS(_, nir, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); in hk_lower_hw_vs()
1006 NIR_PASS(_, nir, agx_nir_lower_cull_distance_vs); in hk_lower_hw_vs()
1008 NIR_PASS(_, nir, agx_nir_lower_uvs, &shader->info.uvs); in hk_lower_hw_vs()
1011 nir->info.cull_distance_array_size; in hk_lower_hw_vs()
1022 /* We consume the NIR, regardless of success or failure */ in hk_compile_shader()
1023 nir_shader *nir = info->nir; in hk_compile_shader() local
1031 ralloc_free(nir); in hk_compile_shader()
1038 hk_lower_nir(dev, nir, info->robustness, is_multiview, in hk_compile_shader()
1041 gl_shader_stage sw_stage = nir->info.stage; in hk_compile_shader()
1048 nir->info.fs.uses_sample_shading |= fs_key->force_sample_shading; in hk_compile_shader()
1055 nir_builder_at(nir_before_impl(nir_shader_get_entrypoint(nir))); in hk_compile_shader()
1057 nir->info.fs.uses_discard = true; in hk_compile_shader()
1060 NIR_PASS(_, nir, agx_nir_lower_sample_intrinsics, false); in hk_compile_shader()
1062 NIR_PASS_V(nir, agx_nir_lower_tcs, dev->dev.libagx); in hk_compile_shader()
1071 /* Each variant gets its own NIR. To save an extra clone, we use the in hk_compile_shader()
1072 * original NIR for the last stage. in hk_compile_shader()
1074 nir_shader *clone = last ? nir : nir_shader_clone(NULL, nir); in hk_compile_shader()
1107 if (clone != nir) { in hk_compile_shader()
1108 ralloc_free(nir); in hk_compile_shader()
1137 if (nir->xfb_info != NULL) { in hk_compile_shader()
1143 !(nir->info.inputs_read & BITFIELD64_MASK(VERT_ATTRIB_GENERIC0)) && in hk_compile_shader()
1146 NIR_PASS(_, nir, nir_recompute_io_bases, nir_var_shader_in); in hk_compile_shader()
1150 NIR_PASS(_, nir, nir_io_add_const_offset_to_base, in hk_compile_shader()
1168 /* Each variant gets its own NIR. To save an extra clone, we use the in hk_compile_shader()
1169 * original NIR for the last stage. in hk_compile_shader()
1171 nir_shader *clone = last ? nir : nir_shader_clone(NULL, nir); in hk_compile_shader()
1178 nir->info.inputs_read >> VERT_ATTRIB_GENERIC0; in hk_compile_shader()
1190 nir->xfb_info); in hk_compile_shader()
1193 ralloc_free(nir); in hk_compile_shader()
1200 /* hk_compile_nir takes ownership of nir */ in hk_compile_shader()
1202 hk_compile_nir(dev, pAllocator, nir, info->flags, info->robustness, in hk_compile_shader()
1232 /* Clean up all the NIR after this point */ in hk_compile_shaders()
1234 ralloc_free(infos[j].nir); in hk_compile_shaders()