venus: cap api versions

We do not want to advertise 1.3 when we only support 1.2.
macos/master
Chia-I Wu 3 years ago
parent bcb3866f66
commit fd6d1bba0d
  1. 12
      src/venus/vkr_common.h
  2. 8
      src/venus/vkr_instance.c
  3. 1
      src/venus/vkr_physical_device.c

@ -34,6 +34,9 @@
#include "vkr_renderer.h" #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 VKR_DEBUG(category) (unlikely(vkr_debug_flags & VKR_DEBUG_##category))
/* define a type-safe cast function */ /* define a type-safe cast function */
@ -154,6 +157,15 @@ extern uint32_t vkr_debug_flags;
void void
vkr_log(const char *fmt, ...); 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 bool
object_array_init(struct vkr_context *ctx, object_array_init(struct vkr_context *ctx,
struct object_array *arr, struct object_array *arr,

@ -16,7 +16,13 @@ vkr_dispatch_vkEnumerateInstanceVersion(UNUSED struct vn_dispatch_context *dispa
struct vn_command_vkEnumerateInstanceVersion *args) struct vn_command_vkEnumerateInstanceVersion *args)
{ {
vn_replace_vkEnumerateInstanceVersion_args_handle(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 static void

@ -219,6 +219,7 @@ vkr_physical_device_init_properties(struct vkr_physical_device *physical_dev)
vkGetPhysicalDeviceProperties(handle, &physical_dev->properties); vkGetPhysicalDeviceProperties(handle, &physical_dev->properties);
VkPhysicalDeviceProperties *props = &physical_dev->properties; VkPhysicalDeviceProperties *props = &physical_dev->properties;
props->apiVersion = vkr_api_version_cap_minor(props->apiVersion, VKR_MAX_API_VERSION);
props->driverVersion = 0; props->driverVersion = 0;
/* TODO lie about props->pipelineCacheUUID and patch cache header */ /* TODO lie about props->pipelineCacheUUID and patch cache header */

Loading…
Cancel
Save