freedreno: Remap high/norm/low priorities

At the gallium level, we only have three priorities.  But if kernel
supports preemption we'll have 3*nr_rings priority levels.  We'd prefer
to have the priorities that userspace picks be distributed over the
entire range of priorities so that preemption can work.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18584>
This commit is contained in:
Rob Clark 2022-09-13 11:14:46 -07:00 committed by Marge Bot
parent 2451c30c11
commit 8192772c0a
3 changed files with 20 additions and 4 deletions

View file

@ -591,15 +591,15 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
{
struct fd_screen *screen = fd_screen(pscreen);
struct pipe_context *pctx;
unsigned prio = 1;
unsigned prio = screen->prio_norm;
/* lower numerical value == higher priority: */
if (FD_DBG(HIPRIO))
prio = 0;
prio = screen->prio_high;
else if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
prio = 0;
prio = screen->prio_high;
else if (flags & PIPE_CONTEXT_LOW_PRIORITY)
prio = 2;
prio = screen->prio_low;
/* Some of the stats will get printed out at context destroy, so
* make sure they are collected:

View file

@ -1037,6 +1037,21 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro,
} else {
/* # of rings equates to number of unique priority values: */
screen->priority_mask = (1 << val) - 1;
/* Lowest numerical value (ie. zero) is highest priority: */
screen->prio_high = 0;
/* Highest numerical value is lowest priority: */
screen->prio_low = val - 1;
/* Pick midpoint for normal priority.. note that whatever the
* range of possible priorities, since we divide by 2 the
* result will either be an integer or an integer plus 0.5,
* in which case it will round down to an integer, so int
* division will give us an appropriate result in either
* case:
*/
screen->prio_norm = val / 2;
}
if (fd_device_version(dev) >= FD_VERSION_ROBUSTNESS)

View file

@ -89,6 +89,7 @@ struct fd_screen {
uint32_t ram_size;
uint32_t max_rts; /* max # of render targets */
uint32_t priority_mask;
unsigned prio_low, prio_norm, prio_high; /* remap low/norm/high priority to kernel priority */
bool has_timestamp;
bool has_robustness;
bool has_syncobj;