1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (C) 2018-2019 Alyssa Rosenzweig <alyssa@rosenzweig.io>
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21bf215546Sopenharmony_ci * SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci#ifndef __BIFROST_PUBLIC_H_
25bf215546Sopenharmony_ci#define __BIFROST_PUBLIC_H_
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#include "compiler/nir/nir.h"
28bf215546Sopenharmony_ci#include "util/u_dynarray.h"
29bf215546Sopenharmony_ci#include "panfrost/util/pan_ir.h"
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_civoid
32bf215546Sopenharmony_cibifrost_compile_shader_nir(nir_shader *nir,
33bf215546Sopenharmony_ci                           const struct panfrost_compile_inputs *inputs,
34bf215546Sopenharmony_ci                           struct util_dynarray *binary,
35bf215546Sopenharmony_ci                           struct pan_shader_info *info);
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistatic const nir_shader_compiler_options bifrost_nir_options = {
38bf215546Sopenharmony_ci        .lower_scmp = true,
39bf215546Sopenharmony_ci        .lower_flrp16 = true,
40bf215546Sopenharmony_ci        .lower_flrp32 = true,
41bf215546Sopenharmony_ci        .lower_flrp64 = true,
42bf215546Sopenharmony_ci        .lower_ffract = true,
43bf215546Sopenharmony_ci        .lower_fmod = true,
44bf215546Sopenharmony_ci        .lower_fdiv = true,
45bf215546Sopenharmony_ci        .lower_isign = true,
46bf215546Sopenharmony_ci        .lower_find_lsb = true,
47bf215546Sopenharmony_ci        .lower_ifind_msb = true,
48bf215546Sopenharmony_ci        .lower_fdph = true,
49bf215546Sopenharmony_ci        .lower_fsqrt = true,
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci        .lower_fsign = true,
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci        .lower_bitfield_insert_to_shifts = true,
54bf215546Sopenharmony_ci        .lower_bitfield_extract_to_shifts = true,
55bf215546Sopenharmony_ci        .lower_extract_byte = true,
56bf215546Sopenharmony_ci        .lower_extract_word = true,
57bf215546Sopenharmony_ci        .lower_insert_byte = true,
58bf215546Sopenharmony_ci        .lower_insert_word = true,
59bf215546Sopenharmony_ci        .lower_rotate = true,
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_ci        .lower_pack_half_2x16 = true,
62bf215546Sopenharmony_ci        .lower_pack_unorm_2x16 = true,
63bf215546Sopenharmony_ci        .lower_pack_snorm_2x16 = true,
64bf215546Sopenharmony_ci        .lower_pack_unorm_4x8 = true,
65bf215546Sopenharmony_ci        .lower_pack_snorm_4x8 = true,
66bf215546Sopenharmony_ci        .lower_unpack_half_2x16 = true,
67bf215546Sopenharmony_ci        .lower_unpack_unorm_2x16 = true,
68bf215546Sopenharmony_ci        .lower_unpack_snorm_2x16 = true,
69bf215546Sopenharmony_ci        .lower_unpack_unorm_4x8 = true,
70bf215546Sopenharmony_ci        .lower_unpack_snorm_4x8 = true,
71bf215546Sopenharmony_ci        .lower_pack_split = true,
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci        .lower_doubles_options = nir_lower_dmod,
74bf215546Sopenharmony_ci        /* TODO: Don't lower supported 64-bit operations */
75bf215546Sopenharmony_ci        .lower_int64_options = ~0,
76bf215546Sopenharmony_ci        /* TODO: Use IMULD on v7 */
77bf215546Sopenharmony_ci        .lower_mul_high = true,
78bf215546Sopenharmony_ci        .lower_uadd_carry = true,
79bf215546Sopenharmony_ci        .lower_usub_borrow = true,
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ci        .has_fsub = true,
82bf215546Sopenharmony_ci        .has_isub = true,
83bf215546Sopenharmony_ci        .vectorize_io = true,
84bf215546Sopenharmony_ci        .vectorize_vec2_16bit = true,
85bf215546Sopenharmony_ci        .fuse_ffma16 = true,
86bf215546Sopenharmony_ci        .fuse_ffma32 = true,
87bf215546Sopenharmony_ci        .fuse_ffma64 = true,
88bf215546Sopenharmony_ci        .use_interpolated_input_intrinsics = true,
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ci        .lower_uniforms_to_ubo = true,
91bf215546Sopenharmony_ci
92bf215546Sopenharmony_ci        .has_cs_global_id = true,
93bf215546Sopenharmony_ci        .lower_cs_local_index_to_id = true,
94bf215546Sopenharmony_ci        .max_unroll_iterations = 32,
95bf215546Sopenharmony_ci        .force_indirect_unrolling = (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp),
96bf215546Sopenharmony_ci        .force_indirect_unrolling_sampler = true,
97bf215546Sopenharmony_ci};
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ci#endif
100