diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2017-02-14 09:16:56 -0700 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2017-02-14 12:53:41 -0700 |
| commit | 38c29e23e7f40d09d6676a1832c73a1a16195e3b (patch) | |
| tree | 2a1fc4ceaa44167a0770ea0a11a873d3ff4d8e3a /scripts/threading_generator.py | |
| parent | 4227ef7e8c29323600f52b7ee975bab5203bd707 (diff) | |
| download | usermoji-38c29e23e7f40d09d6676a1832c73a1a16195e3b.tar.xz | |
layers: Remove predefined threading object lists
These lists were hard-coded in the generator. Added on-the-fly
detection of handles to reduce maintenance.
Change-Id: I8a897da731d96c2f70f00e479a17c355f03a7486
Diffstat (limited to 'scripts/threading_generator.py')
| -rw-r--r-- | scripts/threading_generator.py | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/scripts/threading_generator.py b/scripts/threading_generator.py index 33857842..553fde94 100644 --- a/scripts/threading_generator.py +++ b/scripts/threading_generator.py @@ -137,44 +137,26 @@ class ThreadOutputGenerator(OutputGenerator): if ((elem.tag is not 'type') and (elem.tail is not None)) and '*' in elem.tail: ispointer = True return ispointer + + # Check if an object is a non-dispatchable handle + def isHandleTypeNonDispatchable(self, handletype): + handle = self.registry.tree.find("types/type/[name='" + handletype + "'][@category='handle']") + if handle is not None and handle.find('type').text == 'VK_DEFINE_NON_DISPATCHABLE_HANDLE': + return True + else: + return False + + # Check if an object is a dispatchable handle + def isHandleTypeDispatchable(self, handletype): + handle = self.registry.tree.find("types/type/[name='" + handletype + "'][@category='handle']") + if handle is not None and handle.find('type').text == 'VK_DEFINE_HANDLE': + return True + else: + return False + def makeThreadUseBlock(self, cmd, functionprefix): """Generate C function pointer typedef for <command> Element""" paramdecl = '' - # TODO: We should generate these lists - thread_check_dispatchable_objects = [ - "VkCommandBuffer", - "VkDevice", - "VkInstance", - "VkQueue", - ] - thread_check_nondispatchable_objects = [ - "VkBuffer", - "VkBufferView", - "VkCommandPool", - "VkDescriptorPool", - "VkDescriptorSetLayout", - "VkDeviceMemory", - "VkEvent", - "VkFence", - "VkFramebuffer", - "VkImage", - "VkImageView", - "VkPipeline", - "VkPipelineCache", - "VkPipelineLayout", - "VkQueryPool", - "VkRenderPass", - "VkSampler", - "VkSemaphore", - "VkShaderModule", - "VkObjectTableNVX", - "VkIndirectCommandsLayoutNVX", - "VkDisplayKHR", - "VkDisplayModeKHR", - "VkSurfaceKHR", - "VkSwapchainKHR", - ] - # Find and add any parameters that are thread unsafe params = cmd.findall('param') for param in params: @@ -222,7 +204,7 @@ class ThreadOutputGenerator(OutputGenerator): paramtype = paramtype.text else: paramtype = 'None' - if paramtype in thread_check_dispatchable_objects or paramtype in thread_check_nondispatchable_objects: + if (self.isHandleTypeDispatchable(paramtype) or self.isHandleTypeNonDispatchable(paramtype)) and paramtype != 'VkPhysicalDevice': if self.paramIsArray(param) and ('pPipelines' != paramname.text): # Add pointer dereference for array counts that are pointer values dereference = '' @@ -230,7 +212,8 @@ class ThreadOutputGenerator(OutputGenerator): if param.attrib.get('len') == candidate.find('name').text: if self.paramIsPointer(candidate): dereference = '*' - paramdecl += ' for (uint32_t index = 0; index < ' + dereference + param.attrib.get('len') + '; index++) {\n' + param_len = str(param.attrib.get('len')).replace("::", "->") + paramdecl += ' for (uint32_t index = 0; index < ' + dereference + param_len + '; index++) {\n' paramdecl += ' ' + functionprefix + 'ReadObject(my_data, ' + paramname.text + '[index]);\n' paramdecl += ' }\n' elif not self.paramIsPointer(param): |
