zink/codegen: validate has_properties and has_features

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9021>
This commit is contained in:
Hoe Hao Cheng 2021-02-12 03:35:32 +08:00 committed by Marge Bot
parent 613132c41f
commit 4751135e57
2 changed files with 22 additions and 3 deletions

View file

@ -141,7 +141,6 @@ VERSIONS = [
# This is basically generated_code.replace(key, value).
REPLACEMENTS = {
"ROBUSTNESS2": "ROBUSTNESS_2",
"PropertiesProperties": "Properties",
"PROPERTIES_PROPERTIES": "PROPERTIES",
}
@ -210,10 +209,10 @@ struct zink_device_info {
%for ext in extensions:
<%helpers:guard ext="${ext}">
%if ext.has_features:
VkPhysicalDevice${ext.name_in_camel_case()}Features${ext.vendor()} ${ext.field("feats")};
${ext.physical_device_struct("Features")} ${ext.field("feats")};
%endif
%if ext.has_properties:
VkPhysicalDevice${ext.name_in_camel_case()}Properties${ext.vendor()} ${ext.field("props")};
${ext.physical_device_struct("Properties")} ${ext.field("props")};
%endif
</%helpers:guard>
%endfor
@ -424,6 +423,17 @@ if __name__ == "__main__":
print("The extension {} is {} extension - expected a device extension.".format(ext.name, entry.ext_type))
continue
if ext.has_features:
if not (entry.features_struct and ext.physical_device_struct("Features") == entry.features_struct):
error_count += 1
print("The extension {} does not provide a features struct.".format(ext.name))
if ext.has_properties:
if not (entry.properties_struct and ext.physical_device_struct("Properties") == entry.properties_struct):
error_count += 1
print("The extension {} does not provide a properties struct.".format(ext.name))
print(entry.properties_struct, ext.physical_device_struct("Properties"))
if entry.promoted_in:
ext.core_since = Version((*entry.promoted_in, 0))

View file

@ -119,6 +119,15 @@ class Extension:
def field(self, suffix: str):
return self.alias + '_' + suffix
def physical_device_struct(self, struct: str):
if self.name_in_camel_case().endswith(struct):
struct = ""
return ("VkPhysicalDevice"
+ self.name_in_camel_case()
+ struct
+ self.vendor())
# the sType of the extension's struct
# e.g. VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT
# for VK_EXT_transform_feedback and struct="FEATURES"