d3d12: Add support for retreiving PIPE_VIDEO_CAP_ENC_MAX_DPB_CAPACITY for H264/H265 encode

Signed-off-by: Pohsiang Hsu <pohhsu@microsoft.com>
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34844>
This commit is contained in:
Pohsiang (John) Hsu 2024-11-03 13:27:35 -08:00 committed by Marge Bot
parent 7557ce41be
commit ebd82f39f8

View file

@ -277,7 +277,8 @@ d3d12_video_encode_supported_references_per_frame_structures(const D3D12_VIDEO_E
D3D12_VIDEO_ENCODER_PROFILE_DESC profile,
ID3D12VideoDevice3 *pD3D12VideoDevice,
struct d3d12_encode_codec_support& codecSupport,
uint32_t& maxLongTermReferences)
uint32_t& maxLongTermReferences,
uint32_t& maxDPBCapacity)
{
uint32_t supportedMaxRefFrames = 0u;
D3D12_FEATURE_DATA_VIDEO_ENCODER_CODEC_PICTURE_CONTROL_SUPPORT capPictureControlData = {};
@ -285,6 +286,7 @@ d3d12_video_encode_supported_references_per_frame_structures(const D3D12_VIDEO_E
capPictureControlData.Codec = codec;
maxLongTermReferences = 0u;
maxDPBCapacity = 0u;
if(codec == D3D12_VIDEO_ENCODER_CODEC_H264) {
D3D12_VIDEO_ENCODER_CODEC_PICTURE_CONTROL_SUPPORT_H264 h264PictureControl = {};
@ -313,6 +315,7 @@ d3d12_video_encode_supported_references_per_frame_structures(const D3D12_VIDEO_E
supportedMaxRefFrames = (maxRefForL0 & 0xffff) | ((maxRefForL1 & 0xffff) << 16);
maxLongTermReferences = capPictureControlData.PictureSupport.pH264Support->MaxLongTermReferences;
maxDPBCapacity = capPictureControlData.PictureSupport.pH264Support->MaxDPBCapacity;
}
} else if(codec == D3D12_VIDEO_ENCODER_CODEC_HEVC) {
D3D12_VIDEO_ENCODER_CODEC_PICTURE_CONTROL_SUPPORT_HEVC hevcPictureControl = {};
@ -341,6 +344,7 @@ d3d12_video_encode_supported_references_per_frame_structures(const D3D12_VIDEO_E
supportedMaxRefFrames = (maxRefForL0 & 0xffff) | ((maxRefForL1 & 0xffff) << 16);
maxLongTermReferences = capPictureControlData.PictureSupport.pHEVCSupport->MaxLongTermReferences;
maxDPBCapacity = capPictureControlData.PictureSupport.pHEVCSupport->MaxDPBCapacity;
}
}
else if(codec == D3D12_VIDEO_ENCODER_CODEC_AV1){
@ -857,6 +861,7 @@ d3d12_has_video_encode_support(struct pipe_screen *pscreen,
uint32_t &supportedSliceStructures,
uint32_t &maxReferencesPerFrame,
uint32_t &maxLongTermReferences,
uint32_t &maxDPBCapacity,
struct d3d12_encode_codec_support& codecSupport,
uint32_t &isRCMaxFrameSizeSupported,
uint32_t &maxQualityLevels,
@ -954,7 +959,8 @@ d3d12_has_video_encode_support(struct pipe_screen *pscreen,
profile,
spD3D12VideoDevice.Get(),
codecSupport,
maxLongTermReferences);
maxLongTermReferences,
maxDPBCapacity);
memset(&roi_support, 0, sizeof(roi_support));
roi_support.bits.roi_rc_qp_delta_support = ((capEncoderSupportData1.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RATE_CONTROL_DELTA_QP_AVAILABLE) != 0) ? 1 : 0;
@ -1012,7 +1018,8 @@ d3d12_has_video_encode_support(struct pipe_screen *pscreen,
d3d12_profile,
spD3D12VideoDevice.Get(),
codecSupport,
maxLongTermReferences);
maxLongTermReferences,
maxDPBCapacity);
supportsProfile = d3d12_video_encode_get_hevc_codec_support(codecDesc,
profDesc,
@ -1272,7 +1279,8 @@ d3d12_has_video_encode_support(struct pipe_screen *pscreen,
d3d12_profile,
spD3D12VideoDevice.Get(),
codecSupport,
maxLongTermReferences);
maxLongTermReferences,
maxDPBCapacity);
supportsProfile = d3d12_video_encode_get_av1_codec_support(codecDesc,
profDesc,
@ -1799,6 +1807,7 @@ d3d12_screen_get_video_param_encode(struct pipe_screen *pscreen,
uint32_t supportedSliceStructures = 0u;
uint32_t maxReferencesPerFrame = 0u;
uint32_t maxLongTermReferenceFrame = 0u;
uint32_t maxDPBCapacity = 0u;
uint32_t isRCMaxFrameSizeSupported = 0u;
uint32_t maxQualityLevels = 0u;
uint32_t max_tile_rows = 0u;
@ -1867,6 +1876,7 @@ d3d12_screen_get_video_param_encode(struct pipe_screen *pscreen,
case PIPE_VIDEO_CAP_ENC_HEVC_RANGE_EXTENSION_SUPPORT:
case PIPE_VIDEO_CAP_ENC_HEVC_RANGE_EXTENSION_FLAGS_SUPPORT:
case PIPE_VIDEO_CAP_ENC_MAX_LONG_TERM_REFERENCES_PER_FRAME:
case PIPE_VIDEO_CAP_ENC_MAX_DPB_CAPACITY:
{
if (d3d12_has_video_encode_support(pscreen,
profile,
@ -1878,6 +1888,7 @@ d3d12_screen_get_video_param_encode(struct pipe_screen *pscreen,
supportedSliceStructures,
maxReferencesPerFrame,
maxLongTermReferenceFrame,
maxDPBCapacity,
codec_specific_support,
isRCMaxFrameSizeSupported,
maxQualityLevels,
@ -1917,6 +1928,8 @@ d3d12_screen_get_video_param_encode(struct pipe_screen *pscreen,
return maxReferencesPerFrame;
} else if (param == PIPE_VIDEO_CAP_ENC_MAX_LONG_TERM_REFERENCES_PER_FRAME) {
return maxLongTermReferenceFrame;
} else if (param == PIPE_VIDEO_CAP_ENC_MAX_DPB_CAPACITY) {
return maxDPBCapacity;
} else if (param == PIPE_VIDEO_CAP_ENC_INTRA_REFRESH_MAX_DURATION) {
return maxIRDuration;
} else if (param == PIPE_VIDEO_CAP_ENC_INTRA_REFRESH) {
@ -2027,6 +2040,7 @@ d3d12_video_encode_requires_texture_array_dpb(struct d3d12_screen* pScreen, enum
uint32_t supportedSliceStructures = 0u;
uint32_t maxReferencesPerFrame = 0u;
uint32_t maxLongTermReferenceFrame = 0u;
uint32_t maxDPBCapacity = 0u;
uint32_t isRCMaxFrameSizeSupported = 0u;
uint32_t maxQualityLevels = 0u;
uint32_t max_tile_rows = 0u;
@ -2045,6 +2059,7 @@ d3d12_video_encode_requires_texture_array_dpb(struct d3d12_screen* pScreen, enum
supportedSliceStructures,
maxReferencesPerFrame,
maxLongTermReferenceFrame,
maxDPBCapacity,
codec_specific_support,
isRCMaxFrameSizeSupported,
maxQualityLevels,