radeonsi: vcn: implement the get_decoder_fence vfunc

Implement the get_decoder_fence vfunc by waiting on the fence
previously passed in the end_frame vfunc.

Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20133>
This commit is contained in:
Daniel Almeida 2022-12-04 09:28:23 -03:00 committed by Marge Bot
parent 01a5de1b95
commit 5e1bd07ac5

View File

@ -2360,11 +2360,11 @@ static void rvcn_dec_sq_tail(struct radeon_decoder *dec)
rvcn_sq_tail(&dec->cs, &dec->sq);
}
/* flush IB to the hardware */
static int flush(struct radeon_decoder *dec, unsigned flags)
{
static int flush(struct radeon_decoder *dec, unsigned flags,
struct pipe_fence_handle **fence) {
rvcn_dec_sq_tail(dec);
return dec->ws->cs_flush(&dec->cs, flags, NULL);
return dec->ws->cs_flush(&dec->cs, flags, fence);
}
/* add a new set register command to the IB */
@ -2736,7 +2736,7 @@ static void radeon_dec_destroy(struct pipe_video_codec *decoder)
map_msg_fb_it_probs_buf(dec);
rvcn_dec_message_destroy(dec);
send_msg_buf(dec);
flush(dec, 0);
flush(dec, 0, NULL);
}
dec->ws->cs_destroy(&dec->cs);
@ -2905,7 +2905,7 @@ static void radeon_dec_end_frame(struct pipe_video_codec *decoder, struct pipe_v
return;
dec->send_cmd(dec, target, picture);
flush(dec, PIPE_FLUSH_ASYNC);
flush(dec, PIPE_FLUSH_ASYNC, picture->fence);
next_buffer(dec);
}
@ -2923,7 +2923,7 @@ static void radeon_dec_jpeg_end_frame(struct pipe_video_codec *decoder, struct p
return;
dec->send_cmd(dec, target, picture);
dec->ws->cs_flush(&dec->jcs[dec->cb_idx], PIPE_FLUSH_ASYNC, NULL);
dec->ws->cs_flush(&dec->jcs[dec->cb_idx], PIPE_FLUSH_ASYNC, picture->fence);
next_buffer(dec);
dec->cb_idx = (dec->cb_idx+1) % dec->njctx;
}
@ -2935,6 +2935,14 @@ static void radeon_dec_flush(struct pipe_video_codec *decoder)
{
}
static int radeon_dec_get_decoder_fence(struct pipe_video_codec *decoder,
struct pipe_fence_handle *fence,
uint64_t timeout) {
struct radeon_decoder *dec = (struct radeon_decoder *)decoder;
return dec->ws->fence_wait(dec->ws, fence, timeout);
}
/**
* create and HW decoder
*/
@ -3001,6 +3009,7 @@ struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
dec->base.decode_bitstream = radeon_dec_decode_bitstream;
dec->base.end_frame = radeon_dec_end_frame;
dec->base.flush = radeon_dec_flush;
dec->base.get_decoder_fence = radeon_dec_get_decoder_fence;
dec->stream_type = stream_type;
dec->stream_handle = si_vid_alloc_stream_handle();
@ -3175,7 +3184,7 @@ struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
map_msg_fb_it_probs_buf(dec);
rvcn_dec_message_create(dec);
send_msg_buf(dec);
r = flush(dec, 0);
r = flush(dec, 0, NULL);
if (r)
goto error;
}