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