panfrost: Remove unused batch_fence->ctx
[mesa.git] / src / gallium / drivers / panfrost / pan_job.h
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
29 #include "util/u_dynarray.h"
30 #include "pipe/p_state.h"
31 #include "pan_pool.h"
32 #include "pan_resource.h"
33 #include "pan_scoreboard.h"
34
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;
49 };
50
51 #define PAN_REQ_MSAA (1 << 0)
52 #define PAN_REQ_DEPTH_WRITE (1 << 1)
53
54 /* A panfrost_batch corresponds to a bound FBO we're rendering to,
55 * collecting over multiple draws. */
56
57 struct panfrost_batch {
58 struct panfrost_context *ctx;
59 struct pipe_framebuffer_state key;
60
61 /* Buffers cleared (PIPE_CLEAR_* bitmask) */
62 unsigned clear;
63
64 /* Buffers drawn */
65 unsigned draws;
66
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];
73 float clear_depth;
74 unsigned clear_stencil;
75
76 /* Amount of thread local storage required per thread */
77 unsigned stack_size;
78
79 /* Amount of shared memory needed per workgroup (for compute) */
80 unsigned shared_size;
81
82 /* Whether this job uses the corresponding requirement (PAN_REQ_*
83 * bitmask) */
84 unsigned requirements;
85
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
92 /* BOs referenced not in the pool */
93 struct hash_table *bos;
94
95 /* Pool owned by this batch (released when the batch is released) used for temporary descriptors */
96 struct pan_pool pool;
97
98 /* Job scoreboarding state */
99 struct pan_scoreboard scoreboard;
100
101 /* Polygon list bound to the batch, or NULL if none bound yet */
102 struct panfrost_bo *polygon_list;
103
104 /* Scratchpad BO bound to the batch, or NULL if none bound yet */
105 struct panfrost_bo *scratchpad;
106
107 /* Shared memory BO bound to the batch, or NULL if none bound yet */
108 struct panfrost_bo *shared_memory;
109
110 /* Tiler heap BO bound to the batch, or NULL if none bound yet */
111 struct panfrost_bo *tiler_heap;
112
113 /* Dummy tiler BO bound to the batch, or NULL if none bound yet */
114 struct panfrost_bo *tiler_dummy;
115
116 /* Framebuffer descriptor. */
117 struct panfrost_transfer framebuffer;
118
119 /* Bifrost tiler meta descriptor. */
120 mali_ptr tiler_meta;
121
122 /* Output sync object. Only valid when submitted is true. */
123 struct panfrost_batch_fence *out_sync;
124
125 /* Batch dependencies */
126 struct util_dynarray dependencies;
127 };
128
129 /* Functions for managing the above */
130
131 void
132 panfrost_batch_fence_unreference(struct panfrost_batch_fence *fence);
133
134 void
135 panfrost_batch_fence_reference(struct panfrost_batch_fence *batch);
136
137 struct panfrost_batch *
138 panfrost_get_batch_for_fbo(struct panfrost_context *ctx);
139
140 struct panfrost_batch *
141 panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx);
142
143 void
144 panfrost_batch_init(struct panfrost_context *ctx);
145
146 void
147 panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo,
148 uint32_t flags);
149
150 void panfrost_batch_add_fbo_bos(struct panfrost_batch *batch);
151
152 struct panfrost_bo *
153 panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
154 uint32_t create_flags, uint32_t access_flags);
155
156 void
157 panfrost_flush_all_batches(struct panfrost_context *ctx, uint32_t out_sync);
158
159 bool
160 panfrost_pending_batches_access_bo(struct panfrost_context *ctx,
161 const struct panfrost_bo *bo);
162
163 void
164 panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx,
165 struct panfrost_bo *bo, bool flush_readers);
166
167 void
168 panfrost_batch_set_requirements(struct panfrost_batch *batch);
169
170 void
171 panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
172
173 struct panfrost_bo *
174 panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned shift, unsigned thread_tls_alloc, unsigned core_count);
175
176 struct panfrost_bo *
177 panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);
178
179 mali_ptr
180 panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size);
181
182 struct panfrost_bo *
183 panfrost_batch_get_tiler_heap(struct panfrost_batch *batch);
184
185 struct panfrost_bo *
186 panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch);
187
188 void
189 panfrost_batch_clear(struct panfrost_batch *batch,
190 unsigned buffers,
191 const union pipe_color_union *color,
192 double depth, unsigned stencil);
193
194 void
195 panfrost_batch_union_scissor(struct panfrost_batch *batch,
196 unsigned minx, unsigned miny,
197 unsigned maxx, unsigned maxy);
198
199 void
200 panfrost_batch_intersection_scissor(struct panfrost_batch *batch,
201 unsigned minx, unsigned miny,
202 unsigned maxx, unsigned maxy);
203
204 bool
205 panfrost_batch_is_scanout(struct panfrost_batch *batch);
206
207 mali_ptr
208 panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_count);
209
210 mali_ptr
211 panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch);
212
213 #endif