d3d12: Only pass texture dimensions to d3d12_video_encoder_update_current_encoder_config_state

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26456>
This commit is contained in:
Sil Vilerino 2023-11-17 22:58:08 -05:00 committed by Marge Bot
parent 05fe740374
commit 829e821aab
8 changed files with 41 additions and 37 deletions

View file

@ -1458,7 +1458,7 @@ d3d12_video_encoder_get_current_max_dpb_capacity(struct d3d12_video_encoder *pD3
bool
d3d12_video_encoder_update_current_encoder_config_state(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc * picture)
{
enum pipe_video_format codec = u_reduce_video_profile(pD3D12Enc->base.profile);
@ -1466,20 +1466,20 @@ d3d12_video_encoder_update_current_encoder_config_state(struct d3d12_video_encod
#if VIDEO_CODEC_H264ENC
case PIPE_VIDEO_FORMAT_MPEG4_AVC:
{
return d3d12_video_encoder_update_current_encoder_config_state_h264(pD3D12Enc, srcTexture, picture);
return d3d12_video_encoder_update_current_encoder_config_state_h264(pD3D12Enc, srcTextureDesc, picture);
} break;
#endif
#if VIDEO_CODEC_H265ENC
case PIPE_VIDEO_FORMAT_HEVC:
{
return d3d12_video_encoder_update_current_encoder_config_state_hevc(pD3D12Enc, srcTexture, picture);
return d3d12_video_encoder_update_current_encoder_config_state_hevc(pD3D12Enc, srcTextureDesc, picture);
} break;
#endif
#if VIDEO_CODEC_AV1ENC
#if ((D3D12_SDK_VERSION >= 611) && (D3D12_PREVIEW_SDK_VERSION >= 712))
case PIPE_VIDEO_FORMAT_AV1:
{
return d3d12_video_encoder_update_current_encoder_config_state_av1(pD3D12Enc, srcTexture, picture);
return d3d12_video_encoder_update_current_encoder_config_state_av1(pD3D12Enc, srcTextureDesc, picture);
} break;
#endif
#endif
@ -1699,7 +1699,11 @@ d3d12_video_encoder_reconfigure_session(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_picture_desc * picture)
{
assert(pD3D12Enc->m_spD3D12VideoDevice);
if(!d3d12_video_encoder_update_current_encoder_config_state(pD3D12Enc, srcTexture, picture)) {
D3D12_VIDEO_SAMPLE srcTextureDesc = {};
srcTextureDesc.Width = srcTexture->width;
srcTextureDesc.Height = srcTexture->height;
srcTextureDesc.Format.Format = d3d12_get_format(srcTexture->buffer_format);
if(!d3d12_video_encoder_update_current_encoder_config_state(pD3D12Enc, srcTextureDesc, picture)) {
debug_printf("d3d12_video_encoder_update_current_encoder_config_state failed!\n");
return false;
}

View file

@ -436,7 +436,7 @@ d3d12_video_encoder_reconfigure_session(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_picture_desc * picture);
bool
d3d12_video_encoder_update_current_encoder_config_state(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc * picture);
bool
d3d12_video_encoder_reconfigure_encoder_objects(struct d3d12_video_encoder *pD3D12Enc,

View file

@ -989,7 +989,7 @@ d3d12_video_encoder_convert_av1_codec_configuration(struct d3d12_video_encoder *
static bool
d3d12_video_encoder_update_intra_refresh_av1(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_av1_enc_picture_desc * picture)
{
if (picture->intra_refresh.mode != INTRA_REFRESH_MODE_NONE)
@ -1003,8 +1003,8 @@ d3d12_video_encoder_update_intra_refresh_av1(struct d3d12_video_encoder *pD3D12E
uint32_t sbSize = ((pD3D12Enc->m_currentEncodeConfig.m_encoderCodecSpecificConfigDesc.m_AV1Config.FeatureFlags &
D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK) != 0) ? 128u : 64u;
uint32_t total_frame_blocks = static_cast<uint32_t>(std::ceil(srcTexture->height / sbSize)) *
static_cast<uint32_t>(std::ceil(srcTexture->width / sbSize));
uint32_t total_frame_blocks = static_cast<uint32_t>(std::ceil(srcTextureDesc.Height / sbSize)) *
static_cast<uint32_t>(std::ceil(srcTextureDesc.Width / sbSize));
D3D12_VIDEO_ENCODER_INTRA_REFRESH targetIntraRefresh = {
D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_ROW_BASED,
total_frame_blocks / picture->intra_refresh.region_size,
@ -1031,7 +1031,7 @@ d3d12_video_encoder_update_intra_refresh_av1(struct d3d12_video_encoder *pD3D12E
bool
d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer *srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc *picture)
{
struct pipe_av1_enc_picture_desc *av1Pic = (struct pipe_av1_enc_picture_desc *) picture;
@ -1048,7 +1048,7 @@ d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_e
pD3D12Enc->m_currentEncodeConfig.m_encoderCodecDesc = D3D12_VIDEO_ENCODER_CODEC_AV1;
// Set input format
DXGI_FORMAT targetFmt = d3d12_get_format(srcTexture->buffer_format);
DXGI_FORMAT targetFmt = srcTextureDesc.Format.Format;
if (pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format != targetFmt) {
pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_input_format;
}
@ -1065,12 +1065,12 @@ d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_e
}
// Set resolution (ie. frame_size)
if ((pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width != srcTexture->width) ||
(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height != srcTexture->height)) {
if ((pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width != srcTextureDesc.Width) ||
(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height != srcTextureDesc.Height)) {
pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_resolution;
}
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width = srcTexture->width;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height = srcTexture->height;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width = srcTextureDesc.Width;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height = srcTextureDesc.Height;
// render_size
pD3D12Enc->m_currentEncodeConfig.m_FrameCroppingCodecConfig.right = av1Pic->frame_width;
@ -1150,7 +1150,7 @@ d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_e
}
// Set intra-refresh config
if(!d3d12_video_encoder_update_intra_refresh_av1(pD3D12Enc, srcTexture, av1Pic)) {
if(!d3d12_video_encoder_update_intra_refresh_av1(pD3D12Enc, srcTextureDesc, av1Pic)) {
debug_printf("d3d12_video_encoder_update_intra_refresh_av1 failed!\n");
return false;
}

View file

@ -33,7 +33,7 @@ d3d12_video_encoder_calculate_metadata_resolved_buffer_size_av1(uint32_t maxSlic
bool
d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer *srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc *picture);
void

View file

@ -806,7 +806,7 @@ d3d12_video_encoder_convert_h264_codec_configuration(struct d3d12_video_encoder
static bool
d3d12_video_encoder_update_intra_refresh_h264(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_h264_enc_picture_desc * picture)
{
if (picture->intra_refresh.mode != INTRA_REFRESH_MODE_NONE)
@ -818,8 +818,8 @@ d3d12_video_encoder_update_intra_refresh_h264(struct d3d12_video_encoder *pD3D12
return false;
}
uint32_t total_frame_blocks = static_cast<uint32_t>(std::ceil(srcTexture->height / D3D12_VIDEO_H264_MB_IN_PIXELS)) *
static_cast<uint32_t>(std::ceil(srcTexture->width / D3D12_VIDEO_H264_MB_IN_PIXELS));
uint32_t total_frame_blocks = static_cast<uint32_t>(std::ceil(srcTextureDesc.Height / D3D12_VIDEO_H264_MB_IN_PIXELS)) *
static_cast<uint32_t>(std::ceil(srcTextureDesc.Width / D3D12_VIDEO_H264_MB_IN_PIXELS));
D3D12_VIDEO_ENCODER_INTRA_REFRESH targetIntraRefresh = {
D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_ROW_BASED,
total_frame_blocks / picture->intra_refresh.region_size,
@ -846,7 +846,7 @@ d3d12_video_encoder_update_intra_refresh_h264(struct d3d12_video_encoder *pD3D12
bool
d3d12_video_encoder_update_current_encoder_config_state_h264(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer *srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc *picture)
{
struct pipe_h264_enc_picture_desc *h264Pic = (struct pipe_h264_enc_picture_desc *) picture;
@ -891,18 +891,18 @@ d3d12_video_encoder_update_current_encoder_config_state_h264(struct d3d12_video_
}
// Set intra-refresh config
if(!d3d12_video_encoder_update_intra_refresh_h264(pD3D12Enc, srcTexture, h264Pic)) {
if(!d3d12_video_encoder_update_intra_refresh_h264(pD3D12Enc, srcTextureDesc, h264Pic)) {
debug_printf("d3d12_video_encoder_update_intra_refresh_h264 failed!\n");
return false;
}
// Set resolution
if ((pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width != srcTexture->width) ||
(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height != srcTexture->height)) {
if ((pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width != srcTextureDesc.Width) ||
(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height != srcTextureDesc.Height)) {
pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_resolution;
}
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width = srcTexture->width;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height = srcTexture->height;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width = srcTextureDesc.Width;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height = srcTextureDesc.Height;
// Set resolution codec dimensions (ie. cropping)
if (h264Pic->seq.enc_frame_cropping_flag) {

View file

@ -28,7 +28,7 @@
bool
d3d12_video_encoder_update_current_encoder_config_state_h264(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc * picture);
void
d3d12_video_encoder_update_current_rate_control_h264(struct d3d12_video_encoder *pD3D12Enc,

View file

@ -738,7 +738,7 @@ d3d12_video_encoder_convert_hevc_codec_configuration(struct d3d12_video_encoder
static bool
d3d12_video_encoder_update_intra_refresh_hevc(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_h265_enc_picture_desc * picture)
{
if (picture->intra_refresh.mode != INTRA_REFRESH_MODE_NONE)
@ -752,8 +752,8 @@ d3d12_video_encoder_update_intra_refresh_hevc(struct d3d12_video_encoder *pD3D12
uint8_t ctbSize = d3d12_video_encoder_convert_12cusize_to_pixel_size_hevc(
pD3D12Enc->m_currentEncodeCapabilities.m_encoderCodecSpecificConfigCaps.m_HEVCCodecCaps.MaxLumaCodingUnitSize);
uint32_t total_frame_blocks = static_cast<uint32_t>(std::ceil(srcTexture->height / ctbSize)) *
static_cast<uint32_t>(std::ceil(srcTexture->width / ctbSize));
uint32_t total_frame_blocks = static_cast<uint32_t>(std::ceil(srcTextureDesc.Height / ctbSize)) *
static_cast<uint32_t>(std::ceil(srcTextureDesc.Width / ctbSize));
D3D12_VIDEO_ENCODER_INTRA_REFRESH targetIntraRefresh = {
D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_ROW_BASED,
total_frame_blocks / picture->intra_refresh.region_size,
@ -780,7 +780,7 @@ d3d12_video_encoder_update_intra_refresh_hevc(struct d3d12_video_encoder *pD3D12
bool
d3d12_video_encoder_update_current_encoder_config_state_hevc(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer *srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc *picture)
{
struct pipe_h265_enc_picture_desc *hevcPic = (struct pipe_h265_enc_picture_desc *) picture;
@ -825,12 +825,12 @@ d3d12_video_encoder_update_current_encoder_config_state_hevc(struct d3d12_video_
}
// Set resolution
if ((pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width != srcTexture->width) ||
(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height != srcTexture->height)) {
if ((pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width != srcTextureDesc.Width) ||
(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height != srcTextureDesc.Height)) {
pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_resolution;
}
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width = srcTexture->width;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height = srcTexture->height;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width = srcTextureDesc.Width;
pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Height = srcTextureDesc.Height;
// Set resolution codec dimensions (ie. cropping)
memset(&pD3D12Enc->m_currentEncodeConfig.m_FrameCroppingCodecConfig, 0,
@ -920,7 +920,7 @@ d3d12_video_encoder_update_current_encoder_config_state_hevc(struct d3d12_video_
}
// Set intra-refresh config
if(!d3d12_video_encoder_update_intra_refresh_hevc(pD3D12Enc, srcTexture, hevcPic)) {
if(!d3d12_video_encoder_update_intra_refresh_hevc(pD3D12Enc, srcTextureDesc, hevcPic)) {
debug_printf("d3d12_video_encoder_update_intra_refresh_hevc failed!\n");
return false;
}

View file

@ -28,7 +28,7 @@
bool
d3d12_video_encoder_update_current_encoder_config_state_hevc(struct d3d12_video_encoder *pD3D12Enc,
struct pipe_video_buffer * srcTexture,
D3D12_VIDEO_SAMPLE srcTextureDesc,
struct pipe_picture_desc * picture);
void
d3d12_video_encoder_update_current_rate_control_hevc(struct d3d12_video_encoder *pD3D12Enc,