Path: blob/21.2-virgl/src/gallium/drivers/panfrost/pan_job.h
4570 views
/*1* Copyright (C) 2019 Alyssa Rosenzweig2* Copyright (C) 2014-2017 Broadcom3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23*/2425#ifndef __PAN_JOB_H__26#define __PAN_JOB_H__2728#include "util/u_dynarray.h"29#include "pipe/p_state.h"30#include "pan_cs.h"31#include "pan_mempool.h"32#include "pan_resource.h"33#include "pan_scoreboard.h"3435/* A panfrost_batch corresponds to a bound FBO we're rendering to,36* collecting over multiple draws. */3738struct panfrost_batch {39struct panfrost_context *ctx;40struct pipe_framebuffer_state key;4142/* Sequence number used to implement LRU eviction when all batch slots are used */43uint64_t seqnum;4445/* Buffers cleared (PIPE_CLEAR_* bitmask) */46unsigned clear;4748/* Buffers drawn */49unsigned draws;5051/* Buffers read */52unsigned read;5354/* Buffers needing resolve to memory */55unsigned resolve;5657/* Packed clear values, indexed by both render target as well as word.58* Essentially, a single pixel is packed, with some padding to bring it59* up to a 32-bit interval; that pixel is then duplicated over to fill60* all 16-bytes */6162uint32_t clear_color[PIPE_MAX_COLOR_BUFS][4];63float clear_depth;64unsigned clear_stencil;6566/* Amount of thread local storage required per thread */67unsigned stack_size;6869/* Amount of shared memory needed per workgroup (for compute) */70unsigned shared_size;7172/* The bounding box covered by this job, taking scissors into account.73* Basically, the bounding box we have to run fragment shaders for */7475unsigned minx, miny;76unsigned maxx, maxy;7778/* Acts as a rasterizer discard */79bool scissor_culls_everything;8081/* BOs referenced not in the pool */82int first_bo, last_bo;83unsigned num_bos;84struct util_sparse_array bos;8586/* Pool owned by this batch (released when the batch is released) used for temporary descriptors */87struct panfrost_pool pool;8889/* Pool also owned by this batch that is not CPU mapped (created as90* INVISIBLE) used for private GPU-internal structures, particularly91* varyings */92struct panfrost_pool invisible_pool;9394/* Job scoreboarding state */95struct pan_scoreboard scoreboard;9697/* Polygon list bound to the batch, or NULL if none bound yet */98struct panfrost_bo *polygon_list;99100/* Scratchpad BO bound to the batch, or NULL if none bound yet */101struct panfrost_bo *scratchpad;102103/* Shared memory BO bound to the batch, or NULL if none bound yet */104struct panfrost_bo *shared_memory;105106/* Framebuffer descriptor. */107struct panfrost_ptr framebuffer;108109/* Thread local storage descriptor. */110struct panfrost_ptr tls;111112/* Tiler context */113struct pan_tiler_context tiler_ctx;114115/* Indirect draw data */116struct panfrost_ptr indirect_draw_ctx;117unsigned indirect_draw_job_id;118119/* Keep the num_work_groups sysval around for indirect dispatch */120mali_ptr num_wg_sysval[3];121122/* Cached descriptors */123mali_ptr viewport;124mali_ptr rsd[PIPE_SHADER_TYPES];125mali_ptr textures[PIPE_SHADER_TYPES];126mali_ptr samplers[PIPE_SHADER_TYPES];127mali_ptr attribs[PIPE_SHADER_TYPES];128mali_ptr attrib_bufs[PIPE_SHADER_TYPES];129mali_ptr uniform_buffers[PIPE_SHADER_TYPES];130mali_ptr push_uniforms[PIPE_SHADER_TYPES];131132/* Referenced resources for cleanup */133struct util_dynarray resources;134};135136/* Functions for managing the above */137138struct panfrost_batch *139panfrost_get_fresh_batch(struct panfrost_context *ctx,140const struct pipe_framebuffer_state *key);141142struct panfrost_batch *143panfrost_get_batch_for_fbo(struct panfrost_context *ctx);144145struct panfrost_batch *146panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx);147148void149panfrost_batch_add_bo(struct panfrost_batch *batch,150struct panfrost_bo *bo,151enum pipe_shader_type stage);152153void154panfrost_batch_read_rsrc(struct panfrost_batch *batch,155struct panfrost_resource *rsrc,156enum pipe_shader_type stage);157158void159panfrost_batch_write_rsrc(struct panfrost_batch *batch,160struct panfrost_resource *rsrc,161enum pipe_shader_type stage);162163void164panfrost_batch_add_fbo_bos(struct panfrost_batch *batch);165166struct panfrost_bo *167panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,168uint32_t create_flags, uint32_t access_flags,169const char *label);170171void172panfrost_flush_all_batches(struct panfrost_context *ctx);173174void175panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,176struct panfrost_resource *rsrc);177178void179panfrost_flush_writer(struct panfrost_context *ctx,180struct panfrost_resource *rsrc);181182void183panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);184185struct panfrost_bo *186panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned size, unsigned thread_tls_alloc, unsigned core_count);187188struct panfrost_bo *189panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);190191void192panfrost_batch_clear(struct panfrost_batch *batch,193unsigned buffers,194const union pipe_color_union *color,195double depth, unsigned stencil);196197void198panfrost_batch_union_scissor(struct panfrost_batch *batch,199unsigned minx, unsigned miny,200unsigned maxx, unsigned maxy);201202void203panfrost_batch_intersection_scissor(struct panfrost_batch *batch,204unsigned minx, unsigned miny,205unsigned maxx, unsigned maxy);206207mali_ptr208panfrost_batch_get_bifrost_tiler(struct panfrost_batch *batch, unsigned vertex_count);209210#endif211212213