tu+meson: Re-work KMD selection

Now that turnip can support multiple kernel-mode drivers in a single
build, re-work the meson option to have a single list of KMDs, rather
than special options to enable kgsl for turnip or virtio for gallium.

It is temporarily a bit awkward as gallium does not yet support kgsl
and turnip does not yet support virtio.  But both of those are planned
or in-progress, so long term a single list is the most sensible option.

TODO freedreno/drm support to build with only virtio support.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21394>
This commit is contained in:
Rob Clark 2023-02-17 11:51:49 -08:00 committed by Marge Bot
parent 407e4929de
commit 6a28986eb4
8 changed files with 33 additions and 31 deletions

View File

@ -48,7 +48,7 @@ one cross-compiling the turnip driver for a stock Pixel phone)
-Dandroid-stub=true \
-Dgallium-drivers= \
-Dvulkan-drivers=freedreno \
-Dfreedreno-kgsl=true
-Dfreedreno-kmds=kgsl
ninja -C build-android-aarch64
Replacing Android drivers on stock Android

View File

@ -131,11 +131,6 @@ with_shared_glapi = with_shared_glapi and with_any_opengl
system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android'].contains(host_machine.system())
with_freedreno_kgsl = get_option('freedreno-kgsl')
if with_freedreno_kgsl
system_has_kms_drm = false
endif
gallium_drivers = get_option('gallium-drivers')
if gallium_drivers.contains('auto')
if system_has_kms_drm
@ -193,6 +188,13 @@ foreach gallium_driver : gallium_drivers
pre_args += '-DHAVE_@0@'.format(gallium_driver.to_upper())
endforeach
freedreno_kmds = get_option('freedreno-kmds')
# If building only vulkan with only kgsl kmd support, there is no libdrm
# dependency:
if freedreno_kmds.length() == 1 and freedreno_kmds.contains('kgsl') and not with_gallium_freedreno
system_has_kms_drm = false
endif
with_gallium = gallium_drivers.length() != 0
with_gallium_kmsro = system_has_kms_drm and [
with_gallium_asahi,
@ -244,7 +246,6 @@ with_freedreno_vk = _vulkan_drivers.contains('freedreno')
with_panfrost_vk = _vulkan_drivers.contains('panfrost')
with_swrast_vk = _vulkan_drivers.contains('swrast')
with_virtio_vk = _vulkan_drivers.contains('virtio-experimental')
with_freedreno_virtio = get_option('freedreno-virtio')
with_broadcom_vk = _vulkan_drivers.contains('broadcom')
with_imagination_vk = _vulkan_drivers.contains('imagination-experimental')
with_imagination_srv = get_option('imagination-srv')

View File

@ -198,19 +198,16 @@ option(
'will be built'
)
# Note that currently turnip supports msm and kgsl, while the gallium driver
# support msm and virtio. This is a temporary situation with virtio support
# for turnip and kgsl support for gallium planned/in-progress.
option(
'freedreno-kgsl',
type : 'boolean',
value : false,
description : 'use kgsl backend for freedreno vulkan driver',
)
option(
'freedreno-virtio',
type : 'boolean',
value : false,
description : 'use experimental virtio backend for freedreno (currently ' +
'only gallium driver)',
'freedreno-kmds',
type : 'array',
value : ['msm'],
choices : ['msm', 'kgsl', 'virtio'],
description : 'List of kernel-mode drivers to enable for freedreno ' +
'gallium and vulkan driver',
)
option(

View File

@ -62,7 +62,7 @@ libfreedreno_drm_virtio_files = files(
'virtio/virtio_ringbuffer.c',
'virtio/virtio_ringbuffer.h',
)
if with_freedreno_virtio
if freedreno_kmds.contains('virtio')
libfreedreno_drm_files += libfreedreno_drm_virtio_files
libfreedreno_drm_flags += '-DHAVE_FREEDRENO_VIRTIO'
libfreedreno_drm_includes += inc_virtio_gpu

View File

@ -67,12 +67,18 @@ if with_xlib_lease
tu_deps += [dep_xlib_xrandr]
endif
if with_freedreno_kgsl
tu_flags += '-DTU_USE_KGSL'
# Even if libdrm is available we shouldn't use it in KGSL build
if not system_has_kms_drm
# Even if libdrm is available we shouldn't use it in KGSL-only build
tu_flags += '-UHAVE_LIBDRM'
endif
if freedreno_kmds.contains('kgsl')
tu_flags += '-DTU_HAS_KGSL'
libtu_files += files('tu_knl_kgsl.c')
else
endif
if freedreno_kmds.contains('msm')
tu_flags += '-DTU_HAS_MSM'
libtu_files += files('tu_knl_drm_msm.c')
tu_deps += dep_libdrm
endif

View File

@ -119,7 +119,7 @@ tu_queue_submit(struct vk_queue *vk_queue, struct vk_queue_submit *submit)
VkResult
tu_enumerate_devices(struct vk_instance *vk_instance)
{
#ifdef TU_USE_KGSL
#ifdef TU_HAS_KGSL
struct tu_instance *instance =
container_of(vk_instance, struct tu_instance, vk);
@ -168,7 +168,6 @@ tu_physical_device_try_create(struct vk_instance *vk_instance,
const char *primary_path = drm_device->nodes[DRM_NODE_PRIMARY];
const char *path = drm_device->nodes[DRM_NODE_RENDER];
VkResult result = VK_SUCCESS;
drmVersionPtr version;
int fd;
int master_fd = -1;
@ -189,8 +188,11 @@ tu_physical_device_try_create(struct vk_instance *vk_instance,
struct tu_physical_device *device = NULL;
VkResult result = VK_ERROR_INCOMPATIBLE_DRIVER;
if (strcmp(version->name, "msm") == 0) {
#ifdef TU_HAS_MSM
result = tu_knl_drm_msm_load(instance, fd, version, &device);
#endif
} else {
result = vk_startup_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
"device %s (%s) is not compatible with turnip",

View File

@ -46,9 +46,7 @@ struct tu_bo {
const char *name; /* pointer to device->bo_sizes's entry's name */
int32_t refcnt;
#ifndef TU_USE_KGSL
uint32_t bo_list_idx;
#endif
bool implicit_sync : 1;
};
@ -122,9 +120,7 @@ tu_bo_get_ref(struct tu_bo *bo)
return bo;
}
#ifdef TU_USE_KGSL
VkResult tu_knl_kgsl_load(struct tu_instance *instance, int fd);
#endif
struct _drmVersion;
VkResult tu_knl_drm_msm_load(struct tu_instance *instance,

View File

@ -110,7 +110,7 @@ foreach d : [[with_gallium_kmsro, [
[with_gallium_r600, 'r600_dri.so'],
[with_gallium_svga, 'vmwgfx_dri.so'],
[with_gallium_virgl or
(with_gallium_freedreno and with_freedreno_virtio),
(with_gallium_freedreno and freedreno_kmds.contains('virtio')),
'virtio_gpu_dri.so'],
[with_gallium_lima, 'lima_dri.so'],
[with_gallium_zink, 'zink_dri.so'],