diff --git a/docs/android.rst b/docs/android.rst index b96d43c05e543..0149c195e9b21 100644 --- a/docs/android.rst +++ b/docs/android.rst @@ -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 diff --git a/meson.build b/meson.build index 03fcc1a03815c..7697286699611 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/meson_options.txt b/meson_options.txt index 0bd92d3916dcb..3b66f75ae8381 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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( diff --git a/src/freedreno/drm/meson.build b/src/freedreno/drm/meson.build index cbbfc75f01af5..90ce1921228cd 100644 --- a/src/freedreno/drm/meson.build +++ b/src/freedreno/drm/meson.build @@ -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 diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index 904a14ce8156b..641106791cb97 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -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 diff --git a/src/freedreno/vulkan/tu_knl.c b/src/freedreno/vulkan/tu_knl.c index 5542f6c0fb539..1ab4036867a4c 100644 --- a/src/freedreno/vulkan/tu_knl.c +++ b/src/freedreno/vulkan/tu_knl.c @@ -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", diff --git a/src/freedreno/vulkan/tu_knl.h b/src/freedreno/vulkan/tu_knl.h index 609c44253206f..ede292c744ae9 100644 --- a/src/freedreno/vulkan/tu_knl.h +++ b/src/freedreno/vulkan/tu_knl.h @@ -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, diff --git a/src/gallium/targets/dri/meson.build b/src/gallium/targets/dri/meson.build index ddf67e99b6c63..fbec1da957b0f 100644 --- a/src/gallium/targets/dri/meson.build +++ b/src/gallium/targets/dri/meson.build @@ -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'],