Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: Add struct extension re-lookup in base generator #180

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions scripts/generators/base_generator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python3 -i
#
# Copyright 2023 The Khronos Group Inc.
# Copyright 2023 Valve Corporation
# Copyright 2023 LunarG, Inc.
# Copyright 2023 RasterGrid Kft.
# Copyright 2023-2024 The Khronos Group Inc.
# Copyright 2023-2024 Valve Corporation
# Copyright 2023-2024 LunarG, Inc.
# Copyright 2023-2024 RasterGrid Kft.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -134,6 +134,7 @@ def __init__(self):
self.enumFieldAliasMap = dict()
self.bitmaskAliasMap = dict()
self.flagAliasMap = dict()
self.structAliasMap = dict()

def write(self, data):
# Prevents having to check before writting
Expand Down Expand Up @@ -282,6 +283,18 @@ def applyExtensionDependency(self):
extension.flags[bitmaskName] = [] # Dict needs init
extension.flags[bitmaskName].extend([flag] if flag not in extension.flags[bitmaskName] else [])

# Some structs (ex VkAttachmentSampleCountInfoAMD) can have multiple alias pointing to same extension
for extension in self.vk.extensions.values():
dict = self.featureDictionary[extension.name]['struct']
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
if structName in self.vk.structs:
struct = self.vk.structs[structName]
struct.extensions.extend([extension] if extension not in struct.extensions else [])

def endFile(self):
# This is the point were reg.py has ran, everything is collected
# We do some post processing now
Expand Down Expand Up @@ -511,10 +524,7 @@ def genType(self, typeInfo, typeName, alias):
if (category == 'struct' or category == 'union'):
extension = [self.currentExtension] if self.currentExtension is not None else []
if alias is not None:
struct = self.vk.structs[alias]
# Some structs (ex VkAttachmentSampleCountInfoAMD) can have multiple alias pointing to same extension
struct.extensions += extension if extension and extension[0] not in struct.extensions else []
struct.version = self.currentVersion if struct.version is None else struct.version
self.structAliasMap[typeName] = alias
return

union = category == 'union'
Expand Down