From e8e7f06f104543f4c514b2a77fbe9f8044fc234c Mon Sep 17 00:00:00 2001 From: Sil Vilerino Date: Sun, 4 Dec 2022 09:39:09 -0300 Subject: [PATCH] d3d12: implement the get_decoder_fence vfunc Implement the get_decoder_fence vfunc. Note that the waiting for completion in this driver happens in the end_frame vfunc itself. Signed-off-by: Sil Vilerino Reviewed-by: Leo Liu Reviewed-by: Boyuan Zhang Part-of: --- src/gallium/drivers/d3d12/d3d12_video_dec.cpp | 24 +++++++++++++++++++ src/gallium/drivers/d3d12/d3d12_video_dec.h | 7 ++++++ 2 files changed, 31 insertions(+) diff --git a/src/gallium/drivers/d3d12/d3d12_video_dec.cpp b/src/gallium/drivers/d3d12/d3d12_video_dec.cpp index 4789306ce7a..460c3347227 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_dec.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_dec.cpp @@ -65,6 +65,7 @@ d3d12_video_create_decoder(struct pipe_context *context, const struct pipe_video pD3D12Dec->base.decode_bitstream = d3d12_video_decoder_decode_bitstream; pD3D12Dec->base.end_frame = d3d12_video_decoder_end_frame; pD3D12Dec->base.flush = d3d12_video_decoder_flush; + pD3D12Dec->base.get_decoder_fence = d3d12_video_decoder_get_decoder_fence; pD3D12Dec->m_decodeFormat = d3d12_convert_pipe_video_profile_to_dxgi_format(codec->profile); pD3D12Dec->m_d3d12DecProfileType = d3d12_video_decoder_convert_pipe_video_profile_to_profile_type(codec->profile); @@ -665,6 +666,29 @@ d3d12_video_decoder_end_frame(struct pipe_video_codec *codec, pD3D12Screen->base.fence_reference(&pD3D12Screen->base, &completion_fence, NULL); pipe_resource_reference(&pPipeSrc, NULL); } + + // We do not use the async fence for now but set it to + // NULL to avoid uninitialized memory in VA frontend + *picture->fence = NULL; +} + +/** + * Get decoder fence. + */ +int d3d12_video_decoder_get_decoder_fence(struct pipe_video_codec *codec, + struct pipe_fence_handle *fence, + uint64_t timeout) +{ + /* No need to wait for anything, we're already flushing + and waiting in d3d12_video_decoder_end_frame */ + + // We set NULL in d3d12_video_decoder_end_frame + assert(fence == NULL); + + // Return semantics based on p_video_codec interface + // ret == 0 -> Decode in progress + // ret != 0 -> Decode completed + return 1; } /** diff --git a/src/gallium/drivers/d3d12/d3d12_video_dec.h b/src/gallium/drivers/d3d12/d3d12_video_dec.h index 2184fe0b130..3197cc751d1 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_dec.h +++ b/src/gallium/drivers/d3d12/d3d12_video_dec.h @@ -77,6 +77,13 @@ d3d12_video_decoder_end_frame(struct pipe_video_codec * codec, void d3d12_video_decoder_flush(struct pipe_video_codec *codec); +/** + * Get decoder fence. + */ +int d3d12_video_decoder_get_decoder_fence(struct pipe_video_codec *codec, + struct pipe_fence_handle *fence, + uint64_t timeout); + /// /// Pipe video interface ends ///