1 /* 2 * Copyright 2023 Alyssa Rosenzweig 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #pragma once 7 8 #include <stdbool.h> 9 #include <stdint.h> 10 #include "shader_enums.h" 11 12 struct nir_shader; 13 enum mesa_prim; 14 15 struct nir_instr; 16 struct nir_builder; 17 struct nir_variable; 18 19 struct agx_lower_output_to_var_state { 20 struct nir_variable *outputs[NUM_TOTAL_VARYING_SLOTS]; 21 }; 22 23 bool agx_lower_output_to_var(struct nir_builder *b, struct nir_instr *instr, 24 void *data); 25 26 struct nir_def *agx_vertex_id_for_topology_class(struct nir_builder *b, 27 struct nir_def *vert, 28 enum mesa_prim clas); 29 30 bool agx_nir_lower_index_buffer(struct nir_shader *s, unsigned index_size_B, 31 bool patches); 32 33 bool agx_nir_lower_vs_before_gs(struct nir_shader *vs, 34 const struct nir_shader *libagx, 35 unsigned index_size_B, uint64_t *outputs); 36 37 bool agx_nir_lower_gs(struct nir_shader *gs, const struct nir_shader *libagx, 38 bool rasterizer_discard, struct nir_shader **gs_count, 39 struct nir_shader **gs_copy, struct nir_shader **pre_gs, 40 enum mesa_prim *out_mode, unsigned *out_count_words); 41 42 void agx_nir_prefix_sum_gs(struct nir_builder *b, const void *data); 43 44 struct agx_gs_setup_indirect_key { 45 enum mesa_prim prim; 46 }; 47 48 void agx_nir_gs_setup_indirect(struct nir_builder *b, const void *key); 49 50 struct agx_unroll_restart_key { 51 enum mesa_prim prim; 52 unsigned index_size_B; 53 }; 54 55 void agx_nir_unroll_restart(struct nir_builder *b, const void *key); 56 57 bool agx_nir_lower_tcs(struct nir_shader *tcs, const struct nir_shader *vs, 58 const struct nir_shader *libagx, uint8_t index_size_B); 59 60 bool agx_nir_lower_tes(struct nir_shader *tes, const struct nir_shader *libagx); 61 62 uint64_t agx_tcs_per_vertex_outputs(const struct nir_shader *nir); 63 64 unsigned agx_tcs_output_stride(const struct nir_shader *nir); 65