radeon/vce: Move global function pointer si_get_pic_param to local encoder structure
authorVeerabadhran <vegopala@amd.com>
Wed, 5 Feb 2020 14:03:01 +0000 (19:33 +0530)
committerVeerabadhran G <vegopala@amd.com>
Wed, 12 Feb 2020 13:43:35 +0000 (13:43 +0000)
Multi gpu use case broken when the function was global

Reviewed-by: Leo Liu <leo.liu@amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3731>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3731>

src/gallium/drivers/radeon/radeon_vce.c
src/gallium/drivers/radeon/radeon_vce.h
src/gallium/drivers/radeon/radeon_vce_40_2_2.c
src/gallium/drivers/radeon/radeon_vce_50.c
src/gallium/drivers/radeon/radeon_vce_52.c

index 3e909d8b3180c46cd96907e96b02e809fc0a453a..521dfb40a67bb7cb5d9f44652d058fae0a892753 100644 (file)
 #define FW_52_8_3 ((52 << 24) | (8 << 16) | (3 << 8))
 #define FW_53 (53 << 24)
 
-/* version specific function for getting parameters */
-static void (*si_get_pic_param)(struct rvce_encoder *enc,
-                                struct pipe_h264_enc_picture_desc *pic) = NULL;
-
 /**
  * flush commands to the hardware
  */
@@ -276,7 +272,7 @@ static void rvce_begin_frame(struct pipe_video_codec *encoder,
                enc->pic.rate_ctrl.target_bitrate != pic->rate_ctrl.target_bitrate;
 
        enc->pic = *pic;
-       si_get_pic_param(enc, pic);
+       enc->si_get_pic_param(enc, pic);
 
        enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma);
        enc->get_buffer(vid_buf->resources[1], NULL, &enc->chroma);
@@ -494,7 +490,6 @@ struct pipe_video_codec *si_vce_create_encoder(struct pipe_context *context,
        switch (sscreen->info.vce_fw_version) {
        case FW_40_2_2:
                si_vce_40_2_2_init(enc);
-               si_get_pic_param = si_vce_40_2_2_get_param;
                break;
 
        case FW_50_0_1:
@@ -502,20 +497,17 @@ struct pipe_video_codec *si_vce_create_encoder(struct pipe_context *context,
        case FW_50_10_2:
        case FW_50_17_3:
                si_vce_50_init(enc);
-               si_get_pic_param = si_vce_50_get_param;
                break;
 
        case FW_52_0_3:
        case FW_52_4_3:
        case FW_52_8_3:
                si_vce_52_init(enc);
-               si_get_pic_param = si_vce_52_get_param;
                break;
 
        default:
                if ((sscreen->info.vce_fw_version & (0xff << 24)) >= FW_53) {
                        si_vce_52_init(enc);
-                       si_get_pic_param = si_vce_52_get_param;
                } else
                        goto error;
        }
index b5cfe1780616c020a2c1d276a70cf8ed8bd9777b..bb2567ed3bee8039dd39228fb9398d1f51e4b901 100644 (file)
@@ -376,6 +376,8 @@ struct rvce_encoder {
        void (*task_info)(struct rvce_encoder *enc, uint32_t op,
                          uint32_t dep, uint32_t fb_idx,
                          uint32_t ring_idx);
+       void (*si_get_pic_param)(struct rvce_encoder *enc,
+                               struct pipe_h264_enc_picture_desc *pic);
 
        unsigned                        stream_handle;
 
index e17468c9097b693bd7ba7af0dec85505b96de162..f2d11d49c6f6e0e1ee0d709b7ce4e829c2c463b6 100644 (file)
@@ -443,4 +443,5 @@ void si_vce_40_2_2_init(struct rvce_encoder *enc)
        enc->config = config;
        enc->encode = encode;
        enc->destroy = destroy;
+       enc->si_get_pic_param = si_vce_40_2_2_get_param;
 }
index f4cbc9bb82b53d23623b53a1ad33143c57e3433f..e480ecb749f1f204330d512fcc20f59a10e2ec24 100644 (file)
@@ -238,4 +238,5 @@ void si_vce_50_init(struct rvce_encoder *enc)
        /* only the two below are different */
        enc->rate_control = rate_control;
        enc->encode = encode;
+       enc->si_get_pic_param = si_vce_50_get_param;
 }
index 364da4dbe24a0173ba4162243c30649405c4ddb5..bb97cdfe5c3d71fba0f9b673318050a66b641957 100644 (file)
@@ -667,4 +667,5 @@ void si_vce_52_init(struct rvce_encoder *enc)
        enc->config = config;
        enc->encode = encode;
        enc->destroy = destroy;
+       enc->si_get_pic_param = si_vce_52_get_param;
 }