Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/panfrost/pan_job.h
4570 views
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_cs.h"
32
#include "pan_mempool.h"
33
#include "pan_resource.h"
34
#include "pan_scoreboard.h"
35
36
/* A panfrost_batch corresponds to a bound FBO we're rendering to,
37
* collecting over multiple draws. */
38
39
struct panfrost_batch {
40
struct panfrost_context *ctx;
41
struct pipe_framebuffer_state key;
42
43
/* Sequence number used to implement LRU eviction when all batch slots are used */
44
uint64_t seqnum;
45
46
/* Buffers cleared (PIPE_CLEAR_* bitmask) */
47
unsigned clear;
48
49
/* Buffers drawn */
50
unsigned draws;
51
52
/* Buffers read */
53
unsigned read;
54
55
/* Buffers needing resolve to memory */
56
unsigned resolve;
57
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
61
* all 16-bytes */
62
63
uint32_t clear_color[PIPE_MAX_COLOR_BUFS][4];
64
float clear_depth;
65
unsigned clear_stencil;
66
67
/* Amount of thread local storage required per thread */
68
unsigned stack_size;
69
70
/* Amount of shared memory needed per workgroup (for compute) */
71
unsigned shared_size;
72
73
/* The bounding box covered by this job, taking scissors into account.
74
* Basically, the bounding box we have to run fragment shaders for */
75
76
unsigned minx, miny;
77
unsigned maxx, maxy;
78
79
/* Acts as a rasterizer discard */
80
bool scissor_culls_everything;
81
82
/* BOs referenced not in the pool */
83
int first_bo, last_bo;
84
unsigned num_bos;
85
struct util_sparse_array bos;
86
87
/* Pool owned by this batch (released when the batch is released) used for temporary descriptors */
88
struct panfrost_pool pool;
89
90
/* Pool also owned by this batch that is not CPU mapped (created as
91
* INVISIBLE) used for private GPU-internal structures, particularly
92
* varyings */
93
struct panfrost_pool invisible_pool;
94
95
/* Job scoreboarding state */
96
struct pan_scoreboard scoreboard;
97
98
/* Polygon list bound to the batch, or NULL if none bound yet */
99
struct panfrost_bo *polygon_list;
100
101
/* Scratchpad BO bound to the batch, or NULL if none bound yet */
102
struct panfrost_bo *scratchpad;
103
104
/* Shared memory BO bound to the batch, or NULL if none bound yet */
105
struct panfrost_bo *shared_memory;
106
107
/* Framebuffer descriptor. */
108
struct panfrost_ptr framebuffer;
109
110
/* Thread local storage descriptor. */
111
struct panfrost_ptr tls;
112
113
/* Tiler context */
114
struct pan_tiler_context tiler_ctx;
115
116
/* Indirect draw data */
117
struct panfrost_ptr indirect_draw_ctx;
118
unsigned indirect_draw_job_id;
119
120
/* Keep the num_work_groups sysval around for indirect dispatch */
121
mali_ptr num_wg_sysval[3];
122
123
/* Cached descriptors */
124
mali_ptr viewport;
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
133
/* Referenced resources for cleanup */
134
struct util_dynarray resources;
135
};
136
137
/* Functions for managing the above */
138
139
struct panfrost_batch *
140
panfrost_get_fresh_batch(struct panfrost_context *ctx,
141
const struct pipe_framebuffer_state *key);
142
143
struct panfrost_batch *
144
panfrost_get_batch_for_fbo(struct panfrost_context *ctx);
145
146
struct panfrost_batch *
147
panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx);
148
149
void
150
panfrost_batch_add_bo(struct panfrost_batch *batch,
151
struct panfrost_bo *bo,
152
enum pipe_shader_type stage);
153
154
void
155
panfrost_batch_read_rsrc(struct panfrost_batch *batch,
156
struct panfrost_resource *rsrc,
157
enum pipe_shader_type stage);
158
159
void
160
panfrost_batch_write_rsrc(struct panfrost_batch *batch,
161
struct panfrost_resource *rsrc,
162
enum pipe_shader_type stage);
163
164
void
165
panfrost_batch_add_fbo_bos(struct panfrost_batch *batch);
166
167
struct panfrost_bo *
168
panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
169
uint32_t create_flags, uint32_t access_flags,
170
const char *label);
171
172
void
173
panfrost_flush_all_batches(struct panfrost_context *ctx);
174
175
void
176
panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
177
struct panfrost_resource *rsrc);
178
179
void
180
panfrost_flush_writer(struct panfrost_context *ctx,
181
struct panfrost_resource *rsrc);
182
183
void
184
panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
185
186
struct panfrost_bo *
187
panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned size, unsigned thread_tls_alloc, unsigned core_count);
188
189
struct panfrost_bo *
190
panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);
191
192
void
193
panfrost_batch_clear(struct panfrost_batch *batch,
194
unsigned buffers,
195
const union pipe_color_union *color,
196
double depth, unsigned stencil);
197
198
void
199
panfrost_batch_union_scissor(struct panfrost_batch *batch,
200
unsigned minx, unsigned miny,
201
unsigned maxx, unsigned maxy);
202
203
void
204
panfrost_batch_intersection_scissor(struct panfrost_batch *batch,
205
unsigned minx, unsigned miny,
206
unsigned maxx, unsigned maxy);
207
208
mali_ptr
209
panfrost_batch_get_bifrost_tiler(struct panfrost_batch *batch, unsigned vertex_count);
210
211
#endif
212
213