"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/drivers/panfrost/pan_job.h" (16 Sep 2020, 8514 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pan_job.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 20.1.5_vs_20.2.0-rc1.

    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_allocate.h"
   32 #include "pan_resource.h"
   33 
   34 /* panfrost_batch_fence is the out fence of a batch that users or other batches
   35  * might want to wait on. The batch fence lifetime is different from the batch
   36  * one as want will certainly want to wait upon the fence after the batch has
   37  * been submitted (which is when panfrost_batch objects are freed).
   38  */
   39 struct panfrost_batch_fence {
   40         /* Refcounting object for the fence. */
   41         struct pipe_reference reference;
   42 
   43         /* Batch that created this fence object. Will become NULL at batch
   44          * submission time. This field is mainly here to know whether the
   45          * batch has been flushed or not.
   46          */
   47         struct panfrost_batch *batch;
   48 
   49         /* Context this fence is attached to. We need both ctx and batch, as
   50          * the batch will go away after it's been submitted, but the fence
   51          * will stay a bit longer.
   52          */
   53         struct panfrost_context *ctx;
   54 
   55         /* Sync object backing this fence. */
   56         uint32_t syncobj;
   57 
   58         /* Cached value of the signaled state to avoid calling WAIT_SYNCOBJs
   59          * when we know the fence has already been signaled.
   60          */
   61         bool signaled;
   62 };
   63 
   64 #define PAN_REQ_MSAA            (1 << 0)
   65 #define PAN_REQ_DEPTH_WRITE     (1 << 1)
   66 
   67 /* A panfrost_batch corresponds to a bound FBO we're rendering to,
   68  * collecting over multiple draws. */
   69 
   70 struct panfrost_batch {
   71         struct panfrost_context *ctx;
   72         struct pipe_framebuffer_state key;
   73 
   74         /* Buffers cleared (PIPE_CLEAR_* bitmask) */
   75         unsigned clear;
   76 
   77         /* Packed clear values, indexed by both render target as well as word.
   78          * Essentially, a single pixel is packed, with some padding to bring it
   79          * up to a 32-bit interval; that pixel is then duplicated over to fill
   80          * all 16-bytes */
   81 
   82         uint32_t clear_color[PIPE_MAX_COLOR_BUFS][4];
   83         float clear_depth;
   84         unsigned clear_stencil;
   85 
   86         /* Amount of thread local storage required per thread */
   87         unsigned stack_size;
   88 
   89         /* Amount of shared memory needed per workgroup (for compute) */
   90         unsigned shared_size;
   91 
   92         /* Whether this job uses the corresponding requirement (PAN_REQ_*
   93          * bitmask) */
   94         unsigned requirements;
   95 
   96         /* The bounding box covered by this job, taking scissors into account.
   97          * Basically, the bounding box we have to run fragment shaders for */
   98 
   99         unsigned minx, miny;
  100         unsigned maxx, maxy;
  101 
  102         /* The first job in the batch */
  103         mali_ptr first_job;
  104 
  105         /* The number of jobs in the primary batch, essentially */
  106         unsigned job_index;
  107 
  108         /* A CPU-side pointer to the previous job for next_job linking */
  109         struct mali_job_descriptor_header *prev_job;
  110 
  111         /* The dependency for tiler jobs (i.e. the index of the last emitted
  112          * tiler job, or zero if none have been emitted) */
  113         unsigned tiler_dep;
  114 
  115         /* The job index of the WRITE_VALUE job (before it has been created) */
  116         unsigned write_value_index;
  117 
  118         /* BOs referenced -- will be used for flushing logic */
  119         struct hash_table *bos;
  120 
  121         /* Current transient BO */
  122     struct panfrost_bo *transient_bo;
  123 
  124         /* Within the topmost transient BO, how much has been used? */
  125         unsigned transient_offset;
  126 
  127         /* Polygon list bound to the batch, or NULL if none bound yet */
  128         struct panfrost_bo *polygon_list;
  129 
  130         /* Scratchpad BO bound to the batch, or NULL if none bound yet */
  131         struct panfrost_bo *scratchpad;
  132 
  133         /* Shared memory BO bound to the batch, or NULL if none bound yet */
  134         struct panfrost_bo *shared_memory;
  135 
  136         /* Tiler heap BO bound to the batch, or NULL if none bound yet */
  137         struct panfrost_bo *tiler_heap;
  138 
  139         /* Dummy tiler BO bound to the batch, or NULL if none bound yet */
  140         struct panfrost_bo *tiler_dummy;
  141 
  142         /* Framebuffer descriptor. */
  143         struct panfrost_transfer framebuffer;
  144 
  145         /* Bifrost tiler meta descriptor. */
  146         mali_ptr tiler_meta;
  147 
  148         /* Output sync object. Only valid when submitted is true. */
  149         struct panfrost_batch_fence *out_sync;
  150 
  151         /* Batch dependencies */
  152         struct util_dynarray dependencies;
  153 };
  154 
  155 /* Functions for managing the above */
  156 
  157 void
  158 panfrost_batch_fence_unreference(struct panfrost_batch_fence *fence);
  159 
  160 void
  161 panfrost_batch_fence_reference(struct panfrost_batch_fence *batch);
  162 
  163 struct panfrost_batch *
  164 panfrost_get_batch_for_fbo(struct panfrost_context *ctx);
  165 
  166 struct panfrost_batch *
  167 panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx);
  168 
  169 void
  170 panfrost_batch_init(struct panfrost_context *ctx);
  171 
  172 void
  173 panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo,
  174                       uint32_t flags);
  175 
  176 void panfrost_batch_add_fbo_bos(struct panfrost_batch *batch);
  177 
  178 struct panfrost_bo *
  179 panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
  180                          uint32_t create_flags, uint32_t access_flags);
  181 
  182 void
  183 panfrost_flush_all_batches(struct panfrost_context *ctx, bool wait);
  184 
  185 bool
  186 panfrost_pending_batches_access_bo(struct panfrost_context *ctx,
  187                                    const struct panfrost_bo *bo);
  188 
  189 void
  190 panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx,
  191                                     struct panfrost_bo *bo, uint32_t flags);
  192 
  193 void
  194 panfrost_batch_set_requirements(struct panfrost_batch *batch);
  195 
  196 void
  197 panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
  198 
  199 struct panfrost_bo *
  200 panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned shift, unsigned thread_tls_alloc, unsigned core_count);
  201 
  202 struct panfrost_bo *
  203 panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);
  204 
  205 mali_ptr
  206 panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size);
  207 
  208 struct panfrost_bo *
  209 panfrost_batch_get_tiler_heap(struct panfrost_batch *batch);
  210 
  211 struct panfrost_bo *
  212 panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch);
  213 
  214 void
  215 panfrost_batch_clear(struct panfrost_batch *batch,
  216                      unsigned buffers,
  217                      const union pipe_color_union *color,
  218                      double depth, unsigned stencil);
  219 
  220 void
  221 panfrost_batch_union_scissor(struct panfrost_batch *batch,
  222                              unsigned minx, unsigned miny,
  223                              unsigned maxx, unsigned maxy);
  224 
  225 void
  226 panfrost_batch_intersection_scissor(struct panfrost_batch *batch,
  227                                     unsigned minx, unsigned miny,
  228                                     unsigned maxx, unsigned maxy);
  229 
  230 /* Scoreboarding */
  231 
  232 unsigned
  233 panfrost_new_job(
  234                 struct panfrost_batch *batch,
  235                 enum mali_job_type type,
  236                 bool barrier,
  237                 unsigned local_dep,
  238                 void *payload, size_t payload_size,
  239                 bool inject);
  240 
  241 void panfrost_scoreboard_initialize_tiler(struct panfrost_batch *batch);
  242 
  243 bool
  244 panfrost_batch_is_scanout(struct panfrost_batch *batch);
  245 
  246 mali_ptr
  247 panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_count);
  248 
  249 #endif