1 /* 2 * Copyright (C) 2018-2019 Alyssa Rosenzweig <[email protected]> 3 * Copyright (C) 2019-2020 Collabora, Ltd. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * SOFTWARE. 23 */ 24 25 #ifndef __MIDGARD_H_ 26 #define __MIDGARD_H_ 27 28 #include "compiler/nir/nir.h" 29 #include "panfrost/util/pan_ir.h" 30 #include "util/u_dynarray.h" 31 32 void midgard_preprocess_nir(nir_shader *nir, unsigned gpu_id); 33 34 void midgard_compile_shader_nir(nir_shader *nir, 35 const struct panfrost_compile_inputs *inputs, 36 struct util_dynarray *binary, 37 struct pan_shader_info *info); 38 39 /* NIR options are shared between the standalone compiler and the online 40 * compiler. Defining it here is the simplest, though maybe not the Right 41 * solution. */ 42 43 static const nir_shader_compiler_options midgard_nir_options = { 44 .lower_ffma16 = true, 45 .lower_ffma32 = true, 46 .lower_ffma64 = true, 47 .lower_scmp = true, 48 .lower_flrp16 = true, 49 .lower_flrp32 = true, 50 .lower_flrp64 = true, 51 .lower_ffract = true, 52 .lower_fmod = true, 53 .lower_fdiv = true, 54 .lower_ineg = true, 55 .lower_isign = true, 56 .lower_fpow = true, 57 .lower_find_lsb = true, 58 .lower_ifind_msb = true, 59 .lower_fdph = true, 60 .lower_fisnormal = true, 61 .lower_hadd = true, 62 .lower_uadd_carry = true, 63 .lower_usub_borrow = true, 64 65 /* TODO: We have native ops to help here, which we'll want to look into 66 * eventually */ 67 .lower_fsign = true, 68 69 .lower_bit_count = true, 70 .lower_bitfield_reverse = true, 71 .lower_bitfield_insert = true, 72 .lower_bitfield_extract = true, 73 .lower_extract_byte = true, 74 .lower_extract_word = true, 75 .lower_insert_byte = true, 76 .lower_insert_word = true, 77 .lower_ldexp = true, 78 79 .lower_pack_half_2x16 = true, 80 .lower_pack_unorm_2x16 = true, 81 .lower_pack_snorm_2x16 = true, 82 .lower_pack_unorm_4x8 = true, 83 .lower_pack_snorm_4x8 = true, 84 .lower_unpack_half_2x16 = true, 85 .lower_unpack_unorm_2x16 = true, 86 .lower_unpack_snorm_2x16 = true, 87 .lower_unpack_unorm_4x8 = true, 88 .lower_unpack_snorm_4x8 = true, 89 .lower_pack_split = true, 90 .lower_pack_64_2x32_split = true, 91 .lower_unpack_64_2x32_split = true, 92 .lower_int64_options = nir_lower_imul_2x32_64, 93 94 .lower_doubles_options = nir_lower_dmod, 95 96 .lower_uniforms_to_ubo = true, 97 .has_fsub = true, 98 .has_isub = true, 99 .vectorize_io = true, 100 .use_interpolated_input_intrinsics = true, 101 102 .vertex_id_zero_based = true, 103 .has_cs_global_id = true, 104 .lower_cs_local_index_to_id = true, 105 .max_unroll_iterations = 32, 106 .force_indirect_unrolling = 107 (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp), 108 .force_indirect_unrolling_sampler = true, 109 .has_ddx_intrinsics = true, 110 }; 111 112 #endif 113