diff --git a/src/gallium/frontends/va/buffer.c b/src/gallium/frontends/va/buffer.c index 8626eaf2f42..f8b379fd271 100644 --- a/src/gallium/frontends/va/buffer.c +++ b/src/gallium/frontends/va/buffer.c @@ -559,13 +559,6 @@ vlVaSyncBuffer(VADriverContextP ctx, VABufferID buf_id, uint64_t timeout_ns) PIPE_VIDEO_CAP_ENC_SUPPORTS_ASYNC_OPERATION)) return VA_STATUS_ERROR_UNIMPLEMENTED; - /* vaSyncBuffer spec states that "If timeout is zero, the function returns immediately." */ - if (timeout_ns == 0) - return VA_STATUS_ERROR_TIMEDOUT; - - if (timeout_ns != VA_TIMEOUT_INFINITE) - return VA_STATUS_ERROR_UNIMPLEMENTED; - mtx_lock(&drv->mutex); buf = handle_table_get(drv->htab, buf_id); @@ -589,6 +582,11 @@ vlVaSyncBuffer(VADriverContextP ctx, VABufferID buf_id, uint64_t timeout_ns) vlVaSurface* surf = handle_table_get(drv->htab, buf->associated_encode_input_surf); if ((buf->feedback) && (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE)) { + if (surf && context->decoder->get_feedback_fence && + !context->decoder->get_feedback_fence(context->decoder, surf->fence, timeout_ns)) { + mtx_unlock(&drv->mutex); + return VA_STATUS_ERROR_TIMEDOUT; + } context->decoder->get_feedback(context->decoder, buf->feedback, &(buf->coded_size), &(buf->extended_metadata)); buf->feedback = NULL; /* Also mark the associated render target (encode source texture) surface as done diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index e808dd6a276..b1898f452bd 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -1383,12 +1383,6 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) } } - if (context->decoder->get_feedback_fence && - !context->decoder->get_feedback_fence(context->decoder, feedback)) { - mtx_unlock(&drv->mutex); - return VA_STATUS_ERROR_OPERATION_FAILED; - } - /* Update frame_num disregarding PIPE_VIDEO_CAP_REQUIRES_FLUSH_ON_END_FRAME check above */ if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) { if ((u_reduce_video_profile(context->templat.profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC) diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index 9383a751af4..52899cecc9d 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -226,6 +226,11 @@ _vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target, uint64_t timeo } } } + if (context->decoder->get_feedback_fence && + !context->decoder->get_feedback_fence(context->decoder, surf->fence, timeout_ns)) { + mtx_unlock(&drv->mutex); + return VA_STATUS_ERROR_TIMEDOUT; + } context->decoder->get_feedback(context->decoder, surf->feedback, &(surf->coded_buf->coded_size), &(surf->coded_buf->extended_metadata)); surf->feedback = NULL; surf->coded_buf->feedback = NULL; diff --git a/src/gallium/include/pipe/p_video_codec.h b/src/gallium/include/pipe/p_video_codec.h index 5facab197e5..82644daa4f0 100644 --- a/src/gallium/include/pipe/p_video_codec.h +++ b/src/gallium/include/pipe/p_video_codec.h @@ -152,16 +152,18 @@ struct pipe_video_codec uint64_t timeout); /** - * Gets a weak reference to a feedback fence. + * Get feedback fence. * - * Can be used to wait on the pipe_fence_handle directly instead - * of waiting on the get_feedback blocking call. + * Can be used to query the status of the previous process job denoted by + * 'fence' given 'timeout'. * - * Returns NULL if the feedback parameter does not have - * a valid in-flight submitted frame + * A pointer to a fence pointer can be passed to the codecs before the + * end_frame vfunc and the codec should then be responsible for allocating a + * fence on command stream submission. */ - struct pipe_fence_handle* (*get_feedback_fence)(struct pipe_video_codec *codec, - void *feedback); + int (*get_feedback_fence)(struct pipe_video_codec *codec, + struct pipe_fence_handle *fence, + uint64_t timeout); /** * Destroy fence. diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index dadf0035dd8..e39056d52ad 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -203,7 +203,7 @@ struct pipe_picture_desc enum pipe_format output_format; /* Flush flags for pipe_video_codec::end_frame */ unsigned flush_flags; - /* A fence used on PIPE_VIDEO_ENTRYPOINT_DECODE/PROCESSING to signal job completion */ + /* A fence for pipe_video_codec::end_frame to signal job completion */ struct pipe_fence_handle **fence; unsigned packed_headers; };