mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
gallium/video: Frontends separate in_fence and out_fence
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35900>
This commit is contained in:
parent
9fc42666f4
commit
5f3a7cee83
18 changed files with 38 additions and 38 deletions
|
|
@ -1242,7 +1242,8 @@ void trace_dump_pipe_picture_desc(const struct pipe_picture_desc *picture)
|
|||
trace_dump_member(format, picture, input_format);
|
||||
trace_dump_member(bool, picture, input_full_range);
|
||||
trace_dump_member(format, picture, output_format);
|
||||
trace_dump_member(ptr, picture, fence);
|
||||
trace_dump_member(ptr, picture, in_fence);
|
||||
trace_dump_member(ptr, picture, out_fence);
|
||||
trace_dump_struct_end();
|
||||
}
|
||||
|
||||
|
|
@ -1278,7 +1279,6 @@ void trace_dump_pipe_vpp_desc(const struct pipe_vpp_desc *process_properties)
|
|||
trace_dump_member_struct(u_rect, process_properties, dst_region);
|
||||
trace_dump_member_enum(pipe_video_vpp_orientation, process_properties, orientation);
|
||||
trace_dump_member_struct(pipe_vpp_blend, process_properties, blend);
|
||||
trace_dump_member(ptr, process_properties, src_surface_fence);
|
||||
trace_dump_struct_end();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -675,8 +675,8 @@ d3d12_video_decoder_end_frame(struct pipe_video_codec *codec,
|
|||
|
||||
if (pD3D12Dec->m_spDPBManager->is_pipe_buffer_underlying_output_decode_allocation()) {
|
||||
// No need to copy, the output surface fence is merely the decode queue fence
|
||||
if (picture->fence)
|
||||
d3d12_fence_reference((struct d3d12_fence **)picture->fence, pD3D12Dec->m_inflightResourcesPool[inflightIndexBeforeFlush].m_fence.get());
|
||||
if (picture->out_fence)
|
||||
d3d12_fence_reference((struct d3d12_fence **)picture->out_fence, pD3D12Dec->m_inflightResourcesPool[inflightIndexBeforeFlush].m_fence.get());
|
||||
} else {
|
||||
///
|
||||
/// If !pD3D12Dec->m_spDPBManager->is_pipe_buffer_underlying_output_decode_allocation()
|
||||
|
|
@ -722,7 +722,7 @@ d3d12_video_decoder_end_frame(struct pipe_video_codec *codec,
|
|||
}
|
||||
// Flush resource_copy_region batch
|
||||
// The output surface fence is the graphics queue that will signal after the copy ends
|
||||
pD3D12Dec->base.context->flush(pD3D12Dec->base.context, picture->fence, PIPE_FLUSH_ASYNC | PIPE_FLUSH_HINT_FINISH);
|
||||
pD3D12Dec->base.context->flush(pD3D12Dec->base.context, picture->out_fence, PIPE_FLUSH_ASYNC | PIPE_FLUSH_HINT_FINISH);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2726,7 +2726,7 @@ d3d12_video_encoder_begin_frame(struct pipe_video_codec * codec,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pD3D12Enc->m_inflightResourcesPool[d3d12_video_encoder_pool_current_index(pD3D12Enc)].m_InputSurfaceFence = picture->fence ? d3d12_fence(*picture->fence) : nullptr;
|
||||
pD3D12Enc->m_inflightResourcesPool[d3d12_video_encoder_pool_current_index(pD3D12Enc)].m_InputSurfaceFence = d3d12_fence(picture->in_fence);
|
||||
pD3D12Enc->m_inflightResourcesPool[d3d12_video_encoder_pool_current_index(pD3D12Enc)].encode_result = PIPE_VIDEO_FEEDBACK_METADATA_ENCODE_FLAG_OK;
|
||||
pD3D12Enc->m_spEncodedFrameMetadata[d3d12_video_encoder_metadata_current_index(pD3D12Enc)].encode_result = PIPE_VIDEO_FEEDBACK_METADATA_ENCODE_FLAG_OK;
|
||||
|
||||
|
|
@ -4693,8 +4693,8 @@ d3d12_video_encoder_end_frame(struct pipe_video_codec * codec,
|
|||
pD3D12Enc->m_bPendingWorkNotFlushed = true;
|
||||
|
||||
size_t current_metadata_slot = d3d12_video_encoder_metadata_current_index(pD3D12Enc);
|
||||
if (picture->fence)
|
||||
d3d12_fence_reference((struct d3d12_fence **)picture->fence, pD3D12Enc->m_spEncodedFrameMetadata[current_metadata_slot].m_fence.get());
|
||||
if (picture->out_fence)
|
||||
d3d12_fence_reference((struct d3d12_fence **)picture->out_fence, pD3D12Enc->m_spEncodedFrameMetadata[current_metadata_slot].m_fence.get());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,8 +181,8 @@ d3d12_video_processor_end_frame(struct pipe_video_codec * codec,
|
|||
|
||||
d3d12_unique_fence &fence = pD3D12Proc->m_PendingFences[d3d12_video_processor_pool_current_index(pD3D12Proc)];
|
||||
fence.reset(d3d12_create_fence_raw(pD3D12Proc->m_spFence.Get(), pD3D12Proc->m_fenceValue));
|
||||
if (picture->fence)
|
||||
d3d12_fence_reference((struct d3d12_fence **)picture->fence, fence.get());
|
||||
if (picture->out_fence)
|
||||
d3d12_fence_reference((struct d3d12_fence **)picture->out_fence, fence.get());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -193,8 +193,8 @@ d3d12_video_processor_process_frame(struct pipe_video_codec *codec,
|
|||
{
|
||||
struct d3d12_video_processor * pD3D12Proc = (struct d3d12_video_processor *) codec;
|
||||
|
||||
// begin_frame gets only called once so wouldn't update process_properties->src_surface_fence correctly
|
||||
pD3D12Proc->input_surface_fence = (struct d3d12_fence*) process_properties->src_surface_fence;
|
||||
// begin_frame gets only called once so wouldn't update process_properties->base.in_fence correctly
|
||||
pD3D12Proc->input_surface_fence = (struct d3d12_fence*) process_properties->base.in_fence;
|
||||
|
||||
// Get the underlying resources from the pipe_video_buffers
|
||||
struct d3d12_video_buffer *pInputVideoBuffer = (struct d3d12_video_buffer *) input_texture;
|
||||
|
|
|
|||
|
|
@ -994,7 +994,7 @@ static int ruvd_end_frame(struct pipe_video_codec *decoder,
|
|||
FB_BUFFER_OFFSET + dec->fb_size, RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
|
||||
set_reg(dec, dec->reg.cntl, 1);
|
||||
|
||||
flush(dec, PIPE_FLUSH_ASYNC, picture->fence);
|
||||
flush(dec, PIPE_FLUSH_ASYNC, picture->out_fence);
|
||||
next_buffer(dec);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1184,7 +1184,7 @@ static int ruvd_end_frame(struct pipe_video_codec *decoder, struct pipe_video_bu
|
|||
FB_BUFFER_OFFSET + dec->fb_size, RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
|
||||
set_reg(dec, dec->reg.cntl, 1);
|
||||
|
||||
flush(dec, picture->flush_flags, picture->fence);
|
||||
flush(dec, picture->flush_flags, picture->out_fence);
|
||||
next_buffer(dec);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1200,7 +1200,7 @@ static int radeon_uvd_enc_end_frame(struct pipe_video_codec *encoder,
|
|||
struct pipe_picture_desc *picture)
|
||||
{
|
||||
struct radeon_uvd_encoder *enc = (struct radeon_uvd_encoder *)encoder;
|
||||
return flush(enc, picture->flush_flags, picture->fence);
|
||||
return flush(enc, picture->flush_flags, picture->out_fence);
|
||||
}
|
||||
|
||||
static void radeon_uvd_enc_destroy(struct pipe_video_codec *encoder)
|
||||
|
|
|
|||
|
|
@ -1033,7 +1033,7 @@ static int rvce_end_frame(struct pipe_video_codec *encoder, struct pipe_video_bu
|
|||
{
|
||||
struct rvce_encoder *enc = (struct rvce_encoder *)encoder;
|
||||
|
||||
flush(enc, picture->flush_flags, picture->fence);
|
||||
flush(enc, picture->flush_flags, picture->out_fence);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2640,7 +2640,7 @@ static int radeon_dec_end_frame(struct pipe_video_codec *decoder, struct pipe_vi
|
|||
if (!dec->send_cmd(dec, target, picture))
|
||||
return 1;
|
||||
|
||||
flush(dec, picture->flush_flags, picture->fence);
|
||||
flush(dec, picture->flush_flags, picture->out_fence);
|
||||
|
||||
next_buffer(dec);
|
||||
return 0;
|
||||
|
|
@ -2712,7 +2712,7 @@ static int radeon_dec_jpeg_end_frame(struct pipe_video_codec *decoder, struct pi
|
|||
if (dec->jpg.crop_y + dec->jpg.crop_height > pic->picture_parameter.picture_height)
|
||||
dec->jpg.crop_height = 0;
|
||||
dec->send_cmd(dec, target, picture);
|
||||
dec->ws->cs_flush(&dec->jcs[dec->cb_idx], picture->flush_flags, picture->fence);
|
||||
dec->ws->cs_flush(&dec->jcs[dec->cb_idx], picture->flush_flags, picture->out_fence);
|
||||
next_buffer(dec);
|
||||
dec->cb_idx = (dec->cb_idx+1) % dec->njctx;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1793,7 +1793,7 @@ static int radeon_enc_end_frame(struct pipe_video_codec *encoder, struct pipe_vi
|
|||
if (enc->error)
|
||||
return -1;
|
||||
|
||||
return flush(enc, picture->flush_flags, picture->fence);
|
||||
return flush(enc, picture->flush_flags, picture->out_fence);
|
||||
}
|
||||
|
||||
static void radeon_enc_destroy(struct pipe_video_codec *encoder)
|
||||
|
|
|
|||
|
|
@ -1551,7 +1551,7 @@ si_vpe_processor_end_frame(struct pipe_video_codec *codec,
|
|||
struct vpe_video_processor *vpeproc = (struct vpe_video_processor *)codec;
|
||||
assert(codec);
|
||||
|
||||
vpeproc->ws->cs_flush(&vpeproc->cs, picture->flush_flags, picture->fence);
|
||||
vpeproc->ws->cs_flush(&vpeproc->cs, picture->flush_flags, picture->out_fence);
|
||||
next_buffer(vpeproc);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -204,8 +204,8 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E
|
|||
struct pipe_vpp_desc vpblit_params = {};
|
||||
struct pipe_fence_handle *dst_surface_fence = nullptr;
|
||||
|
||||
vpblit_params.src_surface_fence = m_pPipeFenceHandle; // input surface fence (driver input)
|
||||
vpblit_params.base.fence = &dst_surface_fence; // Output surface fence (driver output)
|
||||
vpblit_params.base.in_fence = m_pPipeFenceHandle; // input surface fence (driver input)
|
||||
vpblit_params.base.out_fence = &dst_surface_fence; // Output surface fence (driver output)
|
||||
|
||||
vpblit_params.base.input_format = pDX12EncodeContext->pPipeVideoBuffer->buffer_format;
|
||||
vpblit_params.base.output_format = pDX12EncodeContext->pDownscaledTwoPassPipeVideoBuffer->buffer_format;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ CDX12EncHMFT::PrepareForEncodeHelper( LPDX12EncodeContext pDX12EncodeContext, bo
|
|||
|
||||
pPicInfo->requested_metadata = m_EncoderCapabilities.m_HWSupportedMetadataFlags;
|
||||
|
||||
pPicInfo->base.fence = &m_pPipeFenceHandle;
|
||||
pPicInfo->base.in_fence = m_pPipeFenceHandle;
|
||||
pPicInfo->base.input_format = pDX12EncodeContext->pPipeVideoBuffer->buffer_format;
|
||||
|
||||
UpdateH264EncPictureDesc( pPicInfo,
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ CDX12EncHMFT::PrepareForEncodeHelper( LPDX12EncodeContext pDX12EncodeContext, bo
|
|||
|
||||
pPicInfo->requested_metadata = m_EncoderCapabilities.m_HWSupportedMetadataFlags;
|
||||
|
||||
pPicInfo->base.fence = &m_pPipeFenceHandle;
|
||||
pPicInfo->base.in_fence = m_pPipeFenceHandle;
|
||||
pPicInfo->base.input_format = pDX12EncodeContext->pPipeVideoBuffer->buffer_format;
|
||||
if( pDX12EncodeContext->bROI )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1176,8 +1176,8 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
|||
struct pipe_vpp_desc vpblit_params = {};
|
||||
struct pipe_fence_handle *dst_surface_fence = nullptr;
|
||||
|
||||
vpblit_params.src_surface_fence = NULL; // No need, we _just_ waited for completion above before get_feedback
|
||||
vpblit_params.base.fence = &dst_surface_fence; // Output surface fence (driver output)
|
||||
vpblit_params.base.in_fence = NULL; // No need, we _just_ waited for completion above before get_feedback
|
||||
vpblit_params.base.out_fence = &dst_surface_fence; // Output surface fence (driver output)
|
||||
|
||||
#if MFT_CODEC_H264ENC
|
||||
auto &cur_pic_dpb_entry =
|
||||
|
|
@ -1227,7 +1227,7 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
|||
|
||||
pThis->m_pPipeVideoBlitter->flush( pThis->m_pPipeVideoBlitter );
|
||||
|
||||
assert( *vpblit_params.base.fence ); // Driver must have returned the completion fence
|
||||
assert( dst_surface_fence ); // Driver must have returned the completion fence
|
||||
// Wait for downscaling completion before encode can proceed
|
||||
|
||||
// TODO: This can probably be done better later as plumbing
|
||||
|
|
@ -1238,7 +1238,7 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
|||
ASSERTED bool finished =
|
||||
pThis->m_pPipeVideoCodec->context->screen->fence_finish( pThis->m_pPipeVideoCodec->context->screen,
|
||||
NULL, /*passing non NULL resets GRFX context*/
|
||||
*vpblit_params.base.fence,
|
||||
dst_surface_fence,
|
||||
OS_TIMEOUT_INFINITE );
|
||||
assert( finished );
|
||||
}
|
||||
|
|
@ -2019,7 +2019,7 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD
|
|||
|
||||
HMFT_ETW_EVENT_STOP( "PipeSubmitFrame", this );
|
||||
|
||||
pDX12EncodeContext->encoderPicInfo.base.fence =
|
||||
pDX12EncodeContext->encoderPicInfo.base.out_fence =
|
||||
&pDX12EncodeContext->pAsyncFence; // end_frame will fill in the fence as output param
|
||||
|
||||
HMFT_ETW_EVENT_START( "PipeEndFrame", this );
|
||||
|
|
|
|||
|
|
@ -1196,7 +1196,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
|
|||
|
||||
if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
|
||||
coded_buf = context->coded_buf;
|
||||
context->desc.base.fence = &coded_buf->fence;
|
||||
context->desc.base.out_fence = &coded_buf->fence;
|
||||
if (u_reduce_video_profile(context->templat.profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC)
|
||||
context->desc.h264enc.frame_num_cnt++;
|
||||
|
||||
|
|
@ -1230,6 +1230,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
|
|||
else if (u_reduce_video_profile(context->templat.profile) == PIPE_VIDEO_FORMAT_AV1)
|
||||
context->desc.av1enc.requested_metadata = driver_metadata_support;
|
||||
|
||||
context->desc.base.in_fence = surf->fence;
|
||||
context->decoder->begin_frame(context->decoder, context->target, &context->desc.base);
|
||||
context->decoder->encode_bitstream(context->decoder, context->target,
|
||||
coded_buf->derived_surface.resource, &feedback);
|
||||
|
|
@ -1237,9 +1238,9 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
|
|||
coded_buf->coded_surf = surf;
|
||||
surf->coded_buf = coded_buf;
|
||||
} else if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
|
||||
context->desc.base.fence = &surf->fence;
|
||||
context->desc.base.out_fence = &surf->fence;
|
||||
} else if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_PROCESSING) {
|
||||
context->desc.base.fence = &surf->fence;
|
||||
context->desc.base.out_fence = &surf->fence;
|
||||
}
|
||||
|
||||
if (screen->is_video_target_buffer_supported &&
|
||||
|
|
@ -1253,7 +1254,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
|
|||
}
|
||||
|
||||
/* when there are external handles, we can't set PIPE_FLUSH_ASYNC */
|
||||
if (context->desc.base.fence)
|
||||
if (context->desc.base.out_fence)
|
||||
context->desc.base.flush_flags = drv->has_external_handles ? 0 : PIPE_FLUSH_ASYNC;
|
||||
|
||||
if (context->decoder->end_frame(context->decoder, context->target, &context->desc.base) != 0) {
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex
|
|||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
context->desc.vidproc.src_surface_fence = src_surface->fence;
|
||||
context->desc.base.in_fence = src_surface->fence;
|
||||
/* Perform VPBlit, if fail, fallback to other implementations below */
|
||||
if (VA_STATUS_SUCCESS == vlVaVidEngineBlit(drv, context, src_region, dst_region,
|
||||
src, context->target, deinterlace, param))
|
||||
|
|
|
|||
|
|
@ -237,8 +237,10 @@ struct pipe_picture_desc
|
|||
enum pipe_format output_format;
|
||||
/* Flush flags for pipe_video_codec::end_frame */
|
||||
unsigned flush_flags;
|
||||
/* A fence for pipe_video_codec::begin_frame to wait on */
|
||||
struct pipe_fence_handle *in_fence;
|
||||
/* A fence for pipe_video_codec::end_frame to signal job completion */
|
||||
struct pipe_fence_handle **fence;
|
||||
struct pipe_fence_handle **out_fence;
|
||||
};
|
||||
|
||||
struct pipe_quant_matrix
|
||||
|
|
@ -2152,9 +2154,6 @@ struct pipe_vpp_desc
|
|||
enum pipe_video_vpp_orientation orientation;
|
||||
struct pipe_vpp_blend blend;
|
||||
|
||||
/* Fence to wait on for the src surface */
|
||||
struct pipe_fence_handle *src_surface_fence;
|
||||
|
||||
uint32_t background_color;
|
||||
enum pipe_video_vpp_color_standard_type in_colors_standard;
|
||||
enum pipe_video_vpp_color_range in_color_range;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue