Skip to content

radeonsi: get enc/dec caps from kernel only on amdgpu

Andres Calderon Jaramillo requested to merge andrescj-chromium/mesa:kabini into main

!20969 (merged) made it so that we query the kernel for decode/encode capabilities when possible. When we do decide to rely on the kernel, we extract the capabilities from sscreen->info.dec_caps and sscreen->info.enc_caps, and so we assume those have been filled out correctly. Currently, the QUERYABLE_KERNEL macro helps determine if we're going to rely on the kernel, and right now, it's true if sscreen->info.drm_minor >= 41.

The problem is that this DRM version check is not sufficient because, as far as I can tell, dec_caps and enc_caps are only filled on the amdgpu path: they're filled by calling amdgpu_query_video_caps_info() in ac_query_gpu_info() which is only called in either src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c or src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c:

$ git grep ac_query_gpu_info
docs/relnotes/20.2.5.rst:- ac: Don't negate strstr return values in ac_query_gpu_info
docs/relnotes/20.3.0.rst:- ac: Don't negate strstr return values in ac_query_gpu_info
docs/relnotes/21.0.0.rst:- ac: Don't negate strstr return values in ac_query_gpu_info
docs/relnotes/22.2.0.rst:- ac/gpu_info: remove amdgpu_gpu_info parameter from ac_query_gpu_info
docs/relnotes/23.1.0.rst:- ac: don't call ac_query_pci_bus_info from ac_query_gpu_info
docs/relnotes/23.2.1.rst:- Revert "ac: don't call ac_query_pci_bus_info from ac_query_gpu_info"
docs/relnotes/23.3.0.rst:- Revert "ac: don't call ac_query_pci_bus_info from ac_query_gpu_info"
src/amd/common/ac_gpu_info.c:bool ac_query_gpu_info(int fd, void *dev_p, struct radeon_info *info,
src/amd/common/ac_gpu_info.h:bool ac_query_gpu_info(int fd, void *dev_p, struct radeon_info *info,
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c:   if (!ac_query_gpu_info(fd, ws->dev, &ws->info, true))
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c:   if (!ac_query_gpu_info(fd, ws->dev, &ws->info, false))

Therefore, querying the kernel won't work for the radeon driver since sscreen->info.dec_caps and sscreen->info.enc_caps are not expected to be correct in that path.

My MR updates the QUERYABLE_KERNEL to be false when not using the amdgpu driver.

I've tested this with an AMD KABINI (running with radeon) and libva. Before my MR, I got the following output from vadumpcaps output the following:

$ vadumpcaps 2>&1 | grep -B 2 -A 31 H264ConstrainedBaseline
        {
            "profile": 13,
            "name": "H264ConstrainedBaseline",
            "description": "H.264 / MPEG-4 part 10 (AVC) Constrained Baseline Profile",
            "entrypoints": [
                {
                    "entrypoint": 1,
                    "name": "VLD",
                    "description": "Decode Slice",
                    "attributes": {
                        "rt_formats": [
                            "YUV420",
                        ],
                    },
                    "surface_formats": [
                        {
                            "rt_format": "YUV420",
                            "memory_types": [
                                "VA",
                                "DRM_PRIME",
                                "DRM_PRIME_2",
                            ],
                            "min_width": 64,
                            "min_height": 64,
                            "max_width": 0,
                            "max_height": 0,
                            "pixel_formats": [
                                "NV12",
                            ],
                        },
                    ],
                },
            ],
        },

After my MR, it outputs:

$ vadumpcaps 2>&1 | grep -B 2 -A 31 H264ConstrainedBaseline
        {
            "profile": 13,
            "name": "H264ConstrainedBaseline",
            "description": "H.264 / MPEG-4 part 10 (AVC) Constrained Baseline Profile",
            "entrypoints": [
                {
                    "entrypoint": 1,
                    "name": "VLD",
                    "description": "Decode Slice",
                    "attributes": {
                        "rt_formats": [
                            "YUV420",
                        ],
                        "max_picture_width": 2048,
                        "max_picture_height": 1152,
                    },
                    "surface_formats": [
                        {
                            "rt_format": "YUV420",
                            "memory_types": [
                                "VA",
                                "DRM_PRIME",
                                "DRM_PRIME_2",
                            ],
                            "min_width": 64,
                            "min_height": 64,
                            "max_width": 2048,
                            "max_height": 1152,
                            "pixel_formats": [
                                "NV12",
                            ],
                        },
                    ],
                },

In particular, note the change in max_width/max_height.

Merge request reports