Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d84eae5 authored by Chris Forbes's avatar Chris Forbes Committed by Tom Murphy
Browse files

Unbitrot libvulkan's code generator

The generator py scripts were broken when VKSC was released. Fix them
and submit the updated autogenerated code.

Bug: b/346650750
Flag: EXEMPT bugfix
Test: ran the script after fixes
Change-Id: I44352b052e5d018b91b327f1c8b3763146ed8fbe
parent 6557491c
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ bool InitDispatchTable(
    INIT_PROC(false, instance, GetPhysicalDeviceExternalSemaphoreProperties);
    INIT_PROC(false, instance, GetPhysicalDeviceExternalFenceProperties);
    INIT_PROC(false, instance, EnumeratePhysicalDeviceGroups);
    INIT_PROC_EXT(KHR_swapchain, false, instance, GetPhysicalDevicePresentRectanglesKHR);
    INIT_PROC_EXT(KHR_swapchain, true, instance, GetPhysicalDevicePresentRectanglesKHR);
    INIT_PROC(false, instance, GetPhysicalDeviceToolProperties);
    // clang-format on

@@ -325,9 +325,9 @@ bool InitDispatchTable(
    INIT_PROC(false, dev, BindBufferMemory2);
    INIT_PROC(false, dev, BindImageMemory2);
    INIT_PROC(false, dev, CmdSetDeviceMask);
    INIT_PROC_EXT(KHR_swapchain, false, dev, GetDeviceGroupPresentCapabilitiesKHR);
    INIT_PROC_EXT(KHR_swapchain, false, dev, GetDeviceGroupSurfacePresentModesKHR);
    INIT_PROC_EXT(KHR_swapchain, false, dev, AcquireNextImage2KHR);
    INIT_PROC_EXT(KHR_swapchain, true, dev, GetDeviceGroupPresentCapabilitiesKHR);
    INIT_PROC_EXT(KHR_swapchain, true, dev, GetDeviceGroupSurfacePresentModesKHR);
    INIT_PROC_EXT(KHR_swapchain, true, dev, AcquireNextImage2KHR);
    INIT_PROC(false, dev, CmdDispatchBase);
    INIT_PROC(false, dev, CreateDescriptorUpdateTemplate);
    INIT_PROC(false, dev, DestroyDescriptorUpdateTemplate);
@@ -659,6 +659,8 @@ VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* pNa
        "vkGetDrmDisplayEXT",
        "vkGetInstanceProcAddr",
        "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT",
        "vkGetPhysicalDeviceCalibrateableTimeDomainsKHR",
        "vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR",
        "vkGetPhysicalDeviceDisplayPlaneProperties2KHR",
        "vkGetPhysicalDeviceDisplayProperties2KHR",
        "vkGetPhysicalDeviceExternalBufferProperties",
@@ -703,6 +705,7 @@ VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* pNa
        "vkGetPhysicalDeviceToolProperties",
        "vkGetPhysicalDeviceToolPropertiesEXT",
        "vkGetPhysicalDeviceVideoCapabilitiesKHR",
        "vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR",
        "vkGetPhysicalDeviceVideoFormatPropertiesKHR",
        "vkSubmitDebugUtilsMessageEXT",
    };
+55 −34
Original line number Diff line number Diff line
@@ -351,9 +351,50 @@ def parse_vulkan_registry():
                          'external', 'vulkan-headers', 'registry', 'vk.xml')
  tree = element_tree.parse(registry)
  root = tree.getroot()

  for exts in root.iter('extensions'):
    for extension in exts.iter('extension'):
      if 'vulkan' not in extension.get('supported').split(','):
        # ANDROID_native_buffer is a weird special case -- it's declared in vk.xml as
        # disabled but we _do_ want to generate plumbing for it in the Android loader.
        if extension.get('name') != 'VK_ANDROID_native_buffer':
          print('skip extension disabled or not for vulkan: ' + extension.get('name'))
          continue

      apiversion = 'VK_VERSION_1_0'
      if extension.tag == 'extension':
        extname = extension.get('name')
        if (extension.get('type') == 'instance' and
            extension.get('promotedto') is not None):
          promoted_inst_ext_dict[extname] = \
              version_2_api_version(extension.get('promotedto'))
        for req in extension.iter('require'):
          if req.get('feature') is not None:
            apiversion = req.get('feature')
          for commands in req:
            if commands.tag == 'command':
              cmd_name = commands.get('name')
              if cmd_name not in extension_dict:
                extension_dict[cmd_name] = extname
                version_dict[cmd_name] = apiversion

  for feature in root.iter('feature'):
    if 'vulkan' not in feature.get('api').split(','):
      continue

    apiversion = feature.get('name')
    for req in feature.iter('require'):
      for command in req:
        if command.tag == 'command':
          cmd_name = command.get('name')
          version_dict[cmd_name] = apiversion

  for commands in root.iter('commands'):
    for command in commands:
      if command.tag == 'command':
        if command.get('api') == 'vulkansc':
          continue

        parameter_list = []
        protoset = False
        cmd_name = ''
@@ -361,12 +402,18 @@ def parse_vulkan_registry():
        if command.get('alias') is not None:
          alias = command.get('alias')
          cmd_name = command.get('name')
          # At this stage all valid commands have been added to the version
          # dict so we can use it to filter valid commands
          if cmd_name in version_dict:
            alias_dict[cmd_name] = alias
            command_list.append(cmd_name)
            param_dict[cmd_name] = param_dict[alias].copy()
            return_type_dict[cmd_name] = return_type_dict[alias]
        for params in command:
          if params.tag == 'param':
            if params.get('api') == 'vulkansc':
              # skip SC-only param variant
              continue
            param_type = ''
            if params.text is not None and params.text.strip():
              param_type = params.text.strip() + ' '
@@ -387,39 +434,13 @@ def parse_vulkan_registry():
                cmd_type = c.text
              if c.tag == 'name':
                cmd_name = c.text
                if cmd_name in version_dict:
                  protoset = True
                  command_list.append(cmd_name)
                  return_type_dict[cmd_name] = cmd_type
        if protoset:
          param_dict[cmd_name] = parameter_list.copy()

  for exts in root.iter('extensions'):
    for extension in exts:
      apiversion = 'VK_VERSION_1_0'
      if extension.tag == 'extension':
        extname = extension.get('name')
        if (extension.get('type') == 'instance' and
            extension.get('promotedto') is not None):
          promoted_inst_ext_dict[extname] = \
              version_2_api_version(extension.get('promotedto'))
        for req in extension:
          if req.get('feature') is not None:
            apiversion = req.get('feature')
          for commands in req:
            if commands.tag == 'command':
              cmd_name = commands.get('name')
              if cmd_name not in extension_dict:
                extension_dict[cmd_name] = extname
                version_dict[cmd_name] = apiversion

  for feature in root.iter('feature'):
    apiversion = feature.get('name')
    for req in feature:
      for command in req:
        if command.tag == 'command':
          cmd_name = command.get('name')
          if cmd_name in command_list:
            version_dict[cmd_name] = apiversion

  version_code_set = set()
  for version in version_dict.values():
+2 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ def gen_cpp():
    f.write(gencom.copyright_and_warning(2015))

    f.write("""\
#include <android/hardware_buffer.h>

#include <algorithm>

#include "null_driver_gen.h"