1# Copyright (c) 2022 The Android Open Source Project 2# Copyright (c) 2022 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16from .wrapperdefs import VulkanWrapperGenerator 17 18 19class VulkanExtensionStructureType(VulkanWrapperGenerator): 20 def __init__(self, extensionName: str, module, typeInfo): 21 super().__init__(module, typeInfo) 22 self._extensionName = extensionName 23 24 def onGenGroup(self, groupinfo, groupName, alias=None): 25 super().onGenGroup(groupinfo, groupName, alias) 26 elem = groupinfo.elem 27 if (not elem.get('type') == 'enum'): 28 return 29 if (not elem.get('name') == 'VkStructureType'): 30 return 31 extensionEnumFactoryMacro = f'{self._extensionName.upper()}_ENUM' 32 for enum in elem.findall(f"enum[@extname='{self._extensionName}']"): 33 name = enum.get('name') 34 offset = enum.get('offset') 35 self.module.appendHeader( 36 f"#define {name} {extensionEnumFactoryMacro}(VkStructureType, {offset})\n") 37 38 39class VulkanGfxstreamStructureType(VulkanExtensionStructureType): 40 def __init__(self, module, typeInfo): 41 super().__init__('VK_GOOGLE_gfxstream', module, typeInfo) 42 43 44class VulkanAndroidNativeBufferStructureType(VulkanExtensionStructureType): 45 def __init__(self, module, typeInfo): 46 super().__init__('VK_ANDROID_native_buffer', module, typeInfo) 47