scripts: Sync up base generator and vulkan object

This commit is contained in:
spencer-lunarg 2025-01-27 10:59:56 -05:00 committed by Charles Giessen
parent 8ec84823af
commit 1ddbe6c40a
2 changed files with 23 additions and 9 deletions

View file

@ -1,8 +1,8 @@
#!/usr/bin/python3 -i
#
# Copyright (c) 2023-2024 Valve Corporation
# Copyright (c) 2023-2024 LunarG, Inc.
# Copyright (c) 2023-2024 RasterGrid Kft.
# Copyright (c) 2023-2025 Valve Corporation
# Copyright (c) 2023-2025 LunarG, Inc.
# Copyright (c) 2023-2025 RasterGrid Kft.
#
# SPDX-License-Identifier: Apache-2.0
@ -26,7 +26,7 @@ vulkanConventions = VulkanConventions()
# Helpers to keep things cleaner
def splitIfGet(elem, name):
return elem.get(name).split(',') if elem.get(name) is not None else None
return elem.get(name).split(',') if elem.get(name) is not None and elem.get(name) != '' else None
def textIfFind(elem, name):
return elem.find(name).text if elem.find(name) is not None else None
@ -86,14 +86,14 @@ def EnableCaching() -> None:
class APISpecific:
# Version object factory method
@staticmethod
def createApiVersion(targetApiName: str, name: str, number: str) -> Version:
def createApiVersion(targetApiName: str, name: str) -> Version:
match targetApiName:
# Vulkan specific API version creation
case 'vulkan':
nameApi = name.replace('VK_', 'VK_API_')
nameString = f'"{name}"'
return Version(name, nameString, nameApi, number)
return Version(name, nameString, nameApi)
# This Generator Option is used across all generators.
@ -295,12 +295,25 @@ class BaseGenerator(OutputGenerator):
for required in dict:
for group in dict[required]:
for structName in dict[required][group]:
isAlias = structName in self.structAliasMap
structName = self.structAliasMap[structName] if isAlias else structName
# An EXT struct can alias a KHR struct,
# that in turns aliaes a core struct
# => Try to propagate aliasing, it can safely result in a no-op
isAlias = structName in self.structAliasMap
structName = self.structAliasMap[structName] if isAlias else structName
if structName in self.vk.structs:
struct = self.vk.structs[structName]
struct.extensions.extend([extension] if extension not in struct.extensions else [])
# While we update struct alias inside other structs, the command itself might have the struct as a first level param.
# We use this time to update params to have the promoted name
# Example - https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/9322
for command in self.vk.commands.values():
for member in command.params:
if member.type in self.structAliasMap:
member.type = self.structAliasMap[member.type]
def endFile(self):
# This is the point were reg.py has ran, everything is collected
# We do some post processing now
@ -382,16 +395,17 @@ class BaseGenerator(OutputGenerator):
obsoletedby = interface.get('obsoletedby')
specialuse = splitIfGet(interface, 'specialuse')
# Not sure if better way to get this info
specVersion = self.featureDictionary[name]['enumconstant'][None][None][0]
nameString = self.featureDictionary[name]['enumconstant'][None][None][1]
self.currentExtension = Extension(name, nameString, instance, device, depends, vendorTag,
self.currentExtension = Extension(name, nameString, specVersion, instance, device, depends, vendorTag,
platform, protect, provisional, promotedto, deprecatedby,
obsoletedby, specialuse)
self.vk.extensions[name] = self.currentExtension
else: # version
number = interface.get('number')
if number != '1.0':
self.currentVersion = APISpecific.createApiVersion(self.targetApiName, name, number)
self.currentVersion = APISpecific.createApiVersion(self.targetApiName, name)
self.vk.versions[name] = self.currentVersion
def endFeature(self):

View file

@ -13,6 +13,7 @@ class Extension:
"""<extension>"""
name: str # ex) VK_KHR_SURFACE
nameString: str # marco with string, ex) VK_KHR_SURFACE_EXTENSION_NAME
specVersion: str # marco with string, ex) VK_KHR_SURFACE_SPEC_VERSION
# Only one will be True, the other is False
instance: bool
@ -47,7 +48,6 @@ class Version:
name: str # ex) VK_VERSION_1_1
nameString: str # ex) "VK_VERSION_1_1" (no marco, so has quotes)
nameApi: str # ex) VK_API_VERSION_1_1
number: str # ex) 1.1
@dataclass
class Handle: