2
* Copyright (C) 2019 Alyssa Rosenzweig
3
* Copyright (C) 2014-2017 Broadcom
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:
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
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
29
#include "util/u_dynarray.h"
30
#include "pipe/p_state.h"
32
#include "pan_mempool.h"
33
#include "pan_resource.h"
34
#include "pan_scoreboard.h"
36
/* A panfrost_batch corresponds to a bound FBO we're rendering to,
37
* collecting over multiple draws. */
39
struct panfrost_batch {
40
struct panfrost_context *ctx;
41
struct pipe_framebuffer_state key;
43
/* Sequence number used to implement LRU eviction when all batch slots are used */
46
/* Buffers cleared (PIPE_CLEAR_* bitmask) */
55
/* Buffers needing resolve to memory */
58
/* Packed clear values, indexed by both render target as well as word.
59
* Essentially, a single pixel is packed, with some padding to bring it
60
* up to a 32-bit interval; that pixel is then duplicated over to fill
63
uint32_t clear_color[PIPE_MAX_COLOR_BUFS][4];
65
unsigned clear_stencil;
67
/* Amount of thread local storage required per thread */
70
/* Amount of shared memory needed per workgroup (for compute) */
73
/* The bounding box covered by this job, taking scissors into account.
74
* Basically, the bounding box we have to run fragment shaders for */
79
/* Acts as a rasterizer discard */
80
bool scissor_culls_everything;
82
/* BOs referenced not in the pool */
83
int first_bo, last_bo;
85
struct util_sparse_array bos;
87
/* Pool owned by this batch (released when the batch is released) used for temporary descriptors */
88
struct panfrost_pool pool;
90
/* Pool also owned by this batch that is not CPU mapped (created as
91
* INVISIBLE) used for private GPU-internal structures, particularly
93
struct panfrost_pool invisible_pool;
95
/* Job scoreboarding state */
96
struct pan_scoreboard scoreboard;
98
/* Polygon list bound to the batch, or NULL if none bound yet */
99
struct panfrost_bo *polygon_list;
101
/* Scratchpad BO bound to the batch, or NULL if none bound yet */
102
struct panfrost_bo *scratchpad;
104
/* Shared memory BO bound to the batch, or NULL if none bound yet */
105
struct panfrost_bo *shared_memory;
107
/* Framebuffer descriptor. */
108
struct panfrost_ptr framebuffer;
110
/* Thread local storage descriptor. */
111
struct panfrost_ptr tls;
114
struct pan_tiler_context tiler_ctx;
116
/* Indirect draw data */
117
struct panfrost_ptr indirect_draw_ctx;
118
unsigned indirect_draw_job_id;
120
/* Keep the num_work_groups sysval around for indirect dispatch */
121
mali_ptr num_wg_sysval[3];
123
/* Cached descriptors */
125
mali_ptr rsd[PIPE_SHADER_TYPES];
126
mali_ptr textures[PIPE_SHADER_TYPES];
127
mali_ptr samplers[PIPE_SHADER_TYPES];
128
mali_ptr attribs[PIPE_SHADER_TYPES];
129
mali_ptr attrib_bufs[PIPE_SHADER_TYPES];
130
mali_ptr uniform_buffers[PIPE_SHADER_TYPES];
131
mali_ptr push_uniforms[PIPE_SHADER_TYPES];
132
mali_ptr depth_stencil;
135
/* Valhall: struct mali_scissor_packed */
137
float minimum_z, maximum_z;
139
/* Used on Valhall only. Midgard includes attributes in-band with
140
* attributes, wildly enough.
142
mali_ptr images[PIPE_SHADER_TYPES];
144
/* Referenced resources */
145
struct set *resources;
148
/* Functions for managing the above */
150
struct panfrost_batch *
151
panfrost_get_batch_for_fbo(struct panfrost_context *ctx);
153
struct panfrost_batch *
154
panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx, const char *reason);
157
panfrost_batch_add_bo(struct panfrost_batch *batch,
158
struct panfrost_bo *bo,
159
enum pipe_shader_type stage);
162
panfrost_batch_read_rsrc(struct panfrost_batch *batch,
163
struct panfrost_resource *rsrc,
164
enum pipe_shader_type stage);
167
panfrost_batch_write_rsrc(struct panfrost_batch *batch,
168
struct panfrost_resource *rsrc,
169
enum pipe_shader_type stage);
172
panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
173
uint32_t create_flags, uint32_t access_flags,
177
panfrost_flush_all_batches(struct panfrost_context *ctx, const char *reason);
180
panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
181
struct panfrost_resource *rsrc,
185
panfrost_flush_writer(struct panfrost_context *ctx,
186
struct panfrost_resource *rsrc,
190
panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
193
panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned size, unsigned thread_tls_alloc, unsigned core_count);
196
panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);
199
panfrost_batch_clear(struct panfrost_batch *batch,
201
const union pipe_color_union *color,
202
double depth, unsigned stencil);
205
panfrost_batch_union_scissor(struct panfrost_batch *batch,
206
unsigned minx, unsigned miny,
207
unsigned maxx, unsigned maxy);
210
panfrost_batch_skip_rasterization(struct panfrost_batch *batch);