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 "shaders/tessellator.h" 11 #include "nir.h" 12 #include "shader_enums.h" 13 14 enum mesa_prim; 15 16 struct agx_lower_output_to_var_state { 17 struct nir_variable *outputs[NUM_TOTAL_VARYING_SLOTS]; 18 }; 19 20 bool agx_lower_output_to_var(struct nir_builder *b, struct nir_instr *instr, 21 void *data); 22 23 struct nir_def *agx_load_per_vertex_input(struct nir_builder *b, 24 nir_intrinsic_instr *intr, 25 struct nir_def *vertex); 26 27 bool agx_nir_lower_sw_vs(struct nir_shader *s, unsigned index_size_B); 28 29 bool agx_nir_lower_vs_before_gs(struct nir_shader *vs, 30 const struct nir_shader *libagx); 31 32 bool agx_nir_lower_gs(struct nir_shader *gs, const struct nir_shader *libagx, 33 bool rasterizer_discard, struct nir_shader **gs_count, 34 struct nir_shader **gs_copy, struct nir_shader **pre_gs, 35 enum mesa_prim *out_mode, unsigned *out_count_words); 36 37 void agx_nir_prefix_sum_gs(struct nir_builder *b, const void *data); 38 39 void agx_nir_prefix_sum_tess(struct nir_builder *b, const void *data); 40 41 struct agx_gs_setup_indirect_key { 42 enum mesa_prim prim; 43 }; 44 45 void agx_nir_gs_setup_indirect(struct nir_builder *b, const void *key); 46 47 struct agx_unroll_restart_key { 48 enum mesa_prim prim; 49 unsigned index_size_B; 50 }; 51 52 void agx_nir_unroll_restart(struct nir_builder *b, const void *key); 53 54 struct agx_tessellator_key { 55 enum tess_primitive_mode prim : 8; 56 enum libagx_tess_output_primitive output_primitive : 8; 57 enum libagx_tess_partitioning partitioning : 8; 58 enum libagx_tess_mode mode : 8; 59 }; 60 static_assert(sizeof(struct agx_tessellator_key) == 4, "padded"); 61 62 struct agx_tess_setup_indirect_key { 63 bool point_mode; 64 bool with_counts; 65 bool padding[2]; 66 }; 67 static_assert(sizeof(struct agx_tess_setup_indirect_key) == 4, "padded"); 68 69 void agx_nir_tessellate(struct nir_builder *b, const void *key); 70 71 bool agx_nir_lower_tcs(struct nir_shader *tcs, const struct nir_shader *libagx); 72 73 bool agx_nir_lower_tes(struct nir_shader *tes, const struct nir_shader *libagx, 74 bool to_hw_vs); 75 76 uint64_t agx_tcs_per_vertex_outputs(const struct nir_shader *nir); 77 78 unsigned agx_tcs_output_stride(const struct nir_shader *nir); 79 80 void agx_nir_tess_setup_indirect(struct nir_builder *b, const void *data); 81 82 void agx_nir_increment_statistic(struct nir_builder *b, const void *data); 83 84 void agx_nir_increment_cs_invocations(struct nir_builder *b, const void *data); 85 86 struct agx_increment_ia_counters_key { 87 /* Implies primitive restart */ 88 uint8_t index_size_B; 89 }; 90 static_assert(sizeof(struct agx_increment_ia_counters_key) == 1, "padded"); 91 92 void agx_nir_increment_ia_counters(struct nir_builder *b, const void *data); 93 94 struct agx_predicate_indirect_key { 95 bool indexed; 96 }; 97 static_assert(sizeof(struct agx_predicate_indirect_key) == 1, "padded"); 98 99 void agx_nir_predicate_indirect(struct nir_builder *b, const void *data); 100 101 struct agx_decompress_key { 102 uint8_t nr_samples; 103 }; 104 static_assert(sizeof(struct agx_decompress_key) == 1, "padded"); 105 106 void agx_nir_decompress(struct nir_builder *b, const void *data); 107