diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 1188f6390cd..c7257068ca6 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -382,7 +382,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, slab_create_child(&r300->pool_transfers, &r300screen->pool_transfers); - r300->ctx = rws->ctx_create(rws, RADEON_CTX_PRIORITY_MEDIUM, false); + r300->ctx = rws->ctx_create(rws, flags); if (!r300->ctx) goto fail; diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c index c668616c2b2..e5ad890ee46 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.c +++ b/src/gallium/drivers/r600/r600_pipe_common.c @@ -622,7 +622,7 @@ bool r600_common_context_init(struct r600_common_context *rctx, if (!rctx->b.const_uploader) return false; - rctx->ctx = rctx->ws->ctx_create(rctx->ws, RADEON_CTX_PRIORITY_MEDIUM, false); + rctx->ctx = rctx->ws->ctx_create(rctx->ws, context_flags); if (!rctx->ctx) return false; diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c index 1486f7ecada..939cbf89038 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c @@ -2882,8 +2882,7 @@ struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context, goto err; for (i = 0; i < dec->njctx; i++) { /* Initialize the context handle and the command stream. */ - dec->jctx[i] = dec->ws->ctx_create(dec->ws, RADEON_CTX_PRIORITY_MEDIUM, - sctx->context_flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET); + dec->jctx[i] = dec->ws->ctx_create(dec->ws, sctx->context_flags); if (!sctx->ctx) goto error; if (!dec->ws->cs_create(&dec->jcs[i], dec->jctx[i], ring, NULL, NULL)) { diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 78b65e89067..948cf9ce95e 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -505,7 +505,6 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign struct si_context *sctx = CALLOC_STRUCT(si_context); struct radeon_winsys *ws = sscreen->ws; int shader, i; - enum radeon_ctx_priority priority; if (!sctx) { fprintf(stderr, "radeonsi: can't allocate a context\n"); @@ -549,26 +548,16 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign } } - if (flags & PIPE_CONTEXT_HIGH_PRIORITY) { - priority = RADEON_CTX_PRIORITY_HIGH; - } else if (flags & PIPE_CONTEXT_LOW_PRIORITY) { - priority = RADEON_CTX_PRIORITY_LOW; - } else { - priority = RADEON_CTX_PRIORITY_MEDIUM; - } - - bool allow_context_lost = flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET; - /* Initialize the context handle and the command stream. */ - sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority, allow_context_lost); - if (!sctx->ctx && priority != RADEON_CTX_PRIORITY_MEDIUM) { + sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags); + if (!sctx->ctx && sctx->context_flags & PIPE_CONTEXT_HIGH_PRIORITY) { /* Context priority should be treated as a hint. If context creation * fails with the requested priority, for example because the caller * lacks CAP_SYS_NICE capability or other system resource constraints, * fallback to normal priority. */ - priority = RADEON_CTX_PRIORITY_MEDIUM; - sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority, allow_context_lost); + sctx->context_flags &= ~PIPE_CONTEXT_HIGH_PRIORITY; + sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags); } if (!sctx->ctx) { fprintf(stderr, "radeonsi: can't create radeon_winsys_ctx\n"); diff --git a/src/gallium/include/winsys/radeon_winsys.h b/src/gallium/include/winsys/radeon_winsys.h index c316201849a..409fb80796f 100644 --- a/src/gallium/include/winsys/radeon_winsys.h +++ b/src/gallium/include/winsys/radeon_winsys.h @@ -133,14 +133,6 @@ enum radeon_value_id RADEON_CS_THREAD_TIME, }; -enum radeon_ctx_priority -{ - RADEON_CTX_PRIORITY_LOW = 0, - RADEON_CTX_PRIORITY_MEDIUM, - RADEON_CTX_PRIORITY_HIGH, - RADEON_CTX_PRIORITY_REALTIME, -}; - enum radeon_ctx_pstate { RADEON_CTX_PSTATE_NONE = 0, @@ -528,13 +520,9 @@ struct radeon_winsys { * Create a command submission context. * Various command streams can be submitted to the same context. * - * \param allow_context_lost If true, lost contexts skip command submission and report - * the reset status. - * If false, losing the context results in undefined behavior. + * \param flags PIPE_CONTEXT_* flags (priority, allow losing the context) */ - struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws, - enum radeon_ctx_priority priority, - bool allow_context_lost); + struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws, unsigned flags); /** * Destroy a context. diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp index fa512190aee..3fbd4a76a83 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp @@ -247,31 +247,15 @@ amdgpu_cs_get_next_fence(struct radeon_cmdbuf *rcs) /* CONTEXTS */ -static uint32_t -radeon_to_amdgpu_priority(enum radeon_ctx_priority radeon_priority) -{ - switch (radeon_priority) { - case RADEON_CTX_PRIORITY_REALTIME: - return AMDGPU_CTX_PRIORITY_VERY_HIGH; - case RADEON_CTX_PRIORITY_HIGH: - return AMDGPU_CTX_PRIORITY_HIGH; - case RADEON_CTX_PRIORITY_MEDIUM: - return AMDGPU_CTX_PRIORITY_NORMAL; - case RADEON_CTX_PRIORITY_LOW: - return AMDGPU_CTX_PRIORITY_LOW; - default: - unreachable("Invalid context priority"); - } -} - -static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws, - enum radeon_ctx_priority priority, - bool allow_context_lost) +static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws, unsigned flags) { struct amdgpu_ctx *ctx = CALLOC_STRUCT(amdgpu_ctx); int r; struct amdgpu_bo_alloc_request alloc_buffer = {}; - uint32_t amdgpu_priority = radeon_to_amdgpu_priority(priority); + assert(!(flags & PIPE_CONTEXT_REALTIME_PRIORITY)); /* not supported */ + uint32_t amdgpu_priority = flags & PIPE_CONTEXT_HIGH_PRIORITY ? AMDGPU_CTX_PRIORITY_HIGH : + flags & PIPE_CONTEXT_LOW_PRIORITY ? AMDGPU_CTX_PRIORITY_LOW : + AMDGPU_CTX_PRIORITY_NORMAL; ac_drm_device *dev; ac_drm_bo buf_handle; @@ -280,8 +264,7 @@ static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws, ctx->aws = amdgpu_winsys(rws); ctx->reference.count = 1; - ctx->allow_context_lost = allow_context_lost; - ctx->priority = priority; + ctx->flags = flags; dev = ctx->aws->dev; @@ -457,7 +440,7 @@ amdgpu_ctx_set_sw_reset_status(struct radeon_winsys_ctx *rwctx, enum pipe_reset_ ctx->sw_status = status; - if (!ctx->allow_context_lost) { + if (!(ctx->flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET)) { va_list args; va_start(args, format); @@ -939,7 +922,7 @@ amdgpu_cs_create(struct radeon_cmdbuf *rcs, } else { switch (ip_type) { case AMD_IP_GFX: - if (ctx->priority >= RADEON_CTX_PRIORITY_HIGH) + if (ctx->flags & PIPE_CONTEXT_HIGH_PRIORITY) acs->queue_index = AMDGPU_QUEUE_GFX_HIGH_PRIO; else acs->queue_index = AMDGPU_QUEUE_GFX; diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h index c655f8a33b9..982ea0b5cb1 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h @@ -31,14 +31,9 @@ struct amdgpu_ctx { uint32_t user_fence_bo_kms_handle; uint64_t *user_fence_cpu_address_base; - /* If true, report lost contexts and skip command submission. - * If false, terminate the process. - */ - bool allow_context_lost; - /* Lost context status due to ioctl and allocation failures. */ enum pipe_reset_status sw_status; - enum radeon_ctx_priority priority; + unsigned flags; }; struct amdgpu_cs_buffer { diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index 205bc01b15b..d6b7a8ff9ed 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -52,8 +52,7 @@ static void radeon_fence_reference(struct radeon_winsys *ws, struct pipe_fence_handle *src); static struct radeon_winsys_ctx *radeon_drm_ctx_create(struct radeon_winsys *ws, - enum radeon_ctx_priority priority, - bool allow_context_lost) + unsigned flags) { struct radeon_ctx *ctx = CALLOC_STRUCT(radeon_ctx); if (!ctx)