Commit d66378db authored by Chia-I Wu's avatar Chia-I Wu Committed by Marge Bot
Browse files

vkr: init proc tables



Adds the code to make use of the new proc table functions
in the [physical_]device initialization.

Co-authored-by: Igor Torrente's avatarIgor Torrente <igor.torrente@collabora.com>
Co-authored-by: Chia-I Wu's avatarChia-I Wu <olvaffe@gmail.com>
Part-of: <!719>
parent d8ba4398
......@@ -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)
{
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment