blob: 93ac3a825dbec2f2d00585296be33df010b85bc0 [file] [log] [blame]
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +00001/*
Alyssa Rosenzweig7e8de5a2019-04-03 01:48:09 +00002 * Copyright (C) 2018-2019 Alyssa Rosenzweig <alyssa@rosenzweig.io>
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +00003 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
Alyssa Rosenzweig7e8de5a2019-04-03 01:48:09 +000024#ifndef __MIDGARD_H_
25#define __MIDGARD_H_
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000026
27#include "compiler/nir/nir.h"
28#include "util/u_dynarray.h"
Alyssa Rosenzweig3a4524e2020-03-10 15:41:56 -040029#include "panfrost/util/pan_ir.h"
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000030
31int
Boris Brezillon0a74a042020-10-08 10:09:56 +020032midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
33 const struct panfrost_compile_inputs *inputs);
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000034
35/* NIR options are shared between the standalone compiler and the online
36 * compiler. Defining it here is the simplest, though maybe not the Right
37 * solution. */
38
39static const nir_shader_compiler_options midgard_nir_options = {
Kenneth Graunke140f53e2020-09-24 08:46:31 -070040 .lower_ffma16 = true,
41 .lower_ffma32 = true,
42 .lower_ffma64 = true,
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000043 .lower_scmp = true,
Alyssa Rosenzweig6c08e292020-04-27 18:33:10 -040044 .lower_flrp16 = true,
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000045 .lower_flrp32 = true,
46 .lower_flrp64 = true,
47 .lower_ffract = true,
Kenneth Graunkec7d1b522019-06-03 13:18:55 -070048 .lower_fmod = true,
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000049 .lower_fdiv = true,
Eric Anholt42d2cae2019-02-06 13:12:25 -080050 .lower_isign = true,
Alyssa Rosenzweig04a72392019-03-26 04:48:20 +000051 .lower_fpow = true,
Alyssa Rosenzweigb19d1a12019-04-05 05:45:01 +000052 .lower_find_lsb = true,
Alyssa Rosenzweig85cc78a2019-08-26 07:46:43 -070053 .lower_fdph = true,
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000054
Alyssa Rosenzweig2adf35e2019-05-23 03:01:32 +000055 .lower_wpos_pntc = true,
56
Alyssa Rosenzweig648cda22019-04-19 23:15:45 +000057 /* TODO: We have native ops to help here, which we'll want to look into
58 * eventually */
59 .lower_fsign = true,
60
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000061 .lower_extract_byte = true,
62 .lower_extract_word = true,
Sagar Ghuge456557a2019-06-03 17:11:57 -070063 .lower_rotate = true,
Kenneth Graunkedfb18f02019-06-03 11:54:21 -070064
Alyssa Rosenzweig3af5a392019-12-24 14:01:33 -050065 .lower_pack_half_2x16 = true,
Alyssa Rosenzweig3af5a392019-12-24 14:01:33 -050066 .lower_pack_unorm_2x16 = true,
67 .lower_pack_snorm_2x16 = true,
68 .lower_pack_unorm_4x8 = true,
69 .lower_pack_snorm_4x8 = true,
70 .lower_unpack_half_2x16 = true,
Alyssa Rosenzweig3af5a392019-12-24 14:01:33 -050071 .lower_unpack_unorm_2x16 = true,
72 .lower_unpack_snorm_2x16 = true,
73 .lower_unpack_unorm_4x8 = true,
74 .lower_unpack_snorm_4x8 = true,
Jonathan Marek42093bb2020-04-24 14:27:33 -040075 .lower_pack_split = true,
Alyssa Rosenzweig3af5a392019-12-24 14:01:33 -050076
Kenneth Graunkedfb18f02019-06-03 11:54:21 -070077 .lower_doubles_options = nir_lower_dmod,
Alyssa Rosenzweigde8d49a2019-06-06 09:15:26 -070078
Boris Brezillonef89a522020-01-31 09:25:07 +010079 .lower_bitfield_extract_to_shifts = true,
Alyssa Rosenzweigde8d49a2019-06-06 09:15:26 -070080 .vectorize_io = true,
Alyssa Rosenzweigc17a4412019-12-27 15:32:50 -050081 .use_interpolated_input_intrinsics = true
Alyssa Rosenzweige67e0722019-01-30 01:11:31 +000082};
Alyssa Rosenzweig7e8de5a2019-04-03 01:48:09 +000083
84#endif