layers: Layer updates to get helpers compiling with type safety changes
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 332aeeb..c5a4075 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,6 @@
# add_subdirectory(tests)
# endif()
#endif()
-#add_subdirectory(layers)
+add_subdirectory(layers)
add_subdirectory(demos)
#add_subdirectory(tools/glave)
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index d304331..cd98222 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 5fbec8a..5dca1c7 100644
--- a/layers/vk_layer_table.cpp
+++ b/layers/vk_layer_table.cpp
@@ -32,7 +32,7 @@
#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 @@
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 @@
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 @@
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 26b7280..3e1d1e3 100755
--- a/vk-layer-generate.py
+++ b/vk-layer-generate.py
@@ -124,6 +124,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 430de12..b52129a 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 @@
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 @@
(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
diff --git a/vulkan.py b/vulkan.py
index dd81631..dbefac9 100755
--- a/vulkan.py
+++ b/vulkan.py
@@ -182,37 +182,39 @@
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 @@
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 @@
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 @@
Param("VkDeviceMemory", "mem"),
Param("VkDeviceSize", "offset"),
Param("VkDeviceSize", "size"),
- Param("VkFlags", "flags"),
+ Param("VkMemoryMapFlags", "flags"),
Param("void**", "ppData")]),
Proto("VkResult", "UnmapMemory",
@@ -347,6 +348,18 @@
Param("uint32_t", "memRangeCount"),
Param("const VkMappedMemoryRange*", "pMemRanges")]),
+ Proto("VkResult", "BindBufferMemory",
+ [Param("VkDevice", "device"),
+ Param("VkBuffer", "buffer"),
+ Param("VkDeviceMemory", "mem"),
+ Param("VkDeviceSize", "memOffset")]),
+
+ Proto("VkResult", "BindImageMemory",
+ [Param("VkDevice", "device"),
+ Param("VkImage", "image"),
+ Param("VkDeviceMemory", "mem"),
+ Param("VkDeviceSize", "memOffset")]),
+
Proto("VkResult", "GetBufferMemoryRequirements",
[Param("VkDevice", "device"),
Param("VkBuffer", "buffer"),
@@ -357,23 +370,11 @@
Param("VkImage", "image"),
Param("VkMemoryRequirements*", "pMemoryRequirements")]),
- Proto("VkResult", "BindBufferMemory",
- [Param("VkDevice", "device"),
- Param("VkBuffer", "buffer"),
- Param("VkDeviceMemory", "mem"),
- Param("VkDeviceSize", "offset")]),
-
- Proto("VkResult", "BindImageMemory",
- [Param("VkDevice", "device"),
- Param("VkImage", "image"),
- Param("VkDeviceMemory", "mem"),
- Param("VkDeviceSize", "offset")]),
-
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 @@
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 @@
Proto("VkResult", "DestroyCommandBuffer",
[Param("VkDevice", "device"),
- Param("VkCmdBuffer", "cmdBuffer")]),
+ Param("VkCmdBuffer", "commandBuffer")]),
Proto("VkResult", "BeginCommandBuffer",
[Param("VkCmdBuffer", "cmdBuffer"),
@@ -726,8 +727,8 @@
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 @@
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 @@
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 @@
[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 @@
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 @@
extensions = [core, wsi_lunarg]
-object_root_list = [
+object_dispatch_list = [
"VkInstance",
"VkPhysicalDevice",
+ "VkDevice",
+ "VkQueue",
+ "VkCmdBuffer",
"VkDisplayWSI",
"VkSwapChainWSI",
]
-object_base_list = [
- "VkDevice",
- "VkQueue",
- "VkDeviceMemory",
-]
-
-object_list = [
- "VkBuffer",
- "VkBufferView",
- "VkImage",
- "VkImageView",
- "VkAttachmentView",
- "VkShader",
- "VkPipeline",
- "VkPipelineCache",
- "VkPipelineLayout",
- "VkSampler",
- "VkDescriptorSet",
- "VkDescriptorSetLayout",
- "VkDescriptorPool",
- "VkDynamicStateObject",
- "VkCmdBuffer",
+object_non_dispatch_list = [
"VkFence",
+ "VkDeviceMemory",
+ "VkBuffer",
+ "VkImage",
"VkSemaphore",
"VkEvent",
"VkQueryPool",
- "VkFramebuffer",
- "VkRenderPass"
-]
-
-object_dynamic_state_list = [
+ "VkBufferView",
+ "VkImageView",
+ "VkAttachmentView",
+ "VkShaderModule",
+ "VkShader",
+ "VkPipelineCache",
+ "VkPipelineLayout",
+ "VkPipeline",
+ "VkDescriptorSetLayout",
+ "VkSampler",
+ "VkDescriptorPool",
+ "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 = []