radv/virtio: support vpipe

Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Rob Clark <robdclark@chromium.org>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34470>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-03-13 11:44:02 +01:00 committed by Marge Bot
parent a96356b26e
commit 999d5098b4
6 changed files with 31 additions and 3 deletions

View file

@ -1184,7 +1184,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr
device->rt_handles = _mesa_hash_table_create(NULL, _mesa_hash_u32, _mesa_key_u32_equal);
device->ws = pdev->ws;
vk_device_set_drm_fd(&device->vk, device->ws->get_fd(device->ws));
device->vk.sync = device->ws->get_sync_provider(device->ws);
/* With update after bind we can't attach bo's to the command buffer
* from the descriptor set anymore, so we have to use a global BO list.

View file

@ -2101,7 +2101,12 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
}
if (!strcmp(version->name, "amdgpu")) {
/* nothing to do. */
#ifdef HAVE_AMDGPU_VIRTIO
if (debug_get_bool_option("AMD_FORCE_VPIPE", false)) {
is_virtio = true;
fd = -1;
}
#endif
} else
#ifdef HAVE_AMDGPU_VIRTIO
if (!strcmp(version->name, "virtio_gpu")) {

View file

@ -317,6 +317,8 @@ struct radeon_winsys {
int (*get_fd)(struct radeon_winsys *ws);
const struct vk_sync_type *const *(*get_sync_types)(struct radeon_winsys *ws);
struct util_sync_provider *(*get_sync_provider)(struct radeon_winsys *ws);
};
static inline uint64_t

View file

@ -170,6 +170,15 @@ radv_amdgpu_winsys_get_sync_types(struct radeon_winsys *rws)
return ws->sync_types;
}
static struct util_sync_provider *
radv_amdgpu_winsys_get_sync_provider(struct radeon_winsys *rws)
{
struct radv_amdgpu_winsys *ws = (struct radv_amdgpu_winsys *)rws;
struct util_sync_provider *p = ac_drm_device_get_sync_provider(ws->dev);
/* vk_device owns the provider, so we need to clone it. */
return p->clone(p);
}
VkResult
radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags, bool reserve_vmid, bool is_virtio,
struct radeon_winsys **winsys)
@ -274,7 +283,7 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags,
}
int num_sync_types = 0;
ws->syncobj_sync_type = vk_drm_syncobj_get_type(ws->fd);
ws->syncobj_sync_type = vk_drm_syncobj_get_type_from_provider(ac_drm_device_get_sync_provider(dev));
if (ws->syncobj_sync_type.features) {
/* multi wait is always supported */
ws->syncobj_sync_type.features |= VK_SYNC_FEATURE_GPU_MULTI_WAIT;
@ -309,6 +318,7 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags,
ws->base.destroy = radv_amdgpu_winsys_destroy;
ws->base.get_fd = radv_amdgpu_winsys_get_fd;
ws->base.get_sync_types = radv_amdgpu_winsys_get_sync_types;
ws->base.get_sync_provider = radv_amdgpu_winsys_get_sync_provider;
radv_amdgpu_bo_init_functions(ws);
radv_amdgpu_cs_init_functions(ws);

View file

@ -10,6 +10,7 @@
#include "radv_null_winsys_public.h"
#include "util/u_string.h"
#include "util/u_sync_provider.h"
#include "radv_null_bo.h"
#include "radv_null_cs.h"
#include "vk_sync_dummy.h"
@ -189,6 +190,12 @@ radv_null_winsys_get_sync_types(struct radeon_winsys *rws)
return radv_null_winsys(rws)->sync_types;
}
static struct util_sync_provider *
radv_null_winsys_get_sync_provider(struct radeon_winsys *rws)
{
return radv_null_winsys(rws)->sync_provider;
}
struct radeon_winsys *
radv_null_winsys_create()
{
@ -202,11 +209,13 @@ radv_null_winsys_create()
ws->base.query_info = radv_null_winsys_query_info;
ws->base.get_fd = radv_null_winsys_get_fd;
ws->base.get_sync_types = radv_null_winsys_get_sync_types;
ws->base.get_sync_provider = radv_null_winsys_get_sync_provider;
ws->base.get_chip_name = radv_null_winsys_get_chip_name;
radv_null_bo_init_functions(ws);
radv_null_cs_init_functions(ws);
ws->sync_types[0] = &vk_sync_dummy_type;
ws->sync_types[1] = NULL;
ws->sync_provider = util_sync_provider_drm(-1);
return &ws->base;
}

View file

@ -16,10 +16,12 @@
#include "radv_radeon_winsys.h"
struct vk_sync_type;
struct util_sync_provider;
struct radv_null_winsys {
struct radeon_winsys base;
const struct vk_sync_type *sync_types[2];
struct util_sync_provider *sync_provider;
};
static inline struct radv_null_winsys *