Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 Alyssa Rosenzweig |
| 3 | * Copyright (C) 2014-2017 Broadcom |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef __PAN_JOB_H__ |
| 27 | #define __PAN_JOB_H__ |
| 28 | |
Alyssa Rosenzweig | f085474 | 2019-06-19 11:27:59 -0700 | [diff] [blame] | 29 | #include "util/u_dynarray.h" |
| 30 | #include "pipe/p_state.h" |
Alyssa Rosenzweig | c8d848b | 2020-07-07 16:24:41 -0400 | [diff] [blame] | 31 | #include "pan_pool.h" |
Alyssa Rosenzweig | f085474 | 2019-06-19 11:27:59 -0700 | [diff] [blame] | 32 | #include "pan_resource.h" |
Alyssa Rosenzweig | 31197c2 | 2020-07-07 17:07:34 -0400 | [diff] [blame] | 33 | #include "pan_scoreboard.h" |
Alyssa Rosenzweig | f085474 | 2019-06-19 11:27:59 -0700 | [diff] [blame] | 34 | |
Boris Brezillon | 6936b7f | 2019-09-15 10:27:07 +0200 | [diff] [blame] | 35 | /* panfrost_batch_fence is the out fence of a batch that users or other batches |
| 36 | * might want to wait on. The batch fence lifetime is different from the batch |
| 37 | * one as want will certainly want to wait upon the fence after the batch has |
| 38 | * been submitted (which is when panfrost_batch objects are freed). |
| 39 | */ |
| 40 | struct panfrost_batch_fence { |
| 41 | /* Refcounting object for the fence. */ |
| 42 | struct pipe_reference reference; |
| 43 | |
| 44 | /* Batch that created this fence object. Will become NULL at batch |
| 45 | * submission time. This field is mainly here to know whether the |
| 46 | * batch has been flushed or not. |
| 47 | */ |
| 48 | struct panfrost_batch *batch; |
Boris Brezillon | 6936b7f | 2019-09-15 10:27:07 +0200 | [diff] [blame] | 49 | }; |
| 50 | |
Alyssa Rosenzweig | 8c26890 | 2019-03-12 23:16:37 +0000 | [diff] [blame] | 51 | #define PAN_REQ_MSAA (1 << 0) |
| 52 | #define PAN_REQ_DEPTH_WRITE (1 << 1) |
| 53 | |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 54 | /* A panfrost_batch corresponds to a bound FBO we're rendering to, |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 55 | * collecting over multiple draws. */ |
| 56 | |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 57 | struct panfrost_batch { |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 58 | struct panfrost_context *ctx; |
Boris Brezillon | 1b5873b | 2019-09-01 10:24:30 +0200 | [diff] [blame] | 59 | struct pipe_framebuffer_state key; |
Alyssa Rosenzweig | 40ffee4 | 2019-02-26 23:51:34 +0000 | [diff] [blame] | 60 | |
| 61 | /* Buffers cleared (PIPE_CLEAR_* bitmask) */ |
| 62 | unsigned clear; |
| 63 | |
Alyssa Rosenzweig | 5d0d8fa | 2020-07-15 17:35:58 -0400 | [diff] [blame] | 64 | /* Buffers drawn */ |
| 65 | unsigned draws; |
| 66 | |
Alyssa Rosenzweig | 8e4e467 | 2019-07-01 11:49:06 -0700 | [diff] [blame] | 67 | /* Packed clear values, indexed by both render target as well as word. |
| 68 | * Essentially, a single pixel is packed, with some padding to bring it |
| 69 | * up to a 32-bit interval; that pixel is then duplicated over to fill |
| 70 | * all 16-bytes */ |
| 71 | |
| 72 | uint32_t clear_color[PIPE_MAX_COLOR_BUFS][4]; |
Alyssa Rosenzweig | 40ffee4 | 2019-02-26 23:51:34 +0000 | [diff] [blame] | 73 | float clear_depth; |
| 74 | unsigned clear_stencil; |
Alyssa Rosenzweig | 9dd84db | 2019-03-12 03:32:17 +0000 | [diff] [blame] | 75 | |
Alyssa Rosenzweig | bc887e8 | 2019-12-09 11:18:47 -0500 | [diff] [blame] | 76 | /* Amount of thread local storage required per thread */ |
| 77 | unsigned stack_size; |
| 78 | |
Alyssa Rosenzweig | 9603126 | 2020-02-06 14:29:42 -0500 | [diff] [blame] | 79 | /* Amount of shared memory needed per workgroup (for compute) */ |
| 80 | unsigned shared_size; |
| 81 | |
Alyssa Rosenzweig | 8c26890 | 2019-03-12 23:16:37 +0000 | [diff] [blame] | 82 | /* Whether this job uses the corresponding requirement (PAN_REQ_* |
| 83 | * bitmask) */ |
| 84 | unsigned requirements; |
| 85 | |
Alyssa Rosenzweig | c378829 | 2019-06-18 12:30:55 -0700 | [diff] [blame] | 86 | /* The bounding box covered by this job, taking scissors into account. |
| 87 | * Basically, the bounding box we have to run fragment shaders for */ |
| 88 | |
| 89 | unsigned minx, miny; |
| 90 | unsigned maxx, maxy; |
| 91 | |
Alyssa Rosenzweig | 8882d6a | 2020-07-07 14:46:40 -0400 | [diff] [blame] | 92 | /* BOs referenced not in the pool */ |
Boris Brezillon | a8bd265 | 2019-09-15 09:27:14 +0200 | [diff] [blame] | 93 | struct hash_table *bos; |
Alyssa Rosenzweig | 0f5ad9e | 2019-07-12 12:53:36 -0700 | [diff] [blame] | 94 | |
Alyssa Rosenzweig | 8882d6a | 2020-07-07 14:46:40 -0400 | [diff] [blame] | 95 | /* Pool owned by this batch (released when the batch is released) used for temporary descriptors */ |
| 96 | struct pan_pool pool; |
Alyssa Rosenzweig | cd98d94 | 2019-08-02 19:18:48 +0200 | [diff] [blame] | 97 | |
Alyssa Rosenzweig | 17c617c | 2020-08-17 10:31:02 -0400 | [diff] [blame] | 98 | /* Pool also owned by this batch that is not CPU mapped (created as |
| 99 | * INVISIBLE) used for private GPU-internal structures, particularly |
| 100 | * varyings */ |
| 101 | struct pan_pool invisible_pool; |
| 102 | |
Alyssa Rosenzweig | 31197c2 | 2020-07-07 17:07:34 -0400 | [diff] [blame] | 103 | /* Job scoreboarding state */ |
| 104 | struct pan_scoreboard scoreboard; |
| 105 | |
Alyssa Rosenzweig | cd98d94 | 2019-08-02 19:18:48 +0200 | [diff] [blame] | 106 | /* Polygon list bound to the batch, or NULL if none bound yet */ |
| 107 | struct panfrost_bo *polygon_list; |
Boris Brezillon | 4166ca9 | 2019-09-05 19:07:12 +0200 | [diff] [blame] | 108 | |
Alyssa Rosenzweig | 9603126 | 2020-02-06 14:29:42 -0500 | [diff] [blame] | 109 | /* Scratchpad BO bound to the batch, or NULL if none bound yet */ |
Boris Brezillon | 1e483a8 | 2019-09-14 19:18:51 +0200 | [diff] [blame] | 110 | struct panfrost_bo *scratchpad; |
| 111 | |
Alyssa Rosenzweig | 9603126 | 2020-02-06 14:29:42 -0500 | [diff] [blame] | 112 | /* Shared memory BO bound to the batch, or NULL if none bound yet */ |
| 113 | struct panfrost_bo *shared_memory; |
| 114 | |
Boris Brezillon | 1e483a8 | 2019-09-14 19:18:51 +0200 | [diff] [blame] | 115 | /* Tiler heap BO bound to the batch, or NULL if none bound yet */ |
| 116 | struct panfrost_bo *tiler_heap; |
| 117 | |
| 118 | /* Dummy tiler BO bound to the batch, or NULL if none bound yet */ |
| 119 | struct panfrost_bo *tiler_dummy; |
| 120 | |
Boris Brezillon | 4166ca9 | 2019-09-05 19:07:12 +0200 | [diff] [blame] | 121 | /* Framebuffer descriptor. */ |
Alyssa Rosenzweig | b0e915b | 2019-12-09 11:00:42 -0500 | [diff] [blame] | 122 | struct panfrost_transfer framebuffer; |
Boris Brezillon | 6936b7f | 2019-09-15 10:27:07 +0200 | [diff] [blame] | 123 | |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 124 | /* Bifrost tiler meta descriptor. */ |
| 125 | mali_ptr tiler_meta; |
| 126 | |
Boris Brezillon | 6936b7f | 2019-09-15 10:27:07 +0200 | [diff] [blame] | 127 | /* Output sync object. Only valid when submitted is true. */ |
| 128 | struct panfrost_batch_fence *out_sync; |
Boris Brezillon | 2dad9fd | 2019-09-15 13:39:52 +0200 | [diff] [blame] | 129 | |
| 130 | /* Batch dependencies */ |
| 131 | struct util_dynarray dependencies; |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | /* Functions for managing the above */ |
| 135 | |
Boris Brezillon | 6936b7f | 2019-09-15 10:27:07 +0200 | [diff] [blame] | 136 | void |
| 137 | panfrost_batch_fence_unreference(struct panfrost_batch_fence *fence); |
| 138 | |
| 139 | void |
| 140 | panfrost_batch_fence_reference(struct panfrost_batch_fence *batch); |
| 141 | |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 142 | struct panfrost_batch * |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 143 | panfrost_get_batch_for_fbo(struct panfrost_context *ctx); |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 144 | |
Boris Brezillon | c138ca8 | 2019-09-19 15:52:02 +0200 | [diff] [blame] | 145 | struct panfrost_batch * |
| 146 | panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx); |
| 147 | |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 148 | void |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 149 | panfrost_batch_init(struct panfrost_context *ctx); |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 150 | |
Alyssa Rosenzweig | e008d4f | 2019-04-14 22:42:44 +0000 | [diff] [blame] | 151 | void |
Boris Brezillon | ada752a | 2019-09-15 09:21:13 +0200 | [diff] [blame] | 152 | panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo, |
| 153 | uint32_t flags); |
Alyssa Rosenzweig | e008d4f | 2019-04-14 22:42:44 +0000 | [diff] [blame] | 154 | |
Boris Brezillon | 5a4d095 | 2019-09-14 17:57:06 +0200 | [diff] [blame] | 155 | struct panfrost_bo * |
| 156 | panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size, |
Boris Brezillon | ada752a | 2019-09-15 09:21:13 +0200 | [diff] [blame] | 157 | uint32_t create_flags, uint32_t access_flags); |
Boris Brezillon | 5a4d095 | 2019-09-14 17:57:06 +0200 | [diff] [blame] | 158 | |
Alyssa Rosenzweig | e008d4f | 2019-04-14 22:42:44 +0000 | [diff] [blame] | 159 | void |
Alyssa Rosenzweig | 64d6f56 | 2020-07-20 13:34:42 -0400 | [diff] [blame] | 160 | panfrost_flush_all_batches(struct panfrost_context *ctx, uint32_t out_sync); |
Rohan Garg | bfca21b | 2019-06-05 17:49:14 +0200 | [diff] [blame] | 161 | |
Boris Brezillon | 7fa5cd3 | 2019-10-10 15:12:30 +0200 | [diff] [blame] | 162 | bool |
| 163 | panfrost_pending_batches_access_bo(struct panfrost_context *ctx, |
| 164 | const struct panfrost_bo *bo); |
| 165 | |
Rohan Garg | bfca21b | 2019-06-05 17:49:14 +0200 | [diff] [blame] | 166 | void |
Boris Brezillon | 82399b5 | 2019-09-15 20:17:14 +0200 | [diff] [blame] | 167 | panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx, |
Alyssa Rosenzweig | c6ebff3 | 2020-05-26 14:47:21 -0400 | [diff] [blame] | 168 | struct panfrost_bo *bo, bool flush_readers); |
Boris Brezillon | 82399b5 | 2019-09-15 20:17:14 +0200 | [diff] [blame] | 169 | |
| 170 | void |
Boris Brezillon | 12d8a17 | 2019-09-05 21:41:28 +0200 | [diff] [blame] | 171 | panfrost_batch_set_requirements(struct panfrost_batch *batch); |
Rohan Garg | ad284f7 | 2019-06-05 19:04:04 +0200 | [diff] [blame] | 172 | |
Boris Brezillon | 79f8850 | 2020-03-05 08:58:10 +0100 | [diff] [blame] | 173 | void |
| 174 | panfrost_batch_adjust_stack_size(struct panfrost_batch *batch); |
| 175 | |
Alyssa Rosenzweig | 4f7fddb | 2019-12-09 11:02:15 -0500 | [diff] [blame] | 176 | struct panfrost_bo * |
Alyssa Rosenzweig | b41692c | 2020-08-17 12:30:49 -0400 | [diff] [blame] | 177 | panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned size, unsigned thread_tls_alloc, unsigned core_count); |
Alyssa Rosenzweig | 4f7fddb | 2019-12-09 11:02:15 -0500 | [diff] [blame] | 178 | |
Alyssa Rosenzweig | 9603126 | 2020-02-06 14:29:42 -0500 | [diff] [blame] | 179 | struct panfrost_bo * |
| 180 | panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count); |
| 181 | |
Alyssa Rosenzweig | cd98d94 | 2019-08-02 19:18:48 +0200 | [diff] [blame] | 182 | mali_ptr |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 183 | panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size); |
Alyssa Rosenzweig | cd98d94 | 2019-08-02 19:18:48 +0200 | [diff] [blame] | 184 | |
Boris Brezillon | 1e483a8 | 2019-09-14 19:18:51 +0200 | [diff] [blame] | 185 | struct panfrost_bo * |
Boris Brezillon | 1e483a8 | 2019-09-14 19:18:51 +0200 | [diff] [blame] | 186 | panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch); |
| 187 | |
Rohan Garg | ad284f7 | 2019-06-05 19:04:04 +0200 | [diff] [blame] | 188 | void |
Boris Brezillon | 12d8a17 | 2019-09-05 21:41:28 +0200 | [diff] [blame] | 189 | panfrost_batch_clear(struct panfrost_batch *batch, |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 190 | unsigned buffers, |
| 191 | const union pipe_color_union *color, |
| 192 | double depth, unsigned stencil); |
Rohan Garg | ad284f7 | 2019-06-05 19:04:04 +0200 | [diff] [blame] | 193 | |
Alyssa Rosenzweig | c378829 | 2019-06-18 12:30:55 -0700 | [diff] [blame] | 194 | void |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 195 | panfrost_batch_union_scissor(struct panfrost_batch *batch, |
| 196 | unsigned minx, unsigned miny, |
| 197 | unsigned maxx, unsigned maxy); |
Alyssa Rosenzweig | c378829 | 2019-06-18 12:30:55 -0700 | [diff] [blame] | 198 | |
Boris Brezillon | 65ae86b | 2019-08-12 12:07:08 +0200 | [diff] [blame] | 199 | void |
Boris Brezillon | 2c52699 | 2019-09-05 21:41:26 +0200 | [diff] [blame] | 200 | panfrost_batch_intersection_scissor(struct panfrost_batch *batch, |
| 201 | unsigned minx, unsigned miny, |
| 202 | unsigned maxx, unsigned maxy); |
Boris Brezillon | 65ae86b | 2019-08-12 12:07:08 +0200 | [diff] [blame] | 203 | |
Boris Brezillon | e46d95d | 2019-09-01 10:54:38 +0200 | [diff] [blame] | 204 | bool |
| 205 | panfrost_batch_is_scanout(struct panfrost_batch *batch); |
| 206 | |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 207 | mali_ptr |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 208 | panfrost_batch_get_bifrost_tiler(struct panfrost_batch *batch, unsigned vertex_count); |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 209 | |
Alyssa Rosenzweig | 34a0310 | 2020-07-15 13:10:02 -0400 | [diff] [blame] | 210 | mali_ptr |
| 211 | panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch); |
| 212 | |
Alyssa Rosenzweig | 59c9623 | 2019-02-25 05:32:16 +0000 | [diff] [blame] | 213 | #endif |