~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/panfrost/pan_job.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
        mali_ptr depth_stencil;
133
 
        mali_ptr blend;
134
 
 
135
 
        /* Valhall: struct mali_scissor_packed */
136
 
        unsigned scissor[2];
137
 
        float minimum_z, maximum_z;
138
 
 
139
 
        /* Used on Valhall only. Midgard includes attributes in-band with
140
 
         * attributes, wildly enough.
141
 
         */
142
 
        mali_ptr images[PIPE_SHADER_TYPES];
143
 
 
144
 
        /* Referenced resources */
145
 
        struct set *resources;
146
 
};
147
 
 
148
 
/* Functions for managing the above */
149
 
 
150
 
struct panfrost_batch *
151
 
panfrost_get_batch_for_fbo(struct panfrost_context *ctx);
152
 
 
153
 
struct panfrost_batch *
154
 
panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx, const char *reason);
155
 
 
156
 
void
157
 
panfrost_batch_add_bo(struct panfrost_batch *batch,
158
 
                      struct panfrost_bo *bo,
159
 
                      enum pipe_shader_type stage);
160
 
 
161
 
void
162
 
panfrost_batch_read_rsrc(struct panfrost_batch *batch,
163
 
                         struct panfrost_resource *rsrc,
164
 
                         enum pipe_shader_type stage);
165
 
 
166
 
void
167
 
panfrost_batch_write_rsrc(struct panfrost_batch *batch,
168
 
                          struct panfrost_resource *rsrc,
169
 
                          enum pipe_shader_type stage);
170
 
 
171
 
struct panfrost_bo *
172
 
panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
173
 
                         uint32_t create_flags, uint32_t access_flags,
174
 
                         const char *label);
175
 
 
176
 
void
177
 
panfrost_flush_all_batches(struct panfrost_context *ctx, const char *reason);
178
 
 
179
 
void
180
 
panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
181
 
                                      struct panfrost_resource *rsrc,
182
 
                                      const char *reason);
183
 
 
184
 
void
185
 
panfrost_flush_writer(struct panfrost_context *ctx,
186
 
                      struct panfrost_resource *rsrc,
187
 
                      const char *reason);
188
 
 
189
 
void
190
 
panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
191
 
 
192
 
struct panfrost_bo *
193
 
panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned size, unsigned thread_tls_alloc, unsigned core_count);
194
 
 
195
 
struct panfrost_bo *
196
 
panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);
197
 
 
198
 
void
199
 
panfrost_batch_clear(struct panfrost_batch *batch,
200
 
                     unsigned buffers,
201
 
                     const union pipe_color_union *color,
202
 
                     double depth, unsigned stencil);
203
 
 
204
 
void
205
 
panfrost_batch_union_scissor(struct panfrost_batch *batch,
206
 
                             unsigned minx, unsigned miny,
207
 
                             unsigned maxx, unsigned maxy);
208
 
 
209
 
bool
210
 
panfrost_batch_skip_rasterization(struct panfrost_batch *batch);
211
 
 
212
 
#endif