vkr: add an extension table

vkr_extension_table allows us to fine-control which extensions are
advertised.

To support an extension, we need venus-protocol support and vkr support.
One is generated and one is open-coded.  We don't want to advertise an
extension automatically whenever an updated venus-protocol includes it.

Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
macos/master
Chia-I Wu 3 years ago
parent fd6d1bba0d
commit 3136d6614c
  1. 2
      src/venus/venus-protocol/vn_protocol_renderer.h
  2. 251
      src/venus/venus-protocol/vn_protocol_renderer_info.h
  3. 71
      src/venus/vkr_common.c
  4. 3
      src/venus/vkr_common.h
  5. 3
      src/venus/vkr_instance.c
  6. 3
      src/venus/vkr_physical_device.c
  7. 4
      src/venus/vkr_renderer.c

@ -1,4 +1,4 @@
/* This file is generated by venus-protocol git-74c1c432. */ /* This file is generated by venus-protocol git-2cbfe3a2. */
/* /*
* Copyright 2020 Google LLC * Copyright 2020 Google LLC

@ -10,6 +10,75 @@
#include "vn_protocol_renderer_defines.h" #include "vn_protocol_renderer_defines.h"
struct vn_info_extension_table {
union {
bool enabled[54];
struct {
bool EXT_command_serialization;
bool EXT_descriptor_indexing;
bool EXT_external_memory_dma_buf;
bool EXT_host_query_reset;
bool EXT_image_drm_format_modifier;
bool EXT_queue_family_foreign;
bool EXT_sampler_filter_minmax;
bool EXT_scalar_block_layout;
bool EXT_separate_stencil_usage;
bool EXT_shader_viewport_index_layer;
bool EXT_transform_feedback;
bool KHR_16bit_storage;
bool KHR_8bit_storage;
bool KHR_bind_memory2;
bool KHR_buffer_device_address;
bool KHR_create_renderpass2;
bool KHR_dedicated_allocation;
bool KHR_depth_stencil_resolve;
bool KHR_descriptor_update_template;
bool KHR_device_group;
bool KHR_device_group_creation;
bool KHR_draw_indirect_count;
bool KHR_driver_properties;
bool KHR_external_fence;
bool KHR_external_fence_capabilities;
bool KHR_external_memory;
bool KHR_external_memory_capabilities;
bool KHR_external_memory_fd;
bool KHR_external_semaphore;
bool KHR_external_semaphore_capabilities;
bool KHR_get_memory_requirements2;
bool KHR_get_physical_device_properties2;
bool KHR_image_format_list;
bool KHR_imageless_framebuffer;
bool KHR_maintenance1;
bool KHR_maintenance2;
bool KHR_maintenance3;
bool KHR_multiview;
bool KHR_relaxed_block_layout;
bool KHR_sampler_mirror_clamp_to_edge;
bool KHR_sampler_ycbcr_conversion;
bool KHR_separate_depth_stencil_layouts;
bool KHR_shader_atomic_int64;
bool KHR_shader_draw_parameters;
bool KHR_shader_float16_int8;
bool KHR_shader_float_controls;
bool KHR_shader_subgroup_extended_types;
bool KHR_spirv_1_4;
bool KHR_storage_buffer_storage_class;
bool KHR_timeline_semaphore;
bool KHR_uniform_buffer_standard_layout;
bool KHR_variable_pointers;
bool KHR_vulkan_memory_model;
bool MESA_venus_protocol;
};
};
};
struct vn_info_extension {
uint32_t index;
const char *name;
uint32_t spec_version;
};
static inline uint32_t static inline uint32_t
vn_info_wire_format_version(void) vn_info_wire_format_version(void)
{ {
@ -23,133 +92,73 @@ vn_info_vk_xml_version(void)
} }
static inline int static inline int
vn_info_extension_compare(const void *a, const void *b) vn_info_extension_compare(const void *name, const void *ext)
{ {
return strcmp(a, *(const char **)b); return strcmp(name, ((const struct vn_info_extension *)ext)->name);
} }
static inline uint32_t static inline const struct vn_info_extension *
vn_info_extension_spec_version(const char *name) vn_info_extension_get(const char *name)
{ {
static uint32_t ext_count = 54; static const struct vn_info_extension vn_info_extensions[54] = {
static const char *ext_names[54] = { { 0, "VK_EXT_command_serialization", 0 },
"VK_EXT_command_serialization", { 1, "VK_EXT_descriptor_indexing", 2 },
"VK_EXT_descriptor_indexing", { 2, "VK_EXT_external_memory_dma_buf", 1 },
"VK_EXT_external_memory_dma_buf", { 3, "VK_EXT_host_query_reset", 1 },
"VK_EXT_host_query_reset", { 4, "VK_EXT_image_drm_format_modifier", 1 },
"VK_EXT_image_drm_format_modifier", { 5, "VK_EXT_queue_family_foreign", 1 },
"VK_EXT_queue_family_foreign", { 6, "VK_EXT_sampler_filter_minmax", 2 },
"VK_EXT_sampler_filter_minmax", { 7, "VK_EXT_scalar_block_layout", 1 },
"VK_EXT_scalar_block_layout", { 8, "VK_EXT_separate_stencil_usage", 1 },
"VK_EXT_separate_stencil_usage", { 9, "VK_EXT_shader_viewport_index_layer", 1 },
"VK_EXT_shader_viewport_index_layer", { 10, "VK_EXT_transform_feedback", 1 },
"VK_EXT_transform_feedback", { 11, "VK_KHR_16bit_storage", 1 },
"VK_KHR_16bit_storage", { 12, "VK_KHR_8bit_storage", 1 },
"VK_KHR_8bit_storage", { 13, "VK_KHR_bind_memory2", 1 },
"VK_KHR_bind_memory2", { 14, "VK_KHR_buffer_device_address", 1 },
"VK_KHR_buffer_device_address", { 15, "VK_KHR_create_renderpass2", 1 },
"VK_KHR_create_renderpass2", { 16, "VK_KHR_dedicated_allocation", 3 },
"VK_KHR_dedicated_allocation", { 17, "VK_KHR_depth_stencil_resolve", 1 },
"VK_KHR_depth_stencil_resolve", { 18, "VK_KHR_descriptor_update_template", 1 },
"VK_KHR_descriptor_update_template", { 19, "VK_KHR_device_group", 4 },
"VK_KHR_device_group", { 20, "VK_KHR_device_group_creation", 1 },
"VK_KHR_device_group_creation", { 21, "VK_KHR_draw_indirect_count", 1 },
"VK_KHR_draw_indirect_count", { 22, "VK_KHR_driver_properties", 1 },
"VK_KHR_driver_properties", { 23, "VK_KHR_external_fence", 1 },
"VK_KHR_external_fence", { 24, "VK_KHR_external_fence_capabilities", 1 },
"VK_KHR_external_fence_capabilities", { 25, "VK_KHR_external_memory", 1 },
"VK_KHR_external_memory", { 26, "VK_KHR_external_memory_capabilities", 1 },
"VK_KHR_external_memory_capabilities", { 27, "VK_KHR_external_memory_fd", 1 },
"VK_KHR_external_memory_fd", { 28, "VK_KHR_external_semaphore", 1 },
"VK_KHR_external_semaphore", { 29, "VK_KHR_external_semaphore_capabilities", 1 },
"VK_KHR_external_semaphore_capabilities", { 30, "VK_KHR_get_memory_requirements2", 1 },
"VK_KHR_get_memory_requirements2", { 31, "VK_KHR_get_physical_device_properties2", 2 },
"VK_KHR_get_physical_device_properties2", { 32, "VK_KHR_image_format_list", 1 },
"VK_KHR_image_format_list", { 33, "VK_KHR_imageless_framebuffer", 1 },
"VK_KHR_imageless_framebuffer", { 34, "VK_KHR_maintenance1", 2 },
"VK_KHR_maintenance1", { 35, "VK_KHR_maintenance2", 1 },
"VK_KHR_maintenance2", { 36, "VK_KHR_maintenance3", 1 },
"VK_KHR_maintenance3", { 37, "VK_KHR_multiview", 1 },
"VK_KHR_multiview", { 38, "VK_KHR_relaxed_block_layout", 1 },
"VK_KHR_relaxed_block_layout", { 39, "VK_KHR_sampler_mirror_clamp_to_edge", 3 },
"VK_KHR_sampler_mirror_clamp_to_edge", { 40, "VK_KHR_sampler_ycbcr_conversion", 14 },
"VK_KHR_sampler_ycbcr_conversion", { 41, "VK_KHR_separate_depth_stencil_layouts", 1 },
"VK_KHR_separate_depth_stencil_layouts", { 42, "VK_KHR_shader_atomic_int64", 1 },
"VK_KHR_shader_atomic_int64", { 43, "VK_KHR_shader_draw_parameters", 1 },
"VK_KHR_shader_draw_parameters", { 44, "VK_KHR_shader_float16_int8", 1 },
"VK_KHR_shader_float16_int8", { 45, "VK_KHR_shader_float_controls", 4 },
"VK_KHR_shader_float_controls", { 46, "VK_KHR_shader_subgroup_extended_types", 1 },
"VK_KHR_shader_subgroup_extended_types", { 47, "VK_KHR_spirv_1_4", 1 },
"VK_KHR_spirv_1_4", { 48, "VK_KHR_storage_buffer_storage_class", 1 },
"VK_KHR_storage_buffer_storage_class", { 49, "VK_KHR_timeline_semaphore", 2 },
"VK_KHR_timeline_semaphore", { 50, "VK_KHR_uniform_buffer_standard_layout", 1 },
"VK_KHR_uniform_buffer_standard_layout", { 51, "VK_KHR_variable_pointers", 1 },
"VK_KHR_variable_pointers", { 52, "VK_KHR_vulkan_memory_model", 3 },
"VK_KHR_vulkan_memory_model", { 53, "VK_MESA_venus_protocol", 100000 },
"VK_MESA_venus_protocol",
}; };
static const uint32_t ext_versions[54] = {
0,
2,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
3,
1,
1,
4,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
2,
1,
1,
1,
1,
3,
14,
1,
1,
1,
1,
4,
1,
1,
1,
2,
1,
1,
3,
100000,
};
const char **found;
found = bsearch(name, ext_names, ext_count, sizeof(ext_names[0]),
vn_info_extension_compare);
return found ? ext_versions[found - ext_names] : 0; return bsearch(name, vn_info_extensions, 54,
sizeof(*vn_info_extensions), vn_info_extension_compare);
} }
#endif /* VN_PROTOCOL_RENDERER_INFO_H */ #endif /* VN_PROTOCOL_RENDERER_INFO_H */

