From e3ab866fea0fe648a22ff7bd1d713c7b59b18924 Mon Sep 17 00:00:00 2001 From: Silvio Vilerino Date: Sat, 18 Oct 2025 10:27:31 -0400 Subject: [PATCH] d3d12: Only call CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO when video format changes Reviewed-by: Pohsiang (John) Hsu Part-of: --- .../drivers/d3d12/d3d12_video_enc_av1.cpp | 20 +++++++++---------- .../drivers/d3d12/d3d12_video_enc_h264.cpp | 18 ++++++++--------- .../drivers/d3d12/d3d12_video_enc_hevc.cpp | 18 ++++++++--------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc_av1.cpp b/src/gallium/drivers/d3d12/d3d12_video_enc_av1.cpp index ed9c7cfb925..b93bc3ce673 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_enc_av1.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_enc_av1.cpp @@ -1066,17 +1066,17 @@ d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_e 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; - } - pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo = {}; - pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format = targetFmt; - HRESULT hr = - pD3D12Enc->m_pD3D12Screen->dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, - &pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo, - sizeof(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo)); - if (FAILED(hr)) { - debug_printf("CheckFeatureSupport failed with HR 0x%x\n", (unsigned)hr); - return false; + pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo = {}; + pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format = targetFmt; + HRESULT hr = + pD3D12Enc->m_pD3D12Screen->dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, + &pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo, + sizeof(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo)); + if (FAILED(hr)) { + debug_printf("CheckFeatureSupport failed with HR 0x%x\n", (unsigned)hr); + return false; + } } // Set resolution (ie. frame_size) diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc_h264.cpp b/src/gallium/drivers/d3d12/d3d12_video_enc_h264.cpp index f7bf30c24a5..2124667b602 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_enc_h264.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_enc_h264.cpp @@ -970,16 +970,16 @@ d3d12_video_encoder_update_current_encoder_config_state_h264(struct d3d12_video_ DXGI_FORMAT targetFmt = d3d12_convert_pipe_video_profile_to_dxgi_format(pD3D12Enc->base.profile); if (pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format != targetFmt) { pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_input_format; - } - pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo = {}; - pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format = targetFmt; - HRESULT hr = pD3D12Enc->m_pD3D12Screen->dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, - &pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo, - sizeof(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo)); - if (FAILED(hr)) { - debug_printf("CheckFeatureSupport failed with HR %x\n", (unsigned)hr); - return false; + pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo = {}; + pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format = targetFmt; + HRESULT hr = pD3D12Enc->m_pD3D12Screen->dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, + &pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo, + sizeof(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo)); + if (FAILED(hr)) { + debug_printf("CheckFeatureSupport failed with HR %x\n", (unsigned)hr); + return false; + } } // Set intra-refresh config diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp b/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp index fcb933162a4..7c761932e3e 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp @@ -1280,16 +1280,16 @@ d3d12_video_encoder_update_current_encoder_config_state_hevc(struct d3d12_video_ DXGI_FORMAT targetFmt = d3d12_convert_pipe_video_profile_to_dxgi_format(pD3D12Enc->base.profile); if (pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format != targetFmt) { pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_input_format; - } - pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo = {}; - pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format = targetFmt; - HRESULT hr = pD3D12Enc->m_pD3D12Screen->dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, - &pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo, - sizeof(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo)); - if (FAILED(hr)) { - debug_printf("CheckFeatureSupport failed with HR %x\n", (unsigned)hr); - return false; + pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo = {}; + pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format = targetFmt; + HRESULT hr = pD3D12Enc->m_pD3D12Screen->dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, + &pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo, + sizeof(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo)); + if (FAILED(hr)) { + debug_printf("CheckFeatureSupport failed with HR %x\n", (unsigned)hr); + return false; + } } // Set resolution