mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
vulkan: fix building with python3.8
Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8640 Reviewed-by: Ricardo Garcia <rgarcia@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21958>
This commit is contained in:
parent
5082b6b034
commit
46c9e84ead
1 changed files with 13 additions and 6 deletions
|
|
@ -24,6 +24,7 @@ COPYRIGHT=u"""
|
|||
|
||||
import argparse
|
||||
from collections import OrderedDict
|
||||
from dataclasses import dataclass
|
||||
import os
|
||||
import sys
|
||||
import typing
|
||||
|
|
@ -33,6 +34,11 @@ import mako
|
|||
from mako.template import Template
|
||||
from vk_extensions import get_all_required, filter_api
|
||||
|
||||
def str_removeprefix(s, prefix):
|
||||
if s.startswith(prefix):
|
||||
return s[len(prefix):]
|
||||
return s
|
||||
|
||||
RENAMED_FEATURES = {
|
||||
# See https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17272#note_1446477 for details
|
||||
('BufferDeviceAddressFeaturesEXT', 'bufferDeviceAddressCaptureReplay'): 'bufferDeviceAddressCaptureReplayEXT',
|
||||
|
|
@ -111,12 +117,13 @@ for (feature_structs, features) in KNOWN_ALIASES:
|
|||
RENAMED_FEATURES[rename] = flag
|
||||
|
||||
def get_renamed_feature(c_type, feature):
|
||||
return RENAMED_FEATURES.get((c_type.removeprefix('VkPhysicalDevice'), feature), feature)
|
||||
return RENAMED_FEATURES.get((str_removeprefix(c_type, 'VkPhysicalDevice'), feature), feature)
|
||||
|
||||
class FeatureStruct(typing.NamedTuple):
|
||||
@dataclass
|
||||
class FeatureStruct:
|
||||
c_type: str
|
||||
s_type: str
|
||||
features: list[str]
|
||||
features: typing.List[str]
|
||||
|
||||
TEMPLATE_C = Template(COPYRIGHT + """
|
||||
/* This file generated from ${filename}, don't edit directly. */
|
||||
|
|
@ -407,12 +414,12 @@ def get_feature_structs_from_xml(xml_files, api='vulkan'):
|
|||
if renamed_flag not in features:
|
||||
features[renamed_flag] = f.c_type
|
||||
else:
|
||||
a = features[renamed_flag].removeprefix('VkPhysicalDevice')
|
||||
b = f.c_type.removeprefix('VkPhysicalDevice')
|
||||
a = str_removeprefix(features[renamed_flag], 'VkPhysicalDevice')
|
||||
b = str_removeprefix(f.c_type, 'VkPhysicalDevice')
|
||||
if (a, flag) not in RENAMED_FEATURES or (b, flag) not in RENAMED_FEATURES:
|
||||
diagnostics.append(f'{a} and {b} both define {flag}')
|
||||
|
||||
unused_renames.pop((f.c_type.removeprefix('VkPhysicalDevice'), flag), None)
|
||||
unused_renames.pop((str_removeprefix(f.c_type, 'VkPhysicalDevice'), flag), None)
|
||||
|
||||
for rename in unused_renames:
|
||||
diagnostics.append(f'unused rename {rename}')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue