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. 253
      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

@ -10,6 +10,75 @@
#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
vn_info_wire_format_version(void)
{
@ -23,133 +92,73 @@ vn_info_vk_xml_version(void)
}
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
vn_info_extension_spec_version(const char *name)
static inline const struct vn_info_extension *
vn_info_extension_get(const char *name)
{
static uint32_t ext_count = 54;
static const char *ext_names[54] = {
"VK_EXT_command_serialization",
"VK_EXT_descriptor_indexing",
"VK_EXT_external_memory_dma_buf",
"VK_EXT_host_query_reset",
"VK_EXT_image_drm_format_modifier",
"VK_EXT_queue_family_foreign",
"VK_EXT_sampler_filter_minmax",
"VK_EXT_scalar_block_layout",
"VK_EXT_separate_stencil_usage",
"VK_EXT_shader_viewport_index_layer",
"VK_EXT_transform_feedback",
"VK_KHR_16bit_storage",
"VK_KHR_8bit_storage",
"VK_KHR_bind_memory2",
"VK_KHR_buffer_device_address",
"VK_KHR_create_renderpass2",
"VK_KHR_dedicated_allocation",
"VK_KHR_depth_stencil_resolve",
"VK_KHR_descriptor_update_template",
"VK_KHR_device_group",
"VK_KHR_device_group_creation",
"VK_KHR_draw_indirect_count",
"VK_KHR_driver_properties",
"VK_KHR_external_fence",
"VK_KHR_external_fence_capabilities",
"VK_KHR_external_memory",
"VK_KHR_external_memory_capabilities",
"VK_KHR_external_memory_fd",
"VK_KHR_external_semaphore",
"VK_KHR_external_semaphore_capabilities",
"VK_KHR_get_memory_requirements2",
"VK_KHR_get_physical_device_properties2",
"VK_KHR_image_format_list",
"VK_KHR_imageless_framebuffer",
"VK_KHR_maintenance1",
"VK_KHR_maintenance2",
"VK_KHR_maintenance3",
"VK_KHR_multiview",
"VK_KHR_relaxed_block_layout",
"VK_KHR_sampler_mirror_clamp_to_edge",
"VK_KHR_sampler_ycbcr_conversion",
"VK_KHR_separate_depth_stencil_layouts",
"VK_KHR_shader_atomic_int64",
"VK_KHR_shader_draw_parameters",
"VK_KHR_shader_float16_int8",
"VK_KHR_shader_float_controls",
"VK_KHR_shader_subgroup_extended_types",
"VK_KHR_spirv_1_4",
"VK_KHR_storage_buffer_storage_class",
"VK_KHR_timeline_semaphore",
"VK_KHR_uniform_buffer_standard_layout",
"VK_KHR_variable_pointers",
"VK_KHR_vulkan_memory_model",
"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);
static const struct vn_info_extension vn_info_extensions[54] = {
{ 0, "VK_EXT_command_serialization", 0 },
{ 1, "VK_EXT_descriptor_indexing", 2 },
{ 2, "VK_EXT_external_memory_dma_buf", 1 },
{ 3, "VK_EXT_host_query_reset", 1 },
{ 4, "VK_EXT_image_drm_format_modifier", 1 },
{ 5, "VK_EXT_queue_family_foreign", 1 },
{ 6, "VK_EXT_sampler_filter_minmax", 2 },
{ 7, "VK_EXT_scalar_block_layout", 1 },
{ 8, "VK_EXT_separate_stencil_usage", 1 },
{ 9, "VK_EXT_shader_viewport_index_layer", 1 },
{ 10, "VK_EXT_transform_feedback", 1 },
{ 11, "VK_KHR_16bit_storage", 1 },
{ 12, "VK_KHR_8bit_storage", 1 },
{ 13, "VK_KHR_bind_memory2", 1 },
{ 14, "VK_KHR_buffer_device_address", 1 },
{ 15, "VK_KHR_create_renderpass2", 1 },
{ 16, "VK_KHR_dedicated_allocation", 3 },
{ 17, "VK_KHR_depth_stencil_resolve", 1 },
{ 18, "VK_KHR_descriptor_update_template", 1 },
{ 19, "VK_KHR_device_group", 4 },
{ 20, "VK_KHR_device_group_creation", 1 },
{ 21, "VK_KHR_draw_indirect_count", 1 },
{ 22, "VK_KHR_driver_properties", 1 },
{ 23, "VK_KHR_external_fence", 1 },
{ 24, "VK_KHR_external_fence_capabilities", 1 },
{ 25, "VK_KHR_external_memory", 1 },
{ 26, "VK_KHR_external_memory_capabilities", 1 },
{ 27, "VK_KHR_external_memory_fd", 1 },
{ 28, "VK_KHR_external_semaphore", 1 },
{ 29, "VK_KHR_external_semaphore_capabilities", 1 },
{ 30, "VK_KHR_get_memory_requirements2", 1 },
{ 31, "VK_KHR_get_physical_device_properties2", 2 },
{ 32, "VK_KHR_image_format_list", 1 },
{ 33, "VK_KHR_imageless_framebuffer", 1 },
{ 34, "VK_KHR_maintenance1", 2 },
{ 35, "VK_KHR_maintenance2", 1 },
{ 36, "VK_KHR_maintenance3", 1 },
{ 37, "VK_KHR_multiview", 1 },
{ 38, "VK_KHR_relaxed_block_layout", 1 },
{ 39, "VK_KHR_sampler_mirror_clamp_to_edge", 3 },
{ 40, "VK_KHR_sampler_ycbcr_conversion", 14 },
{ 41, "VK_KHR_separate_depth_stencil_layouts", 1 },
{ 42, "VK_KHR_shader_atomic_int64", 1 },
{ 43, "VK_KHR_shader_draw_parameters", 1 },
{ 44, "VK_KHR_shader_float16_int8", 1 },
{ 45, "VK_KHR_shader_float_controls", 4 },
{ 46, "VK_KHR_shader_subgroup_extended_types", 1 },
{ 47, "VK_KHR_spirv_1_4", 1 },
{ 48, "VK_KHR_storage_buffer_storage_class", 1 },
{ 49, "VK_KHR_timeline_semaphore", 2 },
{ 50, "VK_KHR_uniform_buffer_standard_layout", 1 },
{ 51, "VK_KHR_variable_pointers", 1 },
{ 52, "VK_KHR_vulkan_memory_model", 3 },
{ 53, "VK_MESA_venus_protocol", 100000 },
};
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 */

@ -8,9 +8,73 @@
#include <stdarg.h>
#include <stdio.h>
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "vkr_context.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
vkr_log(const char *fmt, ...)
{
@ -47,6 +111,13 @@ vkr_log(const char *fmt, ...)
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
object_array_fini(struct object_array *arr)
{

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

@ -5,7 +5,6 @@
#include "vkr_instance.h"
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "venus-protocol/vn_protocol_renderer_instance.h"
#include "vkr_context.h"
@ -47,7 +46,7 @@ vkr_dispatch_vkEnumerateInstanceExtensionProperties(
for (uint32_t i = 0; i < ARRAY_SIZE(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));

@ -6,7 +6,6 @@
#include "vkr_physical_device.h"
#include "venus-protocol/vn_protocol_renderer_device.h"
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "vrend_winsys_gbm.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"))
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 (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->vk_xml_version = vn_info_vk_xml_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 =
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 */
c->supports_blob_id_0 = (bool)(vkr_renderer_flags & VKR_RENDERER_RENDER_SERVER);
}

Loading…
Cancel
Save