diff options
| author | Tobin Ehlis <tobin@lunarg.com> | 2015-07-06 14:02:36 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-07-17 10:05:18 -0600 |
| commit | d415ac33cf0851d99cf35fb99b87dc297a01df66 (patch) | |
| tree | fd312132ddf0abad54b57fb8dac8194701df5cf1 | |
| parent | 57ac630041f270fdcf0027268a964c41ba6c1124 (diff) | |
| download | usermoji-d415ac33cf0851d99cf35fb99b87dc297a01df66.tar.xz | |
layers: Layer updates to get helpers compiling with type safety changes
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | demos/cube.c | 2 | ||||
| -rw-r--r-- | layers/draw_state.cpp | 1 | ||||
| -rw-r--r-- | layers/vk_layer_table.cpp | 8 | ||||
| -rwxr-xr-x | vk-layer-generate.py | 17 | ||||
| -rwxr-xr-x | vk_helper.py | 11 | ||||
| -rwxr-xr-x | vulkan.py | 181 |
7 files changed, 117 insertions, 105 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 332aeeb7..c5a40758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,6 @@ add_subdirectory(icd) # add_subdirectory(tests) # endif() #endif() -#add_subdirectory(layers) +add_subdirectory(layers) add_subdirectory(demos) #add_subdirectory(tools/glave) diff --git a/demos/cube.c b/demos/cube.c index 0642bbd4..4e48cf50 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -1623,7 +1623,7 @@ static void demo_prepare_framebuffers(struct demo *demo) { VkAttachmentBindInfo attachments[2] = { [0] = { - .view = VK_NULL_HANDLE, + .view.handle = VK_NULL_HANDLE, .layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, }, [1] = { diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index d304331e..cd982220 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -33,7 +33,6 @@ #if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wwrite-strings" #endif -#include "vk_struct_graphviz_helper.h" #if defined(__GNUC__) #pragma GCC diagnostic warning "-Wwrite-strings" #endif diff --git a/layers/vk_layer_table.cpp b/layers/vk_layer_table.cpp index 5fbec8ae..5dca1c75 100644 --- a/layers/vk_layer_table.cpp +++ b/layers/vk_layer_table.cpp @@ -32,7 +32,7 @@ static instance_table_map tableInstanceMap; #define DISPATCH_MAP_DEBUG 0 // Map lookup must be thread safe -VkLayerDispatchTable *device_dispatch_table(VkObject object) +VkLayerDispatchTable *device_dispatch_table(void* object) { dispatch_key key = get_dispatch_key(object); device_table_map::const_iterator it = tableMap.find((void *) key); @@ -40,7 +40,7 @@ VkLayerDispatchTable *device_dispatch_table(VkObject object) return it->second; } -VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) +VkLayerInstanceDispatchTable *instance_dispatch_table(void* object) { dispatch_key key = get_dispatch_key(object); instance_table_map::const_iterator it = tableInstanceMap.find((void *) key); @@ -93,7 +93,7 @@ void destroy_instance_dispatch_table(dispatch_key key) destroy_dispatch_table(tableInstanceMap, key); } -VkLayerDispatchTable *get_dispatch_table(device_table_map &map, VkObject object) +VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void* object) { dispatch_key key = get_dispatch_key(object); device_table_map::const_iterator it = map.find((void *) key); @@ -108,7 +108,7 @@ VkLayerDispatchTable *get_dispatch_table(device_table_map &map, VkObject object) return it->second; } -VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, VkObject object) +VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void* object) { // VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) object; dispatch_key key = get_dispatch_key(object); diff --git a/vk-layer-generate.py b/vk-layer-generate.py index 26b7280f..3e1d1e3b 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -124,6 +124,10 @@ class Subcommand(object): if '*' in vk_type: return ("%lu", "*%s" % name) return ("%lu", name) + if vk_type.strip('*') in vulkan.object_non_dispatch_list: + if '*' in vk_type: + return ("%lu", "%s->handle" % name) + return ("%lu", "%s.handle" % name) if "size" in vk_type: if '*' in vk_type: return ("%zu", "*%s" % name) @@ -226,7 +230,6 @@ class Subcommand(object): ggep_body.append('};') ggep_body.append('') ggep_body.append('%s' % self.lineinfo.get()) - ggep_body.append('') ggep_body.append('VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties(uint32_t *pCount, VkLayerProperties* pProperties)') ggep_body.append('{') @@ -547,6 +550,9 @@ class GenericLayerSubcommand(Subcommand): gen_header.append('') gen_header.append('#include "generic.h"') gen_header.append('') + gen_header.append('%s' % self.lineinfo.get()) + gen_header.append('#define LAYER_EXT_ARRAY_SIZE 1') + gen_header.append('#define LAYER_DEV_EXT_ARRAY_SIZE 1') gen_header.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);') gen_header.append('struct devExts {') gen_header.append(' bool wsi_lunarg_enabled;') @@ -704,6 +710,8 @@ class APIDumpSubcommand(Subcommand): header_txt.append('static loader_platform_thread_mutex printLock;') header_txt.append('') header_txt.append('%s' % self.lineinfo.get()) + header_txt.append('#define LAYER_EXT_ARRAY_SIZE 1') + header_txt.append('#define LAYER_DEV_EXT_ARRAY_SIZE 1') header_txt.append('#define MAX_TID 513') header_txt.append('static loader_platform_thread_id tidMapping[MAX_TID] = {0};') header_txt.append('static uint32_t maxTID = 0;') @@ -882,7 +890,7 @@ class APIDumpSubcommand(Subcommand): log_func_no_addr += ')\\n"' log_func += ';' log_func_no_addr += ';' - log_func += '\n }\n else {%s;\n }' % log_func_no_addr; + log_func += '\n }\n else {%s\n }' % log_func_no_addr; log_func += '\n%s' % self.lineinfo.get() #print("Proto %s has param_dict: %s" % (proto.name, sp_param_dict)) if len(sp_param_dict) > 0: @@ -916,7 +924,10 @@ class APIDumpSubcommand(Subcommand): print_cast = '' print_func = 'string_convert_helper' #cis_print_func = 'tmp_str = string_convert_helper((void*)%s[i], " ");' % proto.params[sp_index].name - cis_print_func = 'tmp_str = %s(%s%s[i], " ");' % (print_func, print_cast, proto.params[sp_index].name) + if proto.params[sp_index].ty.strip('*').replace('const ', '') in vulkan.object_non_dispatch_list: + cis_print_func = 'tmp_str = %s(%s%s[i].handle, " ");' % (print_func, print_cast, proto.params[sp_index].name) + else: + cis_print_func = 'tmp_str = %s(%s%s[i], " ");' % (print_func, print_cast, proto.params[sp_index].name) if not i_decl: log_func += '\n%suint32_t i;' % (indent) i_decl = True diff --git a/vk_helper.py b/vk_helper.py index 430de12b..b52129a7 100755 --- a/vk_helper.py +++ b/vk_helper.py @@ -24,6 +24,7 @@ import argparse import os import sys +import vulkan from source_line_info import sourcelineinfo # vk_helper.py overview @@ -854,8 +855,12 @@ class StructWrapperGen: else: sh_funcs.append('%s' % lineinfo.get()) addr_char = '' - sh_funcs.append('%sss[%u] << %spStruct->%s[i];' % (indent, index, addr_char, stp_list[index]['name'])) - sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "] = " + ss[%u].str() + "\\n";' % (indent, index, stp_list[index]['name'], index)) + if stp_list[index]['type'] in vulkan.core.objects: + sh_funcs.append('%sss[%u] << %spStruct->%s[i].handle;' % (indent, index, addr_char, stp_list[index]['name'])) + sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "].handle = " + ss[%u].str() + "\\n";' % (indent, index, stp_list[index]['name'], index)) + else: + sh_funcs.append('%sss[%u] << %spStruct->%s[i];' % (indent, index, addr_char, stp_list[index]['name'])) + sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "] = " + ss[%u].str() + "\\n";' % (indent, index, stp_list[index]['name'], index)) sh_funcs.append('%s' % lineinfo.get()) sh_funcs.append('%sss[%u].str("");' % (indent, index)) indent = indent[4:] @@ -931,6 +936,8 @@ class StructWrapperGen: (po, pa) = self._get_struct_print_formatted(self.struct_dict[s][m]) if "addr" in po: # or self.struct_dict[s][m]['ptr']: sh_funcs.append(' ss[%u].str("addr");' % (index)) + elif not self.struct_dict[s][m]['ptr'] and self.struct_dict[s][m]['type'] in vulkan.core.objects: + sh_funcs.append(' ss[%u] << pStruct->%s.handle;' % (index, self.struct_dict[s][m]['name'])) else: sh_funcs.append(' ss[%u] << pStruct->%s;' % (index, self.struct_dict[s][m]['name'])) value_print = 'ss[%u].str()' % index @@ -182,37 +182,39 @@ class Extension(object): core = Extension( name="VK_CORE", headers=["vulkan.h", "vk_debug_report_lunarg.h"], - objects=[ "VkInstance", "VkPhysicalDevice", "VkDevice", "VkQueue", + "VkCmdBuffer", + "VkFence", "VkDeviceMemory", "VkBuffer", - "VkBufferView", "VkImage", + "VkSemaphore", + "VkEvent", + "VkQueryPool", + "VkBufferView", "VkImageView", "VkAttachmentView", + "VkShaderModule", "VkShader", + "VkPipelineLayout", "VkPipeline", "VkPipelineCache", "VkSampler", "VkDescriptorSet", "VkDescriptorSetLayout", - "VkPipelineLayout", + "VkSampler", "VkDescriptorPool", + "VkDescriptorSet", "VkDynamicViewportState", "VkDynamicRasterState", "VkDynamicColorBlendState", "VkDynamicDepthStencilState", - "VkCmdBuffer", - "VkFence", - "VkSemaphore", - "VkEvent", - "VkQueryPool", - "VkFramebuffer", "VkRenderPass", + "VkFramebuffer", ], protos=[ Proto("VkResult", "CreateInstance", @@ -227,27 +229,6 @@ core = Extension( Param("uint32_t*", "pPhysicalDeviceCount"), Param("VkPhysicalDevice*", "pPhysicalDevices")]), - Proto("VkResult", "GetPhysicalDeviceProperties", - [Param("VkPhysicalDevice", "gpu"), - Param("VkPhysicalDeviceProperties*", "pProperties")]), - - Proto("VkResult", "GetPhysicalDevicePerformance", - [Param("VkPhysicalDevice", "gpu"), - Param("VkPhysicalDevicePerformance*", "pPerformance")]), - - Proto("VkResult", "GetPhysicalDeviceQueueCount", - [Param("VkPhysicalDevice", "gpu"), - Param("uint32_t*", "pCount")]), - - Proto("VkResult", "GetPhysicalDeviceQueueProperties", - [Param("VkPhysicalDevice", "gpu"), - Param("uint32_t", "count"), - Param("VkPhysicalDeviceQueueProperties*", "pProperties")]), - - Proto("VkResult", "GetPhysicalDeviceMemoryProperties", - [Param("VkPhysicalDevice", "gpu"), - Param("VkPhysicalDeviceMemoryProperties*", "pProperties")]), - Proto("VkResult", "GetPhysicalDeviceFeatures", [Param("VkPhysicalDevice", "physicalDevice"), Param("VkPhysicalDeviceFeatures*", "pFeatures")]), @@ -270,33 +251,53 @@ core = Extension( Param("const char*", "pName")]), Proto("VkResult", "CreateDevice", - [Param("VkPhysicalDevice", "gpu"), + [Param("VkPhysicalDevice", "physicalDevice"), Param("const VkDeviceCreateInfo*", "pCreateInfo"), Param("VkDevice*", "pDevice")]), Proto("VkResult", "DestroyDevice", [Param("VkDevice", "device")]), - Proto("VkResult", "GetPhysicalDeviceExtensionProperties", - [Param("VkPhysicalDevice", "gpu"), - Param("const char*", "pLayerName"), - Param("uint32_t*", "pCount"), - Param("VkExtensionProperties*", "pProperties")]), + Proto("VkResult", "GetPhysicalDeviceProperties", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("VkPhysicalDeviceProperties*", "pProperties")]), - Proto("VkResult", "GetPhysicalDeviceLayerProperties", - [Param("VkPhysicalDevice", "gpu"), - Param("const char*", "pLayerName"), - Param("uint32_t*", "pCount"), - Param("VkLayerProperties*", "pProperties")]), + Proto("VkResult", "GetPhysicalDevicePerformance", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("VkPhysicalDevicePerformance*", "pPerformance")]), + + Proto("VkResult", "GetPhysicalDeviceQueueCount", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("uint32_t*", "pCount")]), + + Proto("VkResult", "GetPhysicalDeviceQueueProperties", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("uint32_t", "count"), + Param("VkPhysicalDeviceQueueProperties*", "pQueueProperties")]), + + Proto("VkResult", "GetPhysicalDeviceMemoryProperties", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("VkPhysicalDeviceMemoryProperties*", "pMemoryProperties")]), Proto("VkResult", "GetGlobalExtensionProperties", [Param("const char*", "pLayerName"), Param("uint32_t*", "pCount"), Param("VkExtensionProperties*", "pProperties")]), + Proto("VkResult", "GetPhysicalDeviceExtensionProperties", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("const char*", "pLayerName"), + Param("uint32_t", "*pCount"), + Param("VkExtensionProperties*", "pProperties")]), + Proto("VkResult", "GetGlobalLayerProperties", [Param("uint32_t*", "pCount"), - Param("VkExtensionProperties*", "pProperties")]), + Param("VkLayerProperties*", "pProperties")]), + + Proto("VkResult", "GetPhysicalDeviceLayerProperties", + [Param("VkPhysicalDevice", "physicalDevice"), + Param("uint32_t", "*pCount"), + Param("VkLayerProperties*", "pProperties")]), Proto("VkResult", "GetDeviceQueue", [Param("VkDevice", "device"), @@ -330,7 +331,7 @@ core = Extension( Param("VkDeviceMemory", "mem"), Param("VkDeviceSize", "offset"), Param("VkDeviceSize", "size"), - Param("VkFlags", "flags"), + Param("VkMemoryMapFlags", "flags"), Param("void**", "ppData")]), Proto("VkResult", "UnmapMemory", @@ -347,33 +348,33 @@ core = Extension( Param("uint32_t", "memRangeCount"), Param("const VkMappedMemoryRange*", "pMemRanges")]), - Proto("VkResult", "GetBufferMemoryRequirements", + Proto("VkResult", "BindBufferMemory", [Param("VkDevice", "device"), Param("VkBuffer", "buffer"), - Param("VkMemoryRequirements*", "pMemoryRequirements")]), + Param("VkDeviceMemory", "mem"), + Param("VkDeviceSize", "memOffset")]), - Proto("VkResult", "GetImageMemoryRequirements", + Proto("VkResult", "BindImageMemory", [Param("VkDevice", "device"), Param("VkImage", "image"), - Param("VkMemoryRequirements*", "pMemoryRequirements")]), + Param("VkDeviceMemory", "mem"), + Param("VkDeviceSize", "memOffset")]), - Proto("VkResult", "BindBufferMemory", + Proto("VkResult", "GetBufferMemoryRequirements", [Param("VkDevice", "device"), Param("VkBuffer", "buffer"), - Param("VkDeviceMemory", "mem"), - Param("VkDeviceSize", "offset")]), + Param("VkMemoryRequirements*", "pMemoryRequirements")]), - Proto("VkResult", "BindImageMemory", + Proto("VkResult", "GetImageMemoryRequirements", [Param("VkDevice", "device"), Param("VkImage", "image"), - Param("VkDeviceMemory", "mem"), - Param("VkDeviceSize", "offset")]), + Param("VkMemoryRequirements*", "pMemoryRequirements")]), Proto("VkResult", "GetImageSparseMemoryRequirements", [Param("VkDevice", "device"), Param("VkImage", "image"), Param("uint32_t*", "pNumRequirements"), - Param("VkSparseImageMemoryRequirements*", "pSparseMemoryRequirements"),]), + Param("VkSparseImageMemoryRequirements*", "pSparseMemoryRequirements")]), Proto("VkResult", "GetPhysicalDeviceSparseImageFormatProperties", [Param("VkPhysicalDevice", "physicalDevice"), @@ -383,25 +384,25 @@ core = Extension( Param("VkImageUsageFlags", "usage"), Param("VkImageTiling", "tiling"), Param("uint32_t*", "pNumProperties"), - Param("VkSparseImageFormatProperties*", "pProperties"),]), + Param("VkSparseImageFormatProperties*", "pProperties")]), Proto("VkResult", "QueueBindSparseBufferMemory", [Param("VkQueue", "queue"), Param("VkBuffer", "buffer"), Param("uint32_t", "numBindings"), - Param("const VkSparseMemoryBindInfo*", "pBindInfo"),]), + Param("const VkSparseMemoryBindInfo*", "pBindInfo")]), Proto("VkResult", "QueueBindSparseImageOpaqueMemory", [Param("VkQueue", "queue"), Param("VkImage", "image"), Param("uint32_t", "numBindings"), - Param("const VkSparseMemoryBindInfo*", "pBindInfo"),]), + Param("const VkSparseMemoryBindInfo*", "pBindInfo")]), Proto("VkResult", "QueueBindSparseImageMemory", [Param("VkQueue", "queue"), Param("VkImage", "image"), Param("uint32_t", "numBindings"), - Param("const VkSparseImageMemoryBindInfo*", "pBindInfo"),]), + Param("const VkSparseImageMemoryBindInfo*", "pBindInfo")]), Proto("VkResult", "CreateFence", [Param("VkDevice", "device"), @@ -696,7 +697,7 @@ core = Extension( Proto("VkResult", "DestroyCommandBuffer", [Param("VkDevice", "device"), - Param("VkCmdBuffer", "cmdBuffer")]), + Param("VkCmdBuffer", "commandBuffer")]), Proto("VkResult", "BeginCommandBuffer", [Param("VkCmdBuffer", "cmdBuffer"), @@ -726,8 +727,8 @@ core = Extension( Param("VkDynamicColorBlendState", "dynamicColorBlendState")]), Proto("void", "CmdBindDynamicDepthStencilState", - [Param("VkCmdBuffer", "cmdBuffer"), - Param("VkDynamicDepthStencilState", "dynamicDepthStencilState")]), + [Param("VkCmdBuffer", "cmdBuffer"), + Param("VkDynamicDepthStencilState", "dynamicDepthStencilState")]), Proto("void", "CmdBindDescriptorSets", [Param("VkCmdBuffer", "cmdBuffer"), @@ -739,6 +740,12 @@ core = Extension( Param("uint32_t", "dynamicOffsetCount"), Param("const uint32_t*", "pDynamicOffsets")]), + Proto("void", "CmdBindIndexBuffer", + [Param("VkCmdBuffer", "cmdBuffer"), + Param("VkBuffer", "buffer"), + Param("VkDeviceSize", "offset"), + Param("VkIndexType", "indexType")]), + Proto("void", "CmdBindVertexBuffers", [Param("VkCmdBuffer", "cmdBuffer"), Param("uint32_t", "startBinding"), @@ -746,12 +753,6 @@ core = Extension( Param("const VkBuffer*", "pBuffers"), Param("const VkDeviceSize*", "pOffsets")]), - Proto("void", "CmdBindIndexBuffer", - [Param("VkCmdBuffer", "cmdBuffer"), - Param("VkBuffer", "buffer"), - Param("VkDeviceSize", "offset"), - Param("VkIndexType", "indexType")]), - Proto("void", "CmdDraw", [Param("VkCmdBuffer", "cmdBuffer"), Param("uint32_t", "firstVertex"), @@ -922,7 +923,7 @@ core = Extension( [Param("VkCmdBuffer", "cmdBuffer"), Param("VkQueryPool", "queryPool"), Param("uint32_t", "slot"), - Param("VkFlags", "flags")]), + Param("VkQueryControlFlags", "flags")]), Proto("void", "CmdEndQuery", [Param("VkCmdBuffer", "cmdBuffer"), @@ -949,7 +950,7 @@ core = Extension( Param("VkBuffer", "destBuffer"), Param("VkDeviceSize", "destOffset"), Param("VkDeviceSize", "destStride"), - Param("VkFlags", "flags")]), + Param("VkQueryResultFlags", "flags")]), Proto("VkResult", "CreateFramebuffer", [Param("VkDevice", "device"), @@ -1026,51 +1027,45 @@ wsi_lunarg = Extension( extensions = [core, wsi_lunarg] -object_root_list = [ +object_dispatch_list = [ "VkInstance", "VkPhysicalDevice", + "VkDevice", + "VkQueue", + "VkCmdBuffer", "VkDisplayWSI", "VkSwapChainWSI", ] -object_base_list = [ - "VkDevice", - "VkQueue", +object_non_dispatch_list = [ + "VkFence", "VkDeviceMemory", -] - -object_list = [ "VkBuffer", - "VkBufferView", "VkImage", + "VkSemaphore", + "VkEvent", + "VkQueryPool", + "VkBufferView", "VkImageView", "VkAttachmentView", + "VkShaderModule", "VkShader", - "VkPipeline", "VkPipelineCache", "VkPipelineLayout", - "VkSampler", - "VkDescriptorSet", + "VkPipeline", "VkDescriptorSetLayout", + "VkSampler", "VkDescriptorPool", - "VkDynamicStateObject", - "VkCmdBuffer", - "VkFence", - "VkSemaphore", - "VkEvent", - "VkQueryPool", - "VkFramebuffer", - "VkRenderPass" -] - -object_dynamic_state_list = [ + "VkDescriptorSet", "VkDynamicViewportState", "VkDynamicRasterState", "VkDynamicColorBlendState", - "VkDynamicDepthStencilState" + "VkDynamicDepthStencilState", + "VkRenderPass", + "VkFramebuffer", ] -object_type_list = object_root_list + object_base_list + object_list + object_dynamic_state_list +object_type_list = object_dispatch_list + object_non_dispatch_list headers = [] objects = [] |
