diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2017-10-24 13:41:18 -0600 |
|---|---|---|
| committer | Mike Schuchardt <mikes@lunarg.com> | 2018-03-09 13:54:31 -0700 |
| commit | f895bcc8a6896c5aa278c6549dab241e4eb649ef (patch) | |
| tree | 05f70594c865463bd246d08f12496608b8dc418b /scripts | |
| parent | 1966df8f8754101aa27f7dab90080bffb69f2398 (diff) | |
| download | usermoji-f895bcc8a6896c5aa278c6549dab241e4eb649ef.tar.xz | |
scripts: Update generators for 1.1
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/common_codegen.py | 72 | ||||
| -rw-r--r-- | scripts/dispatch_table_helper_generator.py | 34 | ||||
| -rw-r--r-- | scripts/helper_file_generator.py | 11 | ||||
| -rw-r--r-- | scripts/loader_extension_generator.py | 21 | ||||
| -rw-r--r-- | scripts/lvl_genvk.py | 283 | ||||
| -rw-r--r-- | scripts/mock_icd_generator.py | 19 | ||||
| -rw-r--r-- | scripts/object_tracker_generator.py | 17 | ||||
| -rw-r--r-- | scripts/parameter_validation_generator.py | 20 | ||||
| -rw-r--r-- | scripts/threading_generator.py | 14 | ||||
| -rw-r--r-- | scripts/unique_objects_generator.py | 20 |
10 files changed, 306 insertions, 205 deletions
diff --git a/scripts/common_codegen.py b/scripts/common_codegen.py new file mode 100644 index 00000000..7319c01d --- /dev/null +++ b/scripts/common_codegen.py @@ -0,0 +1,72 @@ +#!/usr/bin/python3 -i +# +# Copyright (c) 2015-2017 The Khronos Group Inc. +# Copyright (c) 2015-2017 Valve Corporation +# Copyright (c) 2015-2017 LunarG, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Author: Mark Lobodzinski <mark@lunarg.com> + +import os,re,sys,string +import xml.etree.ElementTree as etree +from generator import * +from collections import namedtuple +from vuid_mapping import * + +# Copyright text prefixing all headers (list of strings). +prefixStrings = [ + '/*', + '** Copyright (c) 2015-2017 The Khronos Group Inc.', + '** Copyright (c) 2015-2017 Valve Corporation', + '** Copyright (c) 2015-2017 LunarG, Inc.', + '** Copyright (c) 2015-2017 Google Inc.', + '**', + '** Licensed under the Apache License, Version 2.0 (the "License");', + '** you may not use this file except in compliance with the License.', + '** You may obtain a copy of the License at', + '**', + '** http://www.apache.org/licenses/LICENSE-2.0', + '**', + '** Unless required by applicable law or agreed to in writing, software', + '** distributed under the License is distributed on an "AS IS" BASIS,', + '** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.', + '** See the License for the specific language governing permissions and', + '** limitations under the License.', + '*/', + '' +] + + +platform_dict = { + 'android' : 'VK_USE_PLATFORM_ANDROID_KHR', + 'ios' : 'VK_USE_PLATFORM_IOS_MVK', + 'macos' : 'VK_USE_PLATFORM_MACOS_MVK', + 'mir' : 'VK_USE_PLATFORM_MIR_KHR', + 'vi' : 'VK_USE_PLATFORM_VI_NN', + 'wayland' : 'VK_USE_PLATFORM_WAYLAND_KHR', + 'win32' : 'VK_USE_PLATFORM_WIN32_KHR', + 'xcb' : 'VK_USE_PLATFORM_XCB_KHR', + 'xlib' : 'VK_USE_PLATFORM_XLIB_KHR', + 'xlib_randr' : 'VK_USE_PLATFORM_XLIB_RANDR_EXT', +} + +# +# Return appropriate feature protect string from 'platform' tag on feature +def GetFeatureProtect(interface): + """Get platform protection string""" + platform = interface.get('platform') + protect = None + if platform is not None: + protect = platform_dict[platform] + return protect diff --git a/scripts/dispatch_table_helper_generator.py b/scripts/dispatch_table_helper_generator.py index 1801d780..ad8e2b53 100644 --- a/scripts/dispatch_table_helper_generator.py +++ b/scripts/dispatch_table_helper_generator.py @@ -23,6 +23,7 @@ import os,re,sys import xml.etree.ElementTree as etree from generator import * from collections import namedtuple +from common_codegen import * # # DispatchTableHelperOutputGeneratorOptions - subclass of GeneratorOptions. @@ -37,31 +38,24 @@ class DispatchTableHelperOutputGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, - protectFile = True, - protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', - alignFuncParam = 0): + alignFuncParam = 0, + expandEnumerants = True): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText self.genFuncPointers = genFuncPointers self.prefixText = None - self.protectFile = protectFile - self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp - self.alignFuncParam = alignFuncParam # # DispatchTableHelperOutputGenerator - subclass of OutputGenerator. # Generates dispatch table helper header files for LVL @@ -79,14 +73,7 @@ class DispatchTableHelperOutputGenerator(OutputGenerator): # Called once at the beginning of each run def beginFile(self, genOpts): OutputGenerator.beginFile(self, genOpts) - # Protect against multiple inclusions - self.protect_header = False - if (genOpts.protectFile and genOpts.filename): - self.protect_header = True - headerSym = '__' + re.sub('\.h', '_h_', os.path.basename(genOpts.filename)) - write('#ifndef', headerSym, file=self.outFile) - write('#define', headerSym, '1', file=self.outFile) - self.newline() + write("#pragma once", file=self.outFile) # User-supplied prefix text, if any (list of strings) if (genOpts.prefixText): for s in genOpts.prefixText: @@ -138,12 +125,15 @@ class DispatchTableHelperOutputGenerator(OutputGenerator): write("\n", file=self.outFile) write(instance_table, file=self.outFile); - if self.protect_header: - self.newline() - write('#endif', file=self.outFile) # Finish processing in superclass OutputGenerator.endFile(self) # + # Processing at beginning of each feature or extension + def beginFeature(self, interface, emit): + OutputGenerator.beginFeature(self, interface, emit) + self.featureExtraProtect = GetFeatureProtect(interface) + + # # Process commands, adding to appropriate dispatch tables def genCmd(self, cmdinfo, name): OutputGenerator.genCmd(self, cmdinfo, name) diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py index 6f2ea4b6..c3b0085f 100644 --- a/scripts/helper_file_generator.py +++ b/scripts/helper_file_generator.py @@ -24,6 +24,7 @@ import os,re,sys import xml.etree.ElementTree as etree from generator import * from collections import namedtuple +from common_codegen import * # # HelperFileOutputGeneratorOptions - subclass of GeneratorOptions. @@ -38,28 +39,26 @@ class HelperFileOutputGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, protectFile = True, protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', alignFuncParam = 0, library_name = '', + expandEnumerants = True, helper_file_type = ''): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText self.genFuncPointers = genFuncPointers self.protectFile = protectFile self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp @@ -159,6 +158,8 @@ class HelperFileOutputGenerator(OutputGenerator): def beginFeature(self, interface, emit): # Start processing in superclass OutputGenerator.beginFeature(self, interface, emit) + self.featureExtraProtect = GetFeatureProtect(interface) + if self.featureName == 'VK_VERSION_1_0' or self.featureName == 'VK_VERSION_1_1': return nameElem = interface[0][1] diff --git a/scripts/loader_extension_generator.py b/scripts/loader_extension_generator.py index 5c92e35b..1a95927f 100644 --- a/scripts/loader_extension_generator.py +++ b/scripts/loader_extension_generator.py @@ -18,11 +18,14 @@ # limitations under the License. # # Author: Mark Young <marky@lunarg.com> +# Author: Mark Lobodzinski <mark@lunarg.com> import os,re,sys import xml.etree.ElementTree as etree from generator import * from collections import namedtuple +from common_codegen import * + WSI_EXT_NAMES = ['VK_KHR_surface', 'VK_KHR_display', @@ -62,33 +65,30 @@ class LoaderExtensionGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, protectFile = True, protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', + indentFuncProto = True, + indentFuncPointer = False, alignFuncParam = 0, - currentExtension = '', - extensionOfInterest = 0): + expandEnumerants = True): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText - self.genFuncPointers = genFuncPointers self.prefixText = None - self.protectFile = protectFile - self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp self.alignFuncParam = alignFuncParam + self.expandEnumerants = expandEnumerants + # # LoaderExtensionOutputGenerator - subclass of OutputGenerator. # Generates dispatch table helper header files for LVL @@ -208,6 +208,7 @@ class LoaderExtensionOutputGenerator(OutputGenerator): def beginFeature(self, interface, emit): # Start processing in superclass OutputGenerator.beginFeature(self, interface, emit) + self.featureExtraProtect = GetFeatureProtect(interface) enums = interface[0].findall('enum') self.currentExtension = '' diff --git a/scripts/lvl_genvk.py b/scripts/lvl_genvk.py index a4347c1e..8c62432b 100644 --- a/scripts/lvl_genvk.py +++ b/scripts/lvl_genvk.py @@ -43,39 +43,52 @@ def endTimer(timeit, msg): startTime = None # Turn a list of strings into a regexp string matching exactly those strings -def makeREstring(list): - return '^(' + '|'.join(list) + ')$' +def makeREstring(list, default = None): + if len(list) > 0 or default == None: + return '^(' + '|'.join(list) + ')$' + else: + return default # Returns a directory of [ generator function, generator options ] indexed # by specified short names. The generator options incorporate the following # parameters: # -# features - list of <feature> names to include; defaults to all features -# extensions - list of <extension> names to include. -# protect - True if re-inclusion protection should be added to headers -# directory - path to directory in which to generate the target(s) -def makeGenOpts(features = [], - extensions = [], - removeExtensions = [], - protect = True, - directory = '.'): +# args is an parsed argument object; see below for the fields that are used. +def makeGenOpts(args): global genOpts genOpts = {} + # Default class of extensions to include, or None + defaultExtensions = args.defaultExtensions + + # Additional extensions to include (list of extensions) + extensions = args.extension + + # Extensions to remove (list of extensions) + removeExtensions = args.removeExtensions + + # Extensions to emit (list of extensions) + emitExtensions = args.emitExtensions + + # Features to include (list of features) + features = args.feature + + # Whether to disable inclusion protect in headers + protect = args.protect + + # Output target directory + directory = args.directory + # Descriptive names for various regexp patterns used to select # versions and extensions allFeatures = allExtensions = '.*' - noVersions = noExtensions = None + noFeatures = noExtensions = None - addExtensions = makeREstring(extensions) - removeExtensions = makeREstring(removeExtensions) - - if len(features) > 0: - features = makeREstring(features) - else: - features = allFeatures - - # write('* Selecting features: ', features, file=sys.stderr) + # Turn lists of names/patterns into matching regular expressions + addExtensionsPat = makeREstring(extensions, None) + removeExtensionsPat = makeREstring(removeExtensions, None) + emitExtensionsPat = makeREstring(emitExtensions, allExtensions) + featuresPat = makeREstring(features, allFeatures) # Copyright text prefixing all headers (list of strings). prefixStrings = [ @@ -107,12 +120,8 @@ def makeGenOpts(features = [], ] # Defaults for generating re-inclusion protection wrappers (or not) - protectFile = protect protectFeature = protect - protectProto = protect - - # # LoaderAndValidationLayer Generators # Options for threading layer genOpts['thread_check.h'] = [ @@ -122,17 +131,19 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Options for parameter validation layer @@ -143,18 +154,19 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) - ] + alignFuncParam = 48, + expandEnumerants = False) + ] # Options for unique objects layer genOpts['unique_objects_wrappers.h'] = [ @@ -164,17 +176,19 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Options for object_tracker layer @@ -185,17 +199,19 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Options for dispatch table helper generator @@ -206,17 +222,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Options for Layer dispatch table generator @@ -227,17 +244,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Options for loader extension source generator @@ -248,17 +266,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Options for loader extension source generator @@ -269,17 +288,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + expandEnumerants = False) ] # Helper file generator options for vk_enum_string_helper.h @@ -290,17 +310,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'enum_string_header') ] @@ -312,17 +333,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'struct_size_header') ] @@ -334,17 +356,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'struct_size_source') ] @@ -356,17 +379,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'safe_struct_header') ] @@ -378,17 +402,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'safe_struct_source') ] @@ -400,17 +425,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'object_types_header') ] @@ -422,17 +448,18 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = features, - emitversions = features, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, - protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'extension_helper_header') ] @@ -468,17 +495,19 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = allVersions, - emitversions = allVersions, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'mock_icd_header') ] @@ -490,17 +519,19 @@ def makeGenOpts(features = [], directory = directory, apiname = 'vulkan', profile = None, - versions = allVersions, - emitversions = allVersions, + versions = featuresPat, + emitversions = featuresPat, defaultExtensions = 'vulkan', - addExtensions = addExtensions, - removeExtensions = removeExtensions, + addExtensions = addExtensionsPat, + removeExtensions = removeExtensionsPat, + emitExtensions = emitExtensionsPat, prefixText = prefixStrings + vkPrefixStrings, protectFeature = False, apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', alignFuncParam = 48, + expandEnumerants = False, helper_file_type = 'mock_icd_source') ] @@ -517,11 +548,7 @@ def genTarget(args): global genOpts # Create generator options with specified parameters - makeGenOpts(features = args.feature, - extensions = args.extension, - removeExtensions = args.removeExtension, - protect = args.protect, - directory = args.directory) + makeGenOpts(args) if (args.target in genOpts.keys()): createGenerator = genOpts[args.target][0] @@ -529,6 +556,12 @@ def genTarget(args): if not args.quiet: write('* Building', options.filename, file=sys.stderr) + write('* options.versions =', options.versions, file=sys.stderr) + write('* options.emitversions =', options.emitversions, file=sys.stderr) + write('* options.defaultExtensions =', options.defaultExtensions, file=sys.stderr) + write('* options.addExtensions =', options.addExtensions, file=sys.stderr) + write('* options.removeExtensions =', options.removeExtensions, file=sys.stderr) + write('* options.emitExtensions =', options.emitExtensions, file=sys.stderr) startTimer(args.time) gen = createGenerator(errFile=errWarn, @@ -551,15 +584,21 @@ def genTarget(args): if __name__ == '__main__': parser = argparse.ArgumentParser() + parser.add_argument('-defaultExtensions', action='store', + default='vulkan', + help='Specify a single class of extensions to add to targets') parser.add_argument('-extension', action='append', default=[], help='Specify an extension or extensions to add to targets') + parser.add_argument('-removeExtensions', action='append', + default=[], + help='Specify an extension or extensions to remove from targets') + parser.add_argument('-emitExtensions', action='append', + default=[], + help='Specify an extension or extensions to emit in targets') parser.add_argument('-feature', action='append', default=[], help='Specify a core API feature name or names to add to targets') - parser.add_argument('-removeExtension', action='append', - default=[], - help='Specify an extension or extensions to remove from targets') parser.add_argument('-debug', action='store_true', help='Enable debugging') parser.add_argument('-dump', action='store_true', diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py index b1d5e581..ccbaf151 100644 --- a/scripts/mock_icd_generator.py +++ b/scripts/mock_icd_generator.py @@ -26,6 +26,8 @@ import os,re,sys from generator import * +from common_codegen import * + # Mock header code HEADER_C_CODE = ''' @@ -349,21 +351,21 @@ EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( } #endif /* VK_USE_PLATFORM_WIN32_KHR */ -EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHX( +EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR( VkDevice device, VkSurfaceKHR surface, - VkDeviceGroupPresentModeFlagsKHX* pModes) + VkDeviceGroupPresentModeFlagsKHR* pModes) { - return vkmock::GetDeviceGroupSurfacePresentModesKHX(device, surface, pModes); + return vkmock::GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes); } -EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHX( +EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, VkRect2D* pRects) { - return vkmock::GetPhysicalDevicePresentRectanglesKHX(physicalDevice, surface, pRectCount, pRects); + return vkmock::GetPhysicalDevicePresentRectanglesKHR(physicalDevice, surface, pRectCount, pRects); } #ifdef VK_USE_PLATFORM_VI_NN @@ -713,6 +715,7 @@ class MockICDGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, @@ -726,10 +729,11 @@ class MockICDGeneratorOptions(GeneratorOptions): indentFuncProto = True, indentFuncPointer = False, alignFuncParam = 0, + expandEnumerants = True, helper_file_type = ''): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText self.genFuncPointers = genFuncPointers self.protectFile = protectFile @@ -842,7 +846,7 @@ class MockICDOutputGenerator(OutputGenerator): # Ignore extensions that ICDs should not implement or are not safe to report ignore_exts = ['VK_EXT_validation_cache', 'VK_KHR_push_descriptor'] for ext in self.registry.tree.findall("extensions/extension"): - if '0' != ext[0][0].attrib['value']: # Only include implemented extensions + if ext.attrib['supported'] != 'disabled': # Only include enabled extensions if (ext.attrib['name'] in ignore_exts): pass elif (ext.attrib.get('type') and 'instance' == ext.attrib['type']): @@ -884,6 +888,7 @@ class MockICDOutputGenerator(OutputGenerator): #write('// starting beginFeature', file=self.outFile) # Start processing in superclass OutputGenerator.beginFeature(self, interface, emit) + self.featureExtraProtect = GetFeatureProtect(interface) # C-specific # Accumulate includes, defines, types, enums, function pointer typedefs, # end function prototypes separately for this feature. They're only diff --git a/scripts/object_tracker_generator.py b/scripts/object_tracker_generator.py index dafc00ca..c2217a70 100644 --- a/scripts/object_tracker_generator.py +++ b/scripts/object_tracker_generator.py @@ -24,6 +24,7 @@ import xml.etree.ElementTree as etree from generator import * from collections import namedtuple from vuid_mapping import * +from common_codegen import * # This is a workaround to use a Python 2.7 and 3.x compatible syntax. from io import open @@ -72,34 +73,34 @@ class ObjectTrackerGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, protectFile = True, protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', indentFuncProto = True, indentFuncPointer = False, - alignFuncParam = 0): + alignFuncParam = 0, + expandEnumerants = True): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText self.genFuncPointers = genFuncPointers self.protectFile = protectFile self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp self.indentFuncProto = indentFuncProto self.indentFuncPointer = indentFuncPointer self.alignFuncParam = alignFuncParam + self.expandEnumerants = expandEnumerants + # ObjectTrackerOutputGenerator - subclass of OutputGenerator. # Generates object_tracker layer object validation code @@ -396,9 +397,6 @@ class ObjectTrackerOutputGenerator(OutputGenerator): write('#ifdef', self.featureExtraProtect, file=self.outFile) # Write the object_tracker code to the file if (self.sections['command']): - if (self.genOpts.protectProto): - write(self.genOpts.protectProto, - self.genOpts.protectProtoStr, file=self.outFile) write('\n'.join(self.sections['command']), end=u'', file=self.outFile) if (self.featureExtraProtect != None): write('\n#endif //', self.featureExtraProtect, file=self.outFile) @@ -420,6 +418,7 @@ class ObjectTrackerOutputGenerator(OutputGenerator): # Start processing in superclass OutputGenerator.beginFeature(self, interface, emit) self.headerVersion = None + self.featureExtraProtect = GetFeatureProtect(interface) if self.featureName != 'VK_VERSION_1_0' and self.featureName != 'VK_VERSION_1_1': white_list_entry = [] diff --git a/scripts/parameter_validation_generator.py b/scripts/parameter_validation_generator.py index a6dc0972..d4cfb44f 100644 --- a/scripts/parameter_validation_generator.py +++ b/scripts/parameter_validation_generator.py @@ -25,6 +25,7 @@ import xml.etree.ElementTree as etree from generator import * from collections import namedtuple from vuid_mapping import * +from common_codegen import * # This is a workaround to use a Python 2.7 and 3.x compatible syntax. from io import open @@ -72,34 +73,27 @@ class ParameterValidationGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", - genFuncPointers = True, - protectFile = True, - protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', indentFuncProto = True, indentFuncPointer = False, - alignFuncParam = 0): + alignFuncParam = 0, + expandEnumerants = True): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText - self.genFuncPointers = genFuncPointers - self.protectFile = protectFile - self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp self.indentFuncProto = indentFuncProto self.indentFuncPointer = indentFuncPointer self.alignFuncParam = alignFuncParam + self.expandEnumerants = expandEnumerants # ParameterValidationOutputGenerator - subclass of OutputGenerator. # Generates param checker layer code. @@ -353,7 +347,7 @@ class ParameterValidationOutputGenerator(OutputGenerator): self.commands = [] self.structMembers = [] self.newFlags = set() - + self.featureExtraProtect = GetFeatureProtect(interface) # Get base list of extension dependencies for all items in this extension base_required_extensions = [] if "VK_VERSION_1" not in self.featureName: diff --git a/scripts/threading_generator.py b/scripts/threading_generator.py index 174b0115..fd88909c 100644 --- a/scripts/threading_generator.py +++ b/scripts/threading_generator.py @@ -22,6 +22,7 @@ import os,re,sys from generator import * +from common_codegen import * # ThreadGeneratorOptions - subclass of GeneratorOptions. # @@ -67,34 +68,34 @@ class ThreadGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, protectFile = True, protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', indentFuncProto = True, indentFuncPointer = False, - alignFuncParam = 0): + alignFuncParam = 0, + expandEnumerants = True): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText self.genFuncPointers = genFuncPointers self.protectFile = protectFile self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp self.indentFuncProto = indentFuncProto self.indentFuncPointer = indentFuncPointer self.alignFuncParam = alignFuncParam + self.expandEnumerants = expandEnumerants + # ThreadOutputGenerator - subclass of OutputGenerator. # Generates Thread checking framework @@ -291,6 +292,7 @@ class ThreadOutputGenerator(OutputGenerator): # Accumulate includes, defines, types, enums, function pointer typedefs, # end function prototypes separately for this feature. They're only # printed in endFeature(). + self.featureExtraProtect = GetFeatureProtect(interface) self.sections = dict([(section, []) for section in self.ALL_SECTIONS]) #write('// ending beginFeature', file=self.outFile) def endFeature(self): diff --git a/scripts/unique_objects_generator.py b/scripts/unique_objects_generator.py index 4d509942..c80696a4 100644 --- a/scripts/unique_objects_generator.py +++ b/scripts/unique_objects_generator.py @@ -24,6 +24,7 @@ import os,re,sys import xml.etree.ElementTree as etree from generator import * from collections import namedtuple +from common_codegen import * # UniqueObjectsGeneratorOptions - subclass of GeneratorOptions. # @@ -69,34 +70,34 @@ class UniqueObjectsGeneratorOptions(GeneratorOptions): defaultExtensions = None, addExtensions = None, removeExtensions = None, + emitExtensions = None, sortProcedure = regSortFeatures, prefixText = "", genFuncPointers = True, protectFile = True, protectFeature = True, - protectProto = None, - protectProtoStr = None, apicall = '', apientry = '', apientryp = '', indentFuncProto = True, indentFuncPointer = False, - alignFuncParam = 0): + alignFuncParam = 0, + expandEnumerants = True): GeneratorOptions.__init__(self, filename, directory, apiname, profile, versions, emitversions, defaultExtensions, - addExtensions, removeExtensions, sortProcedure) + addExtensions, removeExtensions, emitExtensions, sortProcedure) self.prefixText = prefixText self.genFuncPointers = genFuncPointers self.protectFile = protectFile self.protectFeature = protectFeature - self.protectProto = protectProto - self.protectProtoStr = protectProtoStr self.apicall = apicall self.apientry = apientry self.apientryp = apientryp self.indentFuncProto = indentFuncProto self.indentFuncPointer = indentFuncPointer - self.alignFuncParam = alignFuncParam + self.alignFuncParam = alignFuncParam + self.expandEnumerants = expandEnumerants + # UniqueObjectsOutputGenerator - subclass of OutputGenerator. # Generates unique objects layer non-dispatchable handle-wrapping code. @@ -237,9 +238,6 @@ class UniqueObjectsOutputGenerator(OutputGenerator): write('#ifdef', self.featureExtraProtect, file=self.outFile) # Write the unique_objects code to the file if (self.sections['command']): - if (self.genOpts.protectProto): - write(self.genOpts.protectProto, - self.genOpts.protectProtoStr, file=self.outFile) write('\n'.join(self.sections['command']), end=u'', file=self.outFile) if (self.featureExtraProtect != None): write('\n#endif //', self.featureExtraProtect, file=self.outFile) @@ -260,7 +258,7 @@ class UniqueObjectsOutputGenerator(OutputGenerator): # Start processing in superclass OutputGenerator.beginFeature(self, interface, emit) self.headerVersion = None - + self.featureExtraProtect = GetFeatureProtect(interface) if self.featureName != 'VK_VERSION_1_0' and self.featureName != 'VK_VERSION_1_1': white_list_entry = [] if (self.featureExtraProtect != None): |
