radv/amdgpu: fix chaining CS with external IBs on compute queue

In a scenario where two non-concurrent cmdbufs are submitted to the
compute queue and with the second one using DGCC, the driver would have
chained the CS of the first cmdbuf to the new IB created right after
the DGC IB is executed.

Found while working on DGC task shader with vkd3d-proton.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29913>
(cherry picked from commit fec9b56f17)
This commit is contained in:
Samuel Pitoiset 2024-06-26 13:57:06 +02:00 committed by Eric Engestrom
parent bc75532540
commit bd826b5c5d
2 changed files with 18 additions and 12 deletions

View file

@ -54,7 +54,7 @@
"description": "radv/amdgpu: fix chaining CS with external IBs on compute queue",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -527,6 +527,17 @@ radv_amdgpu_cs_reset(struct radeon_cmdbuf *_cs)
cs->annotations = NULL;
}
static bool
radv_amdgpu_cs_has_external_ib(const struct radv_amdgpu_cs *cs)
{
for (unsigned i = 0; i < cs->num_ib_buffers; i++) {
if (cs->ib_buffers[i].is_external)
return true;
}
return false;
}
static void
radv_amdgpu_cs_unchain(struct radeon_cmdbuf *cs)
{
@ -563,6 +574,12 @@ radv_amdgpu_cs_chain(struct radeon_cmdbuf *cs, struct radeon_cmdbuf *next_cs, bo
if (!acs->use_ib)
return false;
/* Do not chain if the next CS has external IBs because it will chain to newly created IB instead
* of the first one.
*/
if (radv_amdgpu_cs_has_external_ib(next_acs))
return false;
assert(cs->cdw <= cs->max_dw + 4);
acs->chained_to = next_acs;
@ -952,17 +969,6 @@ radv_assign_last_submit(struct radv_amdgpu_ctx *ctx, struct radv_amdgpu_cs_reque
radv_amdgpu_request_to_fence(ctx, &ctx->last_submission[request->ip_type][request->ring], request);
}
static bool
radv_amdgpu_cs_has_external_ib(const struct radv_amdgpu_cs *cs)
{
for (unsigned i = 0; i < cs->num_ib_buffers; i++) {
if (cs->ib_buffers[i].is_external)
return true;
}
return false;
}
static unsigned
radv_amdgpu_get_num_ibs_per_cs(const struct radv_amdgpu_cs *cs)
{