@ -8,9 +8,73 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "vkr_context.h" #include "vkr_context.h"
#include "vkr_cs.h" #include "vkr_cs.h"
static const struct vn_info_extension_table vkr_extension_table = {
/* Venus extensions */
.EXT_command_serialization = true,
.MESA_venus_protocol = true,
/* promoted to VK_VERSION_1_1 */
.KHR_16bit_storage = true,
.KHR_bind_memory2 = true,
.KHR_dedicated_allocation = true,
.KHR_descriptor_update_template = true,
.KHR_device_group = true,
.KHR_device_group_creation = true,
.KHR_external_fence = true,
.KHR_external_fence_capabilities = true,
.KHR_external_memory = true,
.KHR_external_memory_capabilities = true,
.KHR_external_semaphore = true,
.KHR_external_semaphore_capabilities = true,
.KHR_get_memory_requirements2 = true,
.KHR_get_physical_device_properties2 = true,
.KHR_maintenance1 = true,
.KHR_maintenance2 = true,
.KHR_maintenance3 = true,
.KHR_multiview = true,
.KHR_relaxed_block_layout = true,
.KHR_sampler_ycbcr_conversion = true,
.KHR_shader_draw_parameters = true,
.KHR_storage_buffer_storage_class = true,
.KHR_variable_pointers = true,
/* promoted to VK_VERSION_1_2 */
.KHR_8bit_storage = true,
.KHR_buffer_device_address = true,
.KHR_create_renderpass2 = true,
.KHR_depth_stencil_resolve = true,
.KHR_draw_indirect_count = true,
.KHR_driver_properties = true,
.KHR_image_format_list = true,
.KHR_imageless_framebuffer = true,
.KHR_sampler_mirror_clamp_to_edge = true,
.KHR_separate_depth_stencil_layouts = true,
.KHR_shader_atomic_int64 = true,
.KHR_shader_float16_int8 = true,
.KHR_shader_float_controls = true,
.KHR_shader_subgroup_extended_types = true,
.KHR_spirv_1_4 = true,
.KHR_timeline_semaphore = true,
.KHR_uniform_buffer_standard_layout = true,
.KHR_vulkan_memory_model = true,
.EXT_descriptor_indexing = true,
.EXT_host_query_reset = true,
.EXT_sampler_filter_minmax = true,
.EXT_scalar_block_layout = true,
.EXT_separate_stencil_usage = true,
.EXT_shader_viewport_index_layer = true,
/* KHR extensions */
.KHR_external_memory_fd = true,
/* EXT extensions */
.EXT_external_memory_dma_buf = true,
.EXT_image_drm_format_modifier = true,
.EXT_queue_family_foreign = true,
.EXT_transform_feedback = true,
};
void void
vkr_log(const char *fmt, ...) vkr_log(const char *fmt, ...)
{ {
@ -47,6 +111,13 @@ vkr_log(const char *fmt, ...)
virgl_log(line); virgl_log(line);
} }
uint32_t
vkr_extension_get_spec_version(const char *name)
{
const struct vn_info_extension *ext = vn_info_extension_get(name);
return ext && vkr_extension_table.enabled[ext->index] ? ext->spec_version : 0;
}
void void
object_array_fini(struct object_array *arr) object_array_fini(struct object_array *arr)
{ {

@ -166,6 +166,9 @@ vkr_api_version_cap_minor(uint32_t version, uint32_t cap)
return version; return version;
} }
uint32_t
vkr_extension_get_spec_version(const char *name);
bool bool
object_array_init(struct vkr_context *ctx, object_array_init(struct vkr_context *ctx,
struct object_array *arr, struct object_array *arr,

@ -5,7 +5,6 @@
#include "vkr_instance.h" #include "vkr_instance.h"
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "venus-protocol/vn_protocol_renderer_instance.h" #include "venus-protocol/vn_protocol_renderer_instance.h"
#include "vkr_context.h" #include "vkr_context.h"
@ -47,7 +46,7 @@ vkr_dispatch_vkEnumerateInstanceExtensionProperties(
for (uint32_t i = 0; i < ARRAY_SIZE(private_extensions); i++) { for (uint32_t i = 0; i < ARRAY_SIZE(private_extensions); i++) {
VkExtensionProperties *props = &private_extensions[i]; VkExtensionProperties *props = &private_extensions[i];
props->specVersion = vn_info_extension_spec_version(props->extensionName); props->specVersion = vkr_extension_get_spec_version(props->extensionName);
} }
const uint32_t count = MIN2(*args->pPropertyCount, ARRAY_SIZE(private_extensions)); const uint32_t count = MIN2(*args->pPropertyCount, ARRAY_SIZE(private_extensions));

@ -6,7 +6,6 @@
#include "vkr_physical_device.h" #include "vkr_physical_device.h"
#include "venus-protocol/vn_protocol_renderer_device.h" #include "venus-protocol/vn_protocol_renderer_device.h"
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "vrend_winsys_gbm.h" #include "vrend_winsys_gbm.h"
#include "vkr_context.h" #include "vkr_context.h"
@ -183,7 +182,7 @@ vkr_physical_device_init_extensions(struct vkr_physical_device *physical_dev,
else if (!strcmp(props->extensionName, "VK_KHR_external_fence_fd")) else if (!strcmp(props->extensionName, "VK_KHR_external_fence_fd"))
physical_dev->KHR_external_fence_fd = true; physical_dev->KHR_external_fence_fd = true;
const uint32_t spec_ver = vn_info_extension_spec_version(props->extensionName); const uint32_t spec_ver = vkr_extension_get_spec_version(props->extensionName);
if (spec_ver) { if (spec_ver) {
if (props->specVersion > spec_ver) if (props->specVersion > spec_ver)
props->specVersion = spec_ver; props->specVersion = spec_ver;

@ -26,9 +26,9 @@ vkr_get_capset(void *capset)
c->wire_format_version = vn_info_wire_format_version(); c->wire_format_version = vn_info_wire_format_version();
c->vk_xml_version = vn_info_vk_xml_version(); c->vk_xml_version = vn_info_vk_xml_version();
c->vk_ext_command_serialization_spec_version = c->vk_ext_command_serialization_spec_version =
vn_info_extension_spec_version("VK_EXT_command_serialization"); vkr_extension_get_spec_version("VK_EXT_command_serialization");
c->vk_mesa_venus_protocol_spec_version = c->vk_mesa_venus_protocol_spec_version =
vn_info_extension_spec_version("VK_MESA_venus_protocol"); vkr_extension_get_spec_version("VK_MESA_venus_protocol");
/* TODO always true once Mesa resolves its performance issue */ /* TODO always true once Mesa resolves its performance issue */
c->supports_blob_id_0 = (bool)(vkr_renderer_flags & VKR_RENDERER_RENDER_SERVER); c->supports_blob_id_0 = (bool)(vkr_renderer_flags & VKR_RENDERER_RENDER_SERVER);
} }

Loading…
Cancel
Save