diff --git a/src/venus/vkr_common.h b/src/venus/vkr_common.h index ab45a90..e5aa2d7 100644 --- a/src/venus/vkr_common.h +++ b/src/venus/vkr_common.h @@ -34,6 +34,9 @@ #include "vkr_renderer.h" +/* cap instance and device api versions to this */ +#define VKR_MAX_API_VERSION VK_API_VERSION_1_2 + #define VKR_DEBUG(category) (unlikely(vkr_debug_flags & VKR_DEBUG_##category)) /* define a type-safe cast function */ @@ -154,6 +157,15 @@ extern uint32_t vkr_debug_flags; void vkr_log(const char *fmt, ...); +static inline uint32_t +vkr_api_version_cap_minor(uint32_t version, uint32_t cap) +{ + assert(VK_API_VERSION_MAJOR(version) == VK_API_VERSION_MAJOR(cap)); + if (VK_API_VERSION_MINOR(version) > VK_API_VERSION_MINOR(cap)) + version = cap - VK_API_VERSION_PATCH(cap) + VK_API_VERSION_PATCH(version); + return version; +} + bool object_array_init(struct vkr_context *ctx, struct object_array *arr, diff --git a/src/venus/vkr_instance.c b/src/venus/vkr_instance.c index bd9f2fd..3dee474 100644 --- a/src/venus/vkr_instance.c +++ b/src/venus/vkr_instance.c @@ -16,7 +16,13 @@ vkr_dispatch_vkEnumerateInstanceVersion(UNUSED struct vn_dispatch_context *dispa struct vn_command_vkEnumerateInstanceVersion *args) { vn_replace_vkEnumerateInstanceVersion_args_handle(args); - args->ret = vkEnumerateInstanceVersion(args->pApiVersion); + + uint32_t version = 0; + args->ret = vkEnumerateInstanceVersion(&version); + if (args->ret == VK_SUCCESS) + version = vkr_api_version_cap_minor(version, VKR_MAX_API_VERSION); + + *args->pApiVersion = version; } static void diff --git a/src/venus/vkr_physical_device.c b/src/venus/vkr_physical_device.c index 40dc1c3..baaeca4 100644 --- a/src/venus/vkr_physical_device.c +++ b/src/venus/vkr_physical_device.c @@ -219,6 +219,7 @@ vkr_physical_device_init_properties(struct vkr_physical_device *physical_dev) vkGetPhysicalDeviceProperties(handle, &physical_dev->properties); VkPhysicalDeviceProperties *props = &physical_dev->properties; + props->apiVersion = vkr_api_version_cap_minor(props->apiVersion, VKR_MAX_API_VERSION); props->driverVersion = 0; /* TODO lie about props->pipelineCacheUUID and patch cache header */