d3d12: HEVC Encode - Fix num_subregions_per_scanline rounding
authorTeng, Jin Chung <jin.chung.teng@intel.com>
Fri, 26 May 2023 05:54:47 +0000 (13:54 +0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 30 May 2023 12:08:11 +0000 (12:08 +0000)
num_subregions_per_scanline need to be round up

Signed-off-by: Teng, Jin Chung <jin.chung.teng@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23247>

src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp

index ad766f4..6680465 100644 (file)
@@ -318,7 +318,7 @@ d3d12_video_encoder_negotiate_current_hevc_slices_configuration(struct d3d12_vid
 
       uint32_t subregion_block_pixel_size = pD3D12Enc->m_currentEncodeCapabilities.m_currentResolutionSupportCaps.SubregionBlockPixelsSize;
       uint32_t num_subregions_per_scanline =
-         pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width / subregion_block_pixel_size;
+         DIV_ROUND_UP(pD3D12Enc->m_currentEncodeConfig.m_currentResolution.Width, subregion_block_pixel_size);
 
       /* m_currentResolutionSupportCaps.SubregionBlockPixelsSize can be a multiple of MinCUSize to accomodate for HW requirements 
          So, if the allowed subregion (slice) pixel size partition is bigger (a multiple) than the CTU size, we have to adjust
@@ -334,7 +334,9 @@ d3d12_video_encoder_negotiate_current_hevc_slices_configuration(struct d3d12_vid
 
       uint32_t subregionsize_to_ctu_factor = pD3D12Enc->m_currentEncodeCapabilities.m_currentResolutionSupportCaps.SubregionBlockPixelsSize / 
          minCUSize;
-      uint32_t num_subregions_per_slice = picture->slices_descriptors[0].num_ctu_in_slice / (subregionsize_to_ctu_factor*subregionsize_to_ctu_factor);
+      uint32_t num_subregions_per_slice = picture->slices_descriptors[0].num_ctu_in_slice
+                                                   * pD3D12Enc->m_currentEncodeCapabilities.m_currentResolutionSupportCaps.SubregionBlockPixelsSize
+                                                   / (subregionsize_to_ctu_factor * subregionsize_to_ctu_factor);
 
       bool bSliceAligned = ((num_subregions_per_slice % num_subregions_per_scanline) == 0);