From c1887f0dbf99c2773f76e54d704cb3247017608f Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Tue, 7 Nov 2023 11:55:13 -0700 Subject: [PATCH] gfxstream: genvk: add support for vk_gfxstream.xml Custom XML file specific to gfxstream. Reviewed-by: Aaron Ruby Acked-by: Yonggang Luo Acked-by: Adam Jackson Part-of: --- src/gfxstream/codegen/scripts/genvk.py | 95 +++++- src/gfxstream/codegen/xml/vk_gfxstream.xml | 322 +++++++++++++++++++++ 2 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 src/gfxstream/codegen/xml/vk_gfxstream.xml diff --git a/src/gfxstream/codegen/scripts/genvk.py b/src/gfxstream/codegen/scripts/genvk.py index 5a617cc17e8..dd6b93bcbab 100755 --- a/src/gfxstream/codegen/scripts/genvk.py +++ b/src/gfxstream/codegen/scripts/genvk.py @@ -45,7 +45,7 @@ from cerealgenerator import CerealGenerator # Simple timer functions startTime = None - +from typing import Optional def startTimer(timeit): global startTime @@ -979,6 +979,44 @@ def makeGenOpts(args): alignFuncParam = 48) ] + gfxstreamPrefixStrings = [ + '#pragma once', + '#ifdef VK_GFXSTREAM_STRUCTURE_TYPE_EXT', + '#include "vulkan_gfxstream_structure_type.h"', + '#endif', + ] + + # gfxstream specific header + genOpts['vulkan_gfxstream.h'] = [ + COutputGenerator, + CGeneratorOptions( + conventions = conventions, + filename = 'vulkan_gfxstream.h', + directory = directory, + genpath = None, + apiname = 'vulkan', + profile = None, + versions = featuresPat, + emitversions = None, + defaultExtensions = None, + addExtensions = makeREstring(['VK_GOOGLE_gfxstream'], None), + removeExtensions = None, + emitExtensions = makeREstring(['VK_GOOGLE_gfxstream'], None), + prefixText = prefixStrings + vkPrefixStrings + gfxstreamPrefixStrings, + genFuncPointers = True, + # Use #pragma once in the prefixText instead, so that we can put the copyright comments + # at the beginning of the file. + protectFile = False, + protectFeature = False, + protectProto = '#ifndef', + protectProtoStr = 'VK_NO_PROTOTYPES', + apicall = 'VKAPI_ATTR ', + apientry = 'VKAPI_CALL ', + apientryp = 'VKAPI_PTR *', + alignFuncParam = 48, + misracstyle = misracstyle, + misracppstyle = misracppstyle) + ] def genTarget(args): """Create an API generator and corresponding generator options based on @@ -1071,6 +1109,9 @@ if __name__ == '__main__': parser.add_argument('-registry', action='store', default='vk.xml', help='Use specified registry file instead of vk.xml') + parser.add_argument('-registryGfxstream', action='store', + default=None, + help='Use specified gfxstream registry file') parser.add_argument('-time', action='store_true', help='Enable timing') parser.add_argument('-genpath', action='store', default='gen', @@ -1126,6 +1167,58 @@ if __name__ == '__main__': tree = etree.parse(args.registry) endTimer(args.time, '* Time to make ElementTree =') + # Merge the gfxstream registry with the official Vulkan registry if the + # target is the cereal generator + if args.registryGfxstream is not None and args.target == 'cereal': + treeGfxstream = etree.parse(args.registryGfxstream) + treeRoot = tree.getroot() + treeGfxstreamRoot = treeGfxstream.getroot() + + def getEntryName(entry) -> Optional[str]: + name = entry.get("name") + if name is not None: + return name + try: + return entry.find("proto").find("name") + except AttributeError: + return None + + for entriesName in ['types', 'commands', 'extensions']: + treeEntries = treeRoot.find(entriesName) + + originalEntryDict = {} + for entry in treeEntries: + name = getEntryName(entry) + if name is not None: + originalEntryDict[name] = entry + + for entry in treeGfxstreamRoot.find(entriesName): + name = getEntryName(entry) + # New entry, just append to entry list + if name not in originalEntryDict.keys(): + treeEntries.append(entry) + continue + + originalEntry = originalEntryDict[name] + + # Extending an existing entry. This happens for MVK. + if entriesName == "extensions": + for key, value in entry.attrib.items(): + originalEntry.set(key, value) + require = entry.find("require") + if require is not None: + for child in require: + originalEntry.find("require").append(child) + continue + + # Overwriting an existing entry. This happen for + # VkNativeBufferANDROID + if entriesName == "types": + originalEntry.clear() + originalEntry.attrib = entry.attrib + for child in entry: + originalEntry.append(child) + # Load the XML tree into the registry object startTimer(args.time) reg.loadElementTree(tree) diff --git a/src/gfxstream/codegen/xml/vk_gfxstream.xml b/src/gfxstream/codegen/xml/vk_gfxstream.xml new file mode 100644 index 00000000000..cc2515b099e --- /dev/null +++ b/src/gfxstream/codegen/xml/vk_gfxstream.xml @@ -0,0 +1,322 @@ + + + +Copyright (C) 2023 The Android Open Source Project + +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. + + + +This file, vk_gfxstream.xml, is the Vulkan API Registry for gfxstream +specific entries. + + + + + VkStructureType sType + const void* pNext + const uint32_t* handle + int stride + int format + int usage + VkNativeBufferUsage2ANDROID usage2 + + + VkStructureType sType + void* pNext + uint32_t colorBuffer + + + VkStructureType sType + void* pNext + uint32_t buffer + + + VkStructureType sType + void* pNext + uint32_t blobMem + uint32_t blobFlags + uint64_t blobId + + + + + + VkResult vkMapMemoryIntoAddressSpaceGOOGLE + VkDevice device + VkDeviceMemory memory + uint64_t* pAddress + + + void vkUpdateDescriptorSetWithTemplateSizedGOOGLE + VkDevice device + VkDescriptorSet descriptorSet + VkDescriptorUpdateTemplate descriptorUpdateTemplate + uint32_t imageInfoCount + uint32_t bufferInfoCount + uint32_t bufferViewCount + const uint32_t* pImageInfoEntryIndices + const uint32_t* pBufferInfoEntryIndices + const uint32_t* pBufferViewEntryIndices + const VkDescriptorImageInfo* pImageInfos + const VkDescriptorBufferInfo* pBufferInfos + const VkBufferView* pBufferViews + + + void vkUpdateDescriptorSetWithTemplateSized2GOOGLE + VkDevice device + VkDescriptorSet descriptorSet + VkDescriptorUpdateTemplate descriptorUpdateTemplate + uint32_t imageInfoCount + uint32_t bufferInfoCount + uint32_t bufferViewCount + uint32_t inlineUniformBlockCount + const uint32_t* pImageInfoEntryIndices + const uint32_t* pBufferInfoEntryIndices + const uint32_t* pBufferViewEntryIndices + const VkDescriptorImageInfo* pImageInfos + const VkDescriptorBufferInfo* pBufferInfos + const VkBufferView* pBufferViews + const uint8_t* pInlineUniformBlockData + + + void vkBeginCommandBufferAsyncGOOGLE + VkCommandBuffer commandBuffer + const VkCommandBufferBeginInfo* pBeginInfo + + the sname:VkCommandPool that pname:commandBuffer was allocated from + + + + void vkEndCommandBufferAsyncGOOGLE + VkCommandBuffer commandBuffer + + the sname:VkCommandPool that pname:commandBuffer was allocated from + + + + void vkResetCommandBufferAsyncGOOGLE + VkCommandBuffer commandBuffer + VkCommandBufferResetFlags flags + + + void vkCommandBufferHostSyncGOOGLE + VkCommandBuffer commandBuffer + uint32_t needHostSync + uint32_t sequenceNumber + + + VkResult vkCreateImageWithRequirementsGOOGLE + VkDevice device + const VkImageCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkImage* pImage + VkMemoryRequirements* pMemoryRequirements + + + VkResult vkCreateBufferWithRequirementsGOOGLE + VkDevice device + const VkBufferCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkBuffer* pBuffer + VkMemoryRequirements* pMemoryRequirements + + + VkResult vkGetMemoryHostAddressInfoGOOGLE + VkDevice device + VkDeviceMemory memory + uint64_t* pAddress + uint64_t* pSize + uint64_t* pHostmemId + + + VkResult vkFreeMemorySyncGOOGLE + VkDevice device + VkDeviceMemory memory + const VkAllocationCallbacks* pAllocator + + + void vkQueueHostSyncGOOGLE + VkQueue queue + uint32_t needHostSync + uint32_t sequenceNumber + + + void vkQueueSubmitAsyncGOOGLE + VkQueue queue + uint32_t submitCount + const VkSubmitInfo* pSubmits + VkFence fence + + + void vkQueueSubmitAsync2GOOGLE + VkQueue queue + uint32_t submitCount + const VkSubmitInfo2* pSubmits + VkFence fence + + + void vkQueueWaitIdleAsyncGOOGLE + VkQueue queue + + + void vkQueueBindSparseAsyncGOOGLE + VkQueue queue + uint32_t bindInfoCount + const VkBindSparseInfo* pBindInfo + VkFence fence + + + void vkGetLinearImageLayoutGOOGLE + VkDevice device + VkFormat format + VkDeviceSize* pOffset + VkDeviceSize* pRowPitchAlignment + + + void vkGetLinearImageLayout2GOOGLE + VkDevice device + const VkImageCreateInfo* pCreateInfo + VkDeviceSize* pOffset + VkDeviceSize* pRowPitchAlignment + + + void vkQueueFlushCommandsGOOGLE + VkQueue queue + VkCommandBuffer commandBuffer + VkDeviceSize dataSize + const void* pData + + + VkResult vkGetBlobGOOGLE + VkDevice device + VkDeviceMemory memory + + + void vkQueueCommitDescriptorSetUpdatesGOOGLE + VkQueue queue + uint32_t descriptorPoolCount + const VkDescriptorPool* pDescriptorPools + uint32_t descriptorSetCount + const VkDescriptorSetLayout* pSetLayouts + const uint64_t* pDescriptorSetPoolIds + const uint32_t* pDescriptorSetWhichPool + const uint32_t* pDescriptorSetPendingAllocation + const uint32_t* pDescriptorWriteStartingIndices + uint32_t pendingDescriptorWriteCount + const VkWriteDescriptorSet* pPendingDescriptorWrites + + + void vkCollectDescriptorPoolIdsGOOGLE + VkDevice device + VkDescriptorPool descriptorPool + uint32_t* pPoolIdCount + uint64_t* pPoolIds + + + void vkQueueSignalReleaseImageANDROIDAsyncGOOGLE + VkQueue queue + uint32_t waitSemaphoreCount + const VkSemaphore* pWaitSemaphores + VkImage image + + + void vkQueueFlushCommandsFromAuxMemoryGOOGLE + VkQueue queue + VkCommandBuffer commandBuffer + VkDeviceMemory deviceMemory + VkDeviceSize dataOffset + VkDeviceSize dataSize + + + void vkGetMTLDeviceMVK + VkPhysicalDevice physicalDevice + void** pMTLDevice + + + VkResult vkSetMTLTextureMVK + VkImage image + void* mtlTexture + + + void vkGetMTLTextureMVK + VkImage image + void** pMTLTexture + + + void vkGetMTLBufferMVK + VkBuffer buffer + void** pMTLBuffer + + + VkResult vkUseIOSurfaceMVK + VkImage image + void* ioSurface + + + void vkGetIOSurfaceMVK + VkImage image + void** pIOSurface + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file