panfrost: Move JM specific fields to their own struct

In preparation of CSF support addition, we move any JM related bits out
of panfrost_batch into a panfrost_jm_batch struct that's embedded in
panfrost_batch inside an anonymous union. This way, we can easily
specialize things for CSF without polluting the panfrost_batch object
with CSF-specific fields.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26249>
This commit is contained in:
Boris Brezillon
2023-11-15 13:10:12 +01:00
committed by Marge Bot
parent 9de3ff9a78
commit 44bd7067b7
3 changed files with 66 additions and 25 deletions

View File

@@ -2569,12 +2569,13 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
const struct panfrost_ptr *vertex_job,
const struct panfrost_ptr *tiler_job)
{
unsigned vertex = panfrost_add_job(&batch->pool.base, &batch->scoreboard,
unsigned vertex = panfrost_add_job(&batch->pool.base, &batch->jm.jobs.vtc_jc,
MALI_JOB_TYPE_VERTEX, false, false, 0, 0,
vertex_job, false);
panfrost_add_job(&batch->pool.base, &batch->scoreboard, MALI_JOB_TYPE_TILER,
false, false, vertex, 0, tiler_job, false);
panfrost_add_job(&batch->pool.base, &batch->jm.jobs.vtc_jc,
MALI_JOB_TYPE_TILER, false, false, vertex, 0, tiler_job,
false);
}
#endif
@@ -2677,7 +2678,7 @@ emit_fragment_job(struct panfrost_batch *batch, const struct pan_fb_info *pfb)
pan_pool_alloc_desc(&batch->pool.base, FRAGMENT_JOB);
GENX(pan_emit_fragment_job)(pfb, batch->framebuffer.gpu, transfer.cpu);
batch->frag_job = transfer.gpu;
batch->jm.jobs.frag = transfer.gpu;
}
#define DEFINE_CASE(c) \
@@ -3523,7 +3524,7 @@ panfrost_launch_xfb(struct panfrost_batch *batch,
#if PAN_ARCH <= 5
job_type = MALI_JOB_TYPE_VERTEX;
#endif
panfrost_add_job(&batch->pool.base, &batch->scoreboard, job_type, true,
panfrost_add_job(&batch->pool.base, &batch->jm.jobs.vtc_jc, job_type, true,
false, 0, 0, &t, false);
batch->compute_count++;
@@ -3692,7 +3693,7 @@ panfrost_direct_draw(struct panfrost_batch *batch,
panfrost_emit_malloc_vertex(batch, info, draw, secondary_shader, tiler.cpu);
panfrost_add_job(&batch->pool.base, &batch->scoreboard,
panfrost_add_job(&batch->pool.base, &batch->jm.jobs.vtc_jc,
MALI_JOB_TYPE_MALLOC_VERTEX, false, false, 0, 0, &tiler,
false);
#else
@@ -3704,7 +3705,7 @@ panfrost_direct_draw(struct panfrost_batch *batch,
panfrost_draw_emit_vertex_section(
batch, pan_section_ptr(tiler.cpu, INDEXED_VERTEX_JOB, VERTEX_DRAW));
panfrost_add_job(&batch->pool.base, &batch->scoreboard,
panfrost_add_job(&batch->pool.base, &batch->jm.jobs.vtc_jc,
MALI_JOB_TYPE_INDEXED_VERTEX, false, false, 0, 0, &tiler,
false);
#endif
@@ -3923,11 +3924,11 @@ panfrost_launch_grid_on_batch(struct pipe_context *pipe,
};
indirect_dep = GENX(pan_indirect_dispatch_emit)(
&batch->pool.base, &batch->scoreboard, &indirect);
&batch->pool.base, &batch->jm.jobs.vtc_jc, &indirect);
}
#endif
panfrost_add_job(&batch->pool.base, &batch->scoreboard,
panfrost_add_job(&batch->pool.base, &batch->jm.jobs.vtc_jc,
MALI_JOB_TYPE_COMPUTE, true, false, indirect_dep, 0, &t,
false);
batch->compute_count++;
@@ -4516,7 +4517,7 @@ static void
preload(struct panfrost_batch *batch, struct pan_fb_info *fb)
{
GENX(pan_preload_fb)
(&batch->pool.base, &batch->scoreboard, fb, batch->tls.gpu,
(&batch->pool.base, &batch->jm.jobs.vtc_jc, fb, batch->tls.gpu,
PAN_ARCH >= 6 ? batch->tiler_ctx.bifrost : 0, NULL);
}
@@ -4634,8 +4635,8 @@ init_polygon_list(struct panfrost_batch *batch)
{
#if PAN_ARCH <= 5
mali_ptr polygon_list = batch_get_polygon_list(batch);
panfrost_scoreboard_initialize_tiler(&batch->pool.base, &batch->scoreboard,
polygon_list);
panfrost_scoreboard_initialize_tiler(&batch->pool.base,
&batch->jm.jobs.vtc_jc, polygon_list);
#endif
}
@@ -4718,7 +4719,7 @@ panfrost_batch_submit_ioctl(struct panfrost_batch *batch,
* least one tiler job. Tiler heap is written by tiler jobs and read
* by fragment jobs (the polygon list is coming from this heap).
*/
if (batch->scoreboard.first_tiler)
if (batch->jm.jobs.vtc_jc.first_tiler)
bo_handles[submit.bo_handle_count++] = dev->tiler_heap->gem_handle;
/* Always used on Bifrost, occassionally used on Midgard */
@@ -4762,8 +4763,8 @@ panfrost_batch_submit_jobs(struct panfrost_batch *batch)
{
struct pipe_screen *pscreen = batch->ctx->base.screen;
struct panfrost_device *dev = pan_device(pscreen);
bool has_draws = batch->scoreboard.first_job;
bool has_tiler = batch->scoreboard.first_tiler;
bool has_draws = batch->jm.jobs.vtc_jc.first_job;
bool has_tiler = batch->jm.jobs.vtc_jc.first_tiler;
bool has_frag = panfrost_has_fragment_job(batch);
uint32_t out_sync = batch->ctx->syncobj;
int ret = 0;
@@ -4776,15 +4777,15 @@ panfrost_batch_submit_jobs(struct panfrost_batch *batch)
pthread_mutex_lock(&dev->submit_lock);
if (has_draws) {
ret = panfrost_batch_submit_ioctl(batch, batch->scoreboard.first_job, 0,
has_frag ? 0 : out_sync);
ret = panfrost_batch_submit_ioctl(batch, batch->jm.jobs.vtc_jc.first_job,
0, has_frag ? 0 : out_sync);
if (ret)
goto done;
}
if (has_frag) {
ret = panfrost_batch_submit_ioctl(batch, batch->frag_job,
ret = panfrost_batch_submit_ioctl(batch, batch->jm.jobs.frag,
PANFROST_JD_REQ_FS, out_sync);
if (ret)
goto done;

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 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_JM_H__
#define __PAN_JM_H__
#include "pan_scoreboard.h"
struct panfrost_jm_batch {
/* Job related fields. */
struct {
/* Vertex/tiler/compute job chain. */
struct pan_scoreboard vtc_jc;
/* Fragment job, only one per batch. */
mali_ptr frag;
} jobs;
};
#endif

View File

@@ -29,9 +29,9 @@
#include "pipe/p_state.h"
#include "util/u_dynarray.h"
#include "pan_cs.h"
#include "pan_jm.h"
#include "pan_mempool.h"
#include "pan_resource.h"
#include "pan_scoreboard.h"
/* Simple tri-state data structure. In the default "don't care" state, the value
* may be set to true or false. However, once the value is set, it must not be
@@ -139,12 +139,6 @@ struct panfrost_batch {
* varyings */
struct panfrost_pool invisible_pool;
/* Job scoreboarding state */
struct pan_scoreboard scoreboard;
/* Fragment job GPU address */
mali_ptr frag_job;
/* Scratchpad BO bound to the batch, or NULL if none bound yet */
struct panfrost_bo *scratchpad;
@@ -214,6 +208,11 @@ struct panfrost_batch {
/* Number of compute jobs in the batch. */
uint32_t compute_count;
/* Job frontend specific fields. */
union {
struct panfrost_jm_batch jm;
};
};
/* Functions for managing the above */