layers: Layer updates to get helpers compiling with type safety changes

This commit is contained in:
Tobin Ehlis 2015-07-06 14:02:36 -06:00 committed by Courtney Goeltzenleuchter
parent 303615cc9b
commit e944472857
4 changed files with 120 additions and 107 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

197
vulkan.py
View File

@ -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,6 +348,18 @@ core = Extension(
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 @@ core = Extension(
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 @@ 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",
"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 = []