panfrost: Add helpers to support indirect draws

Indirect draws are implemented with compute jobs patching the
vertex/tiler jobs. Provide helpers to do that.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8700>
This commit is contained in:
Boris Brezillon 2021-01-25 13:14:49 +01:00 committed by Marge Bot
parent 9a08c9097f
commit 2e6d94c198
6 changed files with 1428 additions and 0 deletions

View File

@ -49,6 +49,7 @@
#include "pan_resource.h"
#include "pan_public.h"
#include "pan_util.h"
#include "pan_indirect_draw.h"
#include "decode.h"
#include "pan_context.h"

View File

@ -39,6 +39,8 @@ lib_FILES := \
lib/pan_device.h \
lib/pan_encoder.h \
lib/pan_format.c \
lib/pan_indirect_draw.c \
lib/pan_indirect_draw.h \
lib/pan_invocation.c \
lib/pan_pool.c \
lib/pan_pool.h \

View File

@ -28,6 +28,7 @@ libpanfrost_lib_files = files(
'pan_blend.c',
'pan_blit.c',
'pan_format.c',
'pan_indirect_draw.c',
'pan_invocation.c',
'pan_sampler.c',
'pan_samples.c',

View File

@ -37,6 +37,9 @@
#include "util/list.h"
#include "util/sparse_array.h"
#include "panfrost/util/pan_ir.h"
#include "pan_pool.h"
#include <midgard_pack.h>
/* Driver limits */
@ -94,6 +97,55 @@ struct pan_blend_shaders {
pthread_mutex_t lock;
};
enum pan_indirect_draw_flags {
PAN_INDIRECT_DRAW_NO_INDEX = 0 << 0,
PAN_INDIRECT_DRAW_1B_INDEX = 1 << 0,
PAN_INDIRECT_DRAW_2B_INDEX = 2 << 0,
PAN_INDIRECT_DRAW_4B_INDEX = 3 << 0,
PAN_INDIRECT_DRAW_INDEX_SIZE_MASK = 3 << 0,
PAN_INDIRECT_DRAW_HAS_PSIZ = 1 << 2,
PAN_INDIRECT_DRAW_PRIMITIVE_RESTART = 1 << 3,
PAN_INDIRECT_DRAW_UPDATE_PRIM_SIZE = 1 << 4,
PAN_INDIRECT_DRAW_LAST_FLAG = PAN_INDIRECT_DRAW_UPDATE_PRIM_SIZE,
PAN_INDIRECT_DRAW_FLAGS_MASK = (PAN_INDIRECT_DRAW_LAST_FLAG << 1) - 1,
PAN_INDIRECT_DRAW_MIN_MAX_SEARCH_1B_INDEX = PAN_INDIRECT_DRAW_LAST_FLAG << 1,
PAN_INDIRECT_DRAW_MIN_MAX_SEARCH_2B_INDEX,
PAN_INDIRECT_DRAW_MIN_MAX_SEARCH_4B_INDEX,
PAN_INDIRECT_DRAW_NUM_SHADERS,
};
struct pan_indirect_draw_shader {
struct panfrost_ubo_push push;
mali_ptr rsd;
};
struct pan_indirect_draw_shaders {
struct pan_indirect_draw_shader shaders[PAN_INDIRECT_DRAW_NUM_SHADERS];
/* Take the lock when initializing the draw shaders context or when
* allocating from the binary pool.
*/
pthread_mutex_t lock;
/* A memory pool for shader binaries. We currently don't allocate a
* single BO for all shaders up-front because estimating shader size
* is not trivial, and changes to the compiler might influence this
* estimation.
*/
struct pan_pool bin_pool;
/* BO containing all renderer states attached to the compute shaders.
* Those are built at shader compilation time and re-used every time
* panfrost_emit_indirect_draw() is called.
*/
struct panfrost_bo *states;
/* Varying memory is allocated dynamically by compute jobs from this
* heap.
*/
struct panfrost_bo *varying_heap;
};
typedef uint32_t mali_pixel_format;
struct panfrost_format {
@ -149,6 +201,7 @@ struct panfrost_device {
struct pan_blit_shaders blit_shaders;
struct pan_blend_shaders blend_shaders;
struct pan_indirect_draw_shaders indirect_draw_shaders;
/* Tiler heap shared across all tiler jobs, allocated against the
* device since there's only a single tiler. Since this is invisible to

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2021 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __PAN_INDIRECT_DRAW_SHADERS_H__
#define __PAN_INDIRECT_DRAW_SHADERS_H__
struct pan_device;
struct pan_scoreboard;
struct pan_pool;
struct pan_indirect_draw_info {
mali_ptr draw_buf;
mali_ptr index_buf;
mali_ptr vertex_job;
mali_ptr tiler_job;
mali_ptr attrib_bufs;
mali_ptr attribs;
mali_ptr varying_bufs;
unsigned attrib_count;
uint32_t restart_index;
unsigned flags;
unsigned index_size;
unsigned last_indirect_draw;
};
unsigned
panfrost_emit_indirect_draw(struct pan_pool *pool,
struct pan_scoreboard *scoreboard,
const struct pan_indirect_draw_info *draw_info,
struct panfrost_ptr *ctx);
void
panfrost_init_indirect_draw_shaders(struct panfrost_device *dev);
void
panfrost_cleanup_indirect_draw_shaders(struct panfrost_device *dev);
#endif