aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2019-08-08 13:25:07 -0600
committerMark Lobodzinski <mark@lunarg.com>2019-08-08 17:16:02 -0600
commitdb8affe556111c2aa1817b770d2b5db263542b4b (patch)
treebbcf860870a614c080645c9aaa2adba3345dffa1 /scripts
parent1d70bce9928309e19470d63df63cf9a361505a85 (diff)
downloadvulkan-validation-layers-db8affe556111c2aa1817b770d2b5db263542b4b.tar.gz
scripts: Add LoaderStructs to safe pnext handlers
Deep pNext chain copies require that the secret loader init structs are handled properly. These are inserted at the beginning of the CreateInstance and CreateDevice pNext chains. Added support to the pNext copy/free routines for these structs not defined in the vulkan header. Change-Id: Id8df6fabe39ef0a49922c5e12fddb801476e89f5
Diffstat (limited to 'scripts')
-rw-r--r--scripts/helper_file_generator.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py
index 8a02bb229..cbf279d3d 100644
--- a/scripts/helper_file_generator.py
+++ b/scripts/helper_file_generator.py
@@ -452,6 +452,7 @@ class HelperFileOutputGenerator(OutputGenerator):
safe_struct_helper_header = '\n'
safe_struct_helper_header += '#pragma once\n'
safe_struct_helper_header += '#include <vulkan/vulkan.h>\n'
+ safe_struct_helper_header += '#include <vulkan/vk_layer.h>\n'
safe_struct_helper_header += '\n'
safe_struct_helper_header += 'void *SafePnextCopy(const void *pNext);\n'
safe_struct_helper_header += 'void FreePnextChain(const void *head);\n'
@@ -900,19 +901,43 @@ class HelperFileOutputGenerator(OutputGenerator):
build_pnext_proc += ' return nullptr;\n'
build_pnext_proc += ' } else {\n'
build_pnext_proc += ' VkBaseOutStructure *header = reinterpret_cast<VkBaseOutStructure *>(cur_pnext);\n\n'
- build_pnext_proc += ' switch (header->sType) {\n'
+ build_pnext_proc += ' switch (header->sType) {\n\n'
+ # Add special-case code to copy beloved secret loader structs
+ build_pnext_proc += ' // Special-case Loader Instance Struct passed to/from layer in pNext chain\n'
+ build_pnext_proc += ' case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO: {\n'
+ build_pnext_proc += ' VkLayerInstanceCreateInfo *safe_struct = new VkLayerInstanceCreateInfo;\n'
+ build_pnext_proc += ' memcpy((void *)safe_struct, (void *)cur_pnext, sizeof(VkLayerInstanceCreateInfo));\n'
+ build_pnext_proc += ' safe_struct->pNext = SafePnextCopy(safe_struct->pNext);\n'
+ build_pnext_proc += ' cur_ext_struct = reinterpret_cast<void *>(safe_struct);\n'
+ build_pnext_proc += ' } break;\n\n'
+ build_pnext_proc += ' // Special-case Loader Device Struct passed to/from layer in pNext chain\n'
+ build_pnext_proc += ' case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO: {\n'
+ build_pnext_proc += ' VkLayerDeviceCreateInfo *safe_struct = new VkLayerDeviceCreateInfo;\n'
+ build_pnext_proc += ' memcpy((void *)safe_struct, (void *)cur_pnext, sizeof(VkLayerDeviceCreateInfo));\n'
+ build_pnext_proc += ' safe_struct->pNext = SafePnextCopy(safe_struct->pNext);\n'
+ build_pnext_proc += ' cur_ext_struct = reinterpret_cast<void *>(safe_struct);\n'
+ build_pnext_proc += ' } break;\n\n'
free_pnext_proc = '\n\n'
free_pnext_proc += '// Free a const pNext extension chain\n'
free_pnext_proc += 'void FreePnextChain(const void *head) {\n'
free_pnext_proc += ' FreePnextChain(const_cast<void *>(head));\n'
free_pnext_proc += '}\n\n'
-
free_pnext_proc += '// Free a pNext extension chain\n'
free_pnext_proc += 'void FreePnextChain(void *head) {\n'
free_pnext_proc += ' if (nullptr == head) return;\n'
free_pnext_proc += ' VkBaseOutStructure *header = reinterpret_cast<VkBaseOutStructure *>(head);\n\n'
- free_pnext_proc += ' switch (header->sType) {\n';
+ free_pnext_proc += ' switch (header->sType) {\n\n'
+ free_pnext_proc += ' // Special-case Loader Instance Struct passed to/from layer in pNext chain\n'
+ free_pnext_proc += ' case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO: {\n'
+ free_pnext_proc += ' if (header->pNext) FreePnextChain(header->pNext);\n'
+ free_pnext_proc += ' delete reinterpret_cast<VkLayerInstanceCreateInfo *>(head);\n'
+ free_pnext_proc += ' } break;\n\n'
+ free_pnext_proc += ' // Special-case Loader Device Struct passed to/from layer in pNext chain\n'
+ free_pnext_proc += ' case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO: {\n'
+ free_pnext_proc += ' if (header->pNext) FreePnextChain(header->pNext);\n'
+ free_pnext_proc += ' delete reinterpret_cast<VkLayerDeviceCreateInfo *>(head);\n'
+ free_pnext_proc += ' } break;\n\n'
for item in self.structextends_list: