panfrost: Implement context priority on v10

This implement PIPE_CAP_CONTEXT_PRIORITY_MASK and handle priority flags
for v10.

This effectively expose EGL_IMG_context_priority and
EGL_NV_context_priority_realtime.

Expose of what is currently supported from the panthor uAPI.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30991>
This commit is contained in:
Mary Guillemard
2024-09-04 12:58:14 +02:00
committed by Marge Bot
parent 83bc9bb1af
commit d4cb32f42f
4 changed files with 44 additions and 1 deletions

View File

@@ -989,6 +989,8 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
if (!ctx)
return NULL;
ctx->flags = flags;
struct pipe_context *gallium = (struct pipe_context *)ctx;
struct panfrost_device *dev = pan_device(screen);

View File

@@ -124,6 +124,9 @@ struct panfrost_context {
/* Gallium context */
struct pipe_context base;
/* Context flags */
unsigned flags;
/* Dirty global state */
enum pan_dirty_3d dirty;

View File

@@ -1024,6 +1024,19 @@ GENX(csf_launch_draw_indirect)(struct panfrost_batch *batch,
#define POSITION_FIFO_SIZE (64 * 1024)
static enum drm_panthor_group_priority
get_panthor_group_priority(struct panfrost_context *ctx)
{
if (ctx->flags & PIPE_CONTEXT_REALTIME_PRIORITY)
return PANTHOR_GROUP_PRIORITY_REALTIME;
else if (ctx->flags & PIPE_CONTEXT_HIGH_PRIORITY)
return PANTHOR_GROUP_PRIORITY_HIGH;
else if (ctx->flags & PIPE_CONTEXT_LOW_PRIORITY)
return PANTHOR_GROUP_PRIORITY_LOW;
return PANTHOR_GROUP_PRIORITY_MEDIUM;
}
int
GENX(csf_init_context)(struct panfrost_context *ctx)
{
@@ -1040,7 +1053,7 @@ GENX(csf_init_context)(struct panfrost_context *ctx)
.max_compute_cores = util_bitcount64(dev->kmod.props.shader_present),
.max_fragment_cores = util_bitcount64(dev->kmod.props.shader_present),
.max_tiler_cores = 1,
.priority = PANTHOR_GROUP_PRIORITY_MEDIUM,
.priority = get_panthor_group_priority(ctx),
.queues = DRM_PANTHOR_OBJ_ARRAY(ARRAY_SIZE(qc), qc),
.vm_id = pan_kmod_vm_handle(dev->kmod.vm),
};

View File

@@ -98,6 +98,27 @@ panfrost_get_device_vendor(struct pipe_screen *screen)
return "Arm";
}
static int
from_kmod_group_allow_priority_flags(
enum pan_kmod_group_allow_priority_flags kmod_flags)
{
int flags = 0;
if (kmod_flags & PAN_KMOD_GROUP_ALLOW_PRIORITY_REALTIME)
flags |= PIPE_CONTEXT_PRIORITY_REALTIME;
if (kmod_flags & PAN_KMOD_GROUP_ALLOW_PRIORITY_HIGH)
flags |= PIPE_CONTEXT_PRIORITY_HIGH;
if (kmod_flags & PAN_KMOD_GROUP_ALLOW_PRIORITY_MEDIUM)
flags |= PIPE_CONTEXT_PRIORITY_MEDIUM;
if (kmod_flags & PAN_KMOD_GROUP_ALLOW_PRIORITY_LOW)
flags |= PIPE_CONTEXT_PRIORITY_LOW;
return flags;
}
static int
panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
{
@@ -377,6 +398,10 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_NATIVE_FENCE_FD:
return 1;
case PIPE_CAP_CONTEXT_PRIORITY_MASK:
return from_kmod_group_allow_priority_flags(
dev->kmod.props.allowed_group_priorities_mask);
case PIPE_CAP_ASTC_DECODE_MODE:
return dev->arch >= 9 && (dev->compressed_formats & (1 << 30));