virgl:Fix ITEM_CPY macro pointer copy bug
authorCong Liu <liucong2@kylinos.cn>
Thu, 28 Sep 2023 10:36:06 +0000 (18:36 +0800)
committerMarge Bot <emma+marge@anholt.net>
Sat, 30 Sep 2023 03:01:21 +0000 (03:01 +0000)
The ITEM_CPY macro uses the memcpy function to copy the item variable.
When item is a pointer, the memcpy function will copy the value of the
pointer, not the address that the pointer points to.

Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Reviewerd-by: Feng Jiang <jiangfeng@kylinos.cn>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25453>

src/gallium/drivers/virgl/virgl_video.c

index 49d29db..6a21f60 100644 (file)
@@ -549,8 +549,10 @@ static int fill_mpeg4_picture_desc(const struct pipe_picture_desc *desc,
     ITEM_SET(vmpeg4, mpeg4, rounding_control);
     ITEM_SET(vmpeg4, mpeg4, alternate_vertical_scan_flag);
     ITEM_SET(vmpeg4, mpeg4, top_field_first);
-    ITEM_CPY(vmpeg4, mpeg4, intra_matrix);
-    ITEM_CPY(vmpeg4, mpeg4, non_intra_matrix);
+
+    memcpy(vmpeg4->intra_matrix, mpeg4->intra_matrix, 64);
+    memcpy(vmpeg4->non_intra_matrix, mpeg4->non_intra_matrix, 64);
+
     for (i = 0; i < ARRAY_SIZE(mpeg4->ref); i++) {
         vbuf = virgl_video_buffer(mpeg4->ref[i]);
         vmpeg4->ref[i] = vbuf ? vbuf->handle : 0;