17ec681f3Smrg/*
27ec681f3Smrg * Copyright (C) 2018-2019 Alyssa Rosenzweig <alyssa@rosenzweig.io>
37ec681f3Smrg *
47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
57ec681f3Smrg * copy of this software and associated documentation files (the "Software"),
67ec681f3Smrg * to deal in the Software without restriction, including without limitation
77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
97ec681f3Smrg * Software is furnished to do so, subject to the following conditions:
107ec681f3Smrg *
117ec681f3Smrg * The above copyright notice and this permission notice (including the next
127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the
137ec681f3Smrg * Software.
147ec681f3Smrg *
157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
207ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
217ec681f3Smrg * SOFTWARE.
227ec681f3Smrg */
237ec681f3Smrg
247ec681f3Smrg#ifndef __BIFROST_PUBLIC_H_
257ec681f3Smrg#define __BIFROST_PUBLIC_H_
267ec681f3Smrg
277ec681f3Smrg#include "compiler/nir/nir.h"
287ec681f3Smrg#include "util/u_dynarray.h"
297ec681f3Smrg#include "panfrost/util/pan_ir.h"
307ec681f3Smrg
317ec681f3Smrgvoid
327ec681f3Smrgbifrost_compile_shader_nir(nir_shader *nir,
337ec681f3Smrg                           const struct panfrost_compile_inputs *inputs,
347ec681f3Smrg                           struct util_dynarray *binary,
357ec681f3Smrg                           struct pan_shader_info *info);
367ec681f3Smrg
377ec681f3Smrgstatic const nir_shader_compiler_options bifrost_nir_options = {
387ec681f3Smrg        .lower_scmp = true,
397ec681f3Smrg        .lower_flrp16 = true,
407ec681f3Smrg        .lower_flrp32 = true,
417ec681f3Smrg        .lower_flrp64 = true,
427ec681f3Smrg        .lower_ffract = true,
437ec681f3Smrg        .lower_fmod = true,
447ec681f3Smrg        .lower_fdiv = true,
457ec681f3Smrg        .lower_isign = true,
467ec681f3Smrg        .lower_find_lsb = true,
477ec681f3Smrg        .lower_ifind_msb = true,
487ec681f3Smrg        .lower_fdph = true,
497ec681f3Smrg        .lower_fsqrt = true,
507ec681f3Smrg
517ec681f3Smrg        .lower_wpos_pntc = true,
527ec681f3Smrg        .lower_fsign = true,
537ec681f3Smrg
547ec681f3Smrg        .lower_bitfield_insert_to_shifts = true,
557ec681f3Smrg        .lower_bitfield_extract_to_shifts = true,
567ec681f3Smrg        .lower_extract_byte = true,
577ec681f3Smrg        .lower_extract_word = true,
587ec681f3Smrg        .lower_insert_byte = true,
597ec681f3Smrg        .lower_insert_word = true,
607ec681f3Smrg        .lower_rotate = true,
617ec681f3Smrg
627ec681f3Smrg        .lower_pack_half_2x16 = true,
637ec681f3Smrg        .lower_pack_unorm_2x16 = true,
647ec681f3Smrg        .lower_pack_snorm_2x16 = true,
657ec681f3Smrg        .lower_pack_unorm_4x8 = true,
667ec681f3Smrg        .lower_pack_snorm_4x8 = true,
677ec681f3Smrg        .lower_unpack_half_2x16 = true,
687ec681f3Smrg        .lower_unpack_unorm_2x16 = true,
697ec681f3Smrg        .lower_unpack_snorm_2x16 = true,
707ec681f3Smrg        .lower_unpack_unorm_4x8 = true,
717ec681f3Smrg        .lower_unpack_snorm_4x8 = true,
727ec681f3Smrg        .lower_pack_split = true,
737ec681f3Smrg
747ec681f3Smrg        .lower_doubles_options = nir_lower_dmod,
757ec681f3Smrg        /* TODO: Don't lower supported 64-bit operations */
767ec681f3Smrg        .lower_int64_options = ~0,
777ec681f3Smrg        /* TODO: Use IMULD on v7 */
787ec681f3Smrg        .lower_mul_high = true,
797ec681f3Smrg        .lower_uadd_carry = true,
807ec681f3Smrg
817ec681f3Smrg        .has_fsub = true,
827ec681f3Smrg        .has_isub = true,
837ec681f3Smrg        .vectorize_io = true,
847ec681f3Smrg        .vectorize_vec2_16bit = true,
857ec681f3Smrg        .fuse_ffma16 = true,
867ec681f3Smrg        .fuse_ffma32 = true,
877ec681f3Smrg        .fuse_ffma64 = true,
887ec681f3Smrg        .use_interpolated_input_intrinsics = true,
897ec681f3Smrg
907ec681f3Smrg        .lower_uniforms_to_ubo = true,
917ec681f3Smrg
927ec681f3Smrg        .has_cs_global_id = true,
937ec681f3Smrg        .vertex_id_zero_based = true,
947ec681f3Smrg        .lower_cs_local_index_from_id = true,
957ec681f3Smrg        .max_unroll_iterations = 32,
967ec681f3Smrg        .force_indirect_unrolling = (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp),
977ec681f3Smrg};
987ec681f3Smrg
997ec681f3Smrg#endif
100