diff --git a/src/venus/vkr_common.c b/src/venus/vkr_common.c index 5e9d8e8..6a3e5ba 100644 --- a/src/venus/vkr_common.c +++ b/src/venus/vkr_common.c @@ -143,6 +143,19 @@ vkr_log(const char *fmt, ...) virgl_log(line); } +void +vkr_extension_table_init(struct vn_info_extension_table *table, + const char *const *exts, + uint32_t count) +{ + memset(table, 0, sizeof(*table)); + for (uint32_t i = 0; i < count; i++) { + const struct vn_info_extension *ext = vn_info_extension_get(exts[i]); + if (ext) + table->enabled[ext->index] = true; + } +} + uint32_t vkr_extension_get_spec_version(const char *name) { diff --git a/src/venus/vkr_common.h b/src/venus/vkr_common.h index 0311e50..e1c9ce5 100644 --- a/src/venus/vkr_common.h +++ b/src/venus/vkr_common.h @@ -59,6 +59,7 @@ .begin = (offset), .end = (offset) + (size) \ } +struct vn_info_extension_table; struct vkr_context; struct vkr_instance; struct vkr_physical_device; @@ -166,6 +167,11 @@ vkr_api_version_cap_minor(uint32_t version, uint32_t cap) return version; } +void +vkr_extension_table_init(struct vn_info_extension_table *table, + const char *const *exts, + uint32_t count); + uint32_t vkr_extension_get_spec_version(const char *name); diff --git a/src/venus/vkr_device.c b/src/venus/vkr_device.c index d2b7e26..abbcfaf 100644 --- a/src/venus/vkr_device.c +++ b/src/venus/vkr_device.c @@ -219,6 +219,19 @@ vkr_device_init_entry_points(struct vkr_device *dev, uint32_t api_version) handle, "vkGetMemoryFdPropertiesKHR"); } +static void +vkr_device_init_proc_table(struct vkr_device *dev, + uint32_t api_version, + const char *const *exts, + uint32_t count) +{ + struct vn_info_extension_table ext_table; + vkr_extension_table_init(&ext_table, exts, count); + + vn_util_init_device_proc_table(dev->base.handle.device, api_version, &ext_table, + &dev->proc_table); +} + static void vkr_dispatch_vkCreateDevice(struct vn_dispatch_context *dispatch, struct vn_command_vkCreateDevice *args) @@ -272,10 +285,12 @@ vkr_dispatch_vkCreateDevice(struct vn_dispatch_context *dispatch, return; } - free(exts); - dev->physical_device = physical_dev; + vkr_device_init_proc_table(dev, physical_dev->api_version, exts, ext_count); + + free(exts); + args->ret = vkr_device_create_queues(ctx, dev, args->pCreateInfo->queueCreateInfoCount, args->pCreateInfo->pQueueCreateInfos); if (args->ret != VK_SUCCESS) { diff --git a/src/venus/vkr_device.h b/src/venus/vkr_device.h index 29cca34..1c510d7 100644 --- a/src/venus/vkr_device.h +++ b/src/venus/vkr_device.h @@ -6,8 +6,9 @@ #ifndef VKR_DEVICE_H #define VKR_DEVICE_H -#include "vkr_common.h" +#include "venus-protocol/vn_protocol_renderer_util.h" +#include "vkr_common.h" #include "vkr_context.h" struct vkr_device { @@ -15,6 +16,8 @@ struct vkr_device { struct vkr_physical_device *physical_device; + struct vn_device_proc_table proc_table; + /* Vulkan 1.2 */ PFN_vkGetSemaphoreCounterValue GetSemaphoreCounterValue; PFN_vkWaitSemaphores WaitSemaphores; diff --git a/src/venus/vkr_physical_device.c b/src/venus/vkr_physical_device.c index 95cf706..d98a9b8 100644 --- a/src/venus/vkr_physical_device.c +++ b/src/venus/vkr_physical_device.c @@ -224,6 +224,14 @@ vkr_physical_device_init_properties(struct vkr_physical_device *physical_dev) /* TODO lie about props->pipelineCacheUUID and patch cache header */ } +static void +vkr_physical_device_init_proc_table(struct vkr_physical_device *physical_dev, + struct vkr_instance *instance) +{ + vn_util_init_physical_device_proc_table(instance->base.handle.instance, + &physical_dev->proc_table); +} + static void vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch, struct vn_command_vkEnumeratePhysicalDevices *args) @@ -281,6 +289,7 @@ vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch, physical_dev->base.handle.physical_device = instance->physical_device_handles[i]; + vkr_physical_device_init_proc_table(physical_dev, instance); vkr_physical_device_init_properties(physical_dev); physical_dev->api_version = MIN2(physical_dev->properties.apiVersion, instance->api_version); diff --git a/src/venus/vkr_physical_device.h b/src/venus/vkr_physical_device.h index 73e5e40..d3cfe29 100644 --- a/src/venus/vkr_physical_device.h +++ b/src/venus/vkr_physical_device.h @@ -8,11 +8,15 @@ #include "vkr_common.h" +#include "venus-protocol/vn_protocol_renderer_util.h" + struct gbm_device; struct vkr_physical_device { struct vkr_object base; + struct vn_physical_device_proc_table proc_table; + VkPhysicalDeviceProperties properties; uint32_t api_version;