diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 3eabb6f837e..0daeb43fa68 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index febe9fe9639..660d0b266f8 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_csf.c b/src/gallium/drivers/panfrost/pan_csf.c index f196880a31c..d505aa693b1 100644 --- a/src/gallium/drivers/panfrost/pan_csf.c +++ b/src/gallium/drivers/panfrost/pan_csf.c @@ -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), }; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 8bd4a7c39b2..13e7f33e635 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -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));