1 /* 2 * Copyright (C) 2023 Collabora Ltd. 3 * 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 */ 24 25 #ifndef __PAN_CSF_H__ 26 #define __PAN_CSF_H__ 27 28 #include "compiler/shader_enums.h" 29 30 #include "pan_bo.h" 31 #include "pan_desc.h" 32 #include "pan_mempool.h" 33 34 struct cs_builder; 35 struct cs_load_store_tracker; 36 37 enum pan_rendering_pass { 38 PAN_INCREMENTAL_RENDERING_FIRST_PASS, 39 PAN_INCREMENTAL_RENDERING_MIDDLE_PASS, 40 PAN_INCREMENTAL_RENDERING_LAST_PASS, 41 PAN_INCREMENTAL_RENDERING_PASS_COUNT 42 }; 43 44 struct pan_csf_tiler_oom_ctx { 45 /* Number of times the OOM exception handler was called */ 46 uint32_t counter; 47 48 /* Alternative framebuffer descriptors for incremental rendering */ 49 struct panfrost_ptr fbds[PAN_INCREMENTAL_RENDERING_PASS_COUNT]; 50 51 /* Bounding Box (Register 42 and 43) */ 52 uint32_t bbox_min; 53 uint32_t bbox_max; 54 55 /* Tiler descriptor address */ 56 uint64_t tiler_desc; 57 58 /* Address of the region reserved for saving registers. */ 59 uint64_t dump_addr; 60 } PACKED; 61 62 struct panfrost_csf_batch { 63 /* CS related fields. */ 64 struct { 65 /* CS builder. */ 66 struct cs_builder *builder; 67 68 /* CS state, written through the CS, and checked when PAN_MESA_DEBUG=sync. 69 */ 70 struct panfrost_ptr state; 71 72 /* CS load/store tracker if extra checks are enabled. */ 73 struct cs_load_store_tracker *ls_tracker; 74 } cs; 75 76 /* Pool used to allocate CS chunks. */ 77 struct panfrost_pool cs_chunk_pool; 78 79 struct panfrost_ptr tiler_oom_ctx; 80 81 struct mali_tiler_context_packed *pending_tiler_desc; 82 }; 83 84 struct panfrost_csf_context { 85 bool is_init; 86 uint32_t group_handle; 87 88 struct { 89 uint32_t handle; 90 struct panfrost_bo *desc_bo; 91 } heap; 92 93 /* Temporary geometry buffer. Used as a FIFO by the tiler. */ 94 struct panfrost_bo *tmp_geom_bo; 95 96 struct { 97 struct panfrost_bo *cs_bo; 98 struct panfrost_bo *save_bo; 99 uint32_t length; 100 } tiler_oom_handler; 101 }; 102 103 #if defined(PAN_ARCH) && PAN_ARCH >= 10 104 105 #include "genxml/gen_macros.h" 106 107 struct panfrost_batch; 108 struct panfrost_context; 109 struct pan_fb_info; 110 struct pan_tls_info; 111 struct pipe_draw_info; 112 struct pipe_grid_info; 113 struct pipe_draw_start_count_bias; 114 115 int GENX(csf_init_context)(struct panfrost_context *ctx); 116 void GENX(csf_cleanup_context)(struct panfrost_context *ctx); 117 118 int GENX(csf_init_batch)(struct panfrost_batch *batch); 119 void GENX(csf_cleanup_batch)(struct panfrost_batch *batch); 120 int GENX(csf_submit_batch)(struct panfrost_batch *batch); 121 122 void GENX(csf_prepare_tiler)(struct panfrost_batch *batch, 123 struct pan_fb_info *fb); 124 void GENX(csf_preload_fb)(struct panfrost_batch *batch, struct pan_fb_info *fb); 125 void GENX(csf_emit_fbds)(struct panfrost_batch *batch, struct pan_fb_info *fb, 126 struct pan_tls_info *tls); 127 void GENX(csf_emit_fragment_job)(struct panfrost_batch *batch, 128 const struct pan_fb_info *pfb); 129 int GENX(csf_emit_batch_end)(struct panfrost_batch *batch); 130 void GENX(csf_launch_xfb)(struct panfrost_batch *batch, 131 const struct pipe_draw_info *info, unsigned count); 132 void GENX(csf_launch_grid)(struct panfrost_batch *batch, 133 const struct pipe_grid_info *info); 134 void GENX(csf_launch_draw)(struct panfrost_batch *batch, 135 const struct pipe_draw_info *info, 136 unsigned drawid_offset, 137 const struct pipe_draw_start_count_bias *draw, 138 unsigned vertex_count); 139 void GENX(csf_launch_draw_indirect)(struct panfrost_batch *batch, 140 const struct pipe_draw_info *info, 141 unsigned drawid_offset, 142 const struct pipe_draw_indirect_info *indirect); 143 144 void GENX(csf_emit_write_timestamp)(struct panfrost_batch *batch, 145 struct panfrost_resource *dst, 146 unsigned offset); 147 148 #endif /* PAN_ARCH >= 10 */ 149 150 #endif /* __PAN_CSF_H__ */ 151