d3d12: Fix out of bounds index check for texture array DPB
authorSil Vilerino <sivileri@microsoft.com>
Thu, 22 Sep 2022 17:07:59 +0000 (13:07 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 22 Sep 2022 22:03:44 +0000 (22:03 +0000)
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18763>

src/gallium/drivers/d3d12/d3d12_video_enc.cpp

index bb18c58..7b5916d 100644 (file)
@@ -1462,15 +1462,20 @@ d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec,
 
          CD3DX12_RESOURCE_DESC referencesTexArrayDesc(GetDesc(referenceFramesDescriptor.ppTexture2Ds[0]));
 
-         for (uint32_t referenceSubresource = 0; referenceSubresource < referencesTexArrayDesc.DepthOrArraySize;
-              referenceSubresource++) {
+#if DEBUG
+   // the reconpic output should be all the same texarray allocation
+   if((reconPicOutputTextureDesc.pReconstructedPicture) && (referenceFramesDescriptor.NumTexture2Ds > 0))
+      assert(referenceFramesDescriptor.ppTexture2Ds[0] == reconPicOutputTextureDesc.pReconstructedPicture);
 
+   for (uint32_t refIndex = 0; refIndex < referenceFramesDescriptor.NumTexture2Ds; refIndex++) {
             // all reference frames inputs should be all the same texarray allocation
             assert(referenceFramesDescriptor.ppTexture2Ds[0] ==
-                   referenceFramesDescriptor.ppTexture2Ds[referenceSubresource]);
+                   referenceFramesDescriptor.ppTexture2Ds[refIndex]);
+   }
+#endif
 
-            // the reconpic output should be all the same texarray allocation
-            assert(referenceFramesDescriptor.ppTexture2Ds[0] == reconPicOutputTextureDesc.pReconstructedPicture);
+         for (uint32_t referenceSubresource = 0; referenceSubresource < referencesTexArrayDesc.DepthOrArraySize;
+              referenceSubresource++) {
 
             uint32_t MipLevel, PlaneSlice, ArraySlice;
             D3D12DecomposeSubresource(referenceSubresource,