aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPetr Kraus <petr_kraus@email.cz>2017-12-14 20:57:36 +0100
committerTobin Ehlis <tobine@google.com>2017-12-15 12:35:29 -0700
commit7f36ca0776f1d8d801fc85bb87a23ff440db5dd3 (patch)
tree4a62b28649278ef5024bca7cfd4149fdae247dac /scripts
parentacfe0d1a7d6dd1bcc7df02f4bb491d42e7abbdde (diff)
downloadusermoji-7f36ca0776f1d8d801fc85bb87a23ff440db5dd3.tar.xz
layers: Fix Graphics Pipeline pointers not ignored
Some VkGraphicsPipelineCreateInfo pointers must be ignored under some conditions, but were not in the layers. Add relevant tests. Fix tests found broken (using depth or color without attachment in subpass)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/helper_file_generator.py254
-rw-r--r--scripts/parameter_validation_generator.py2
-rw-r--r--scripts/unique_objects_generator.py2
3 files changed, 210 insertions, 48 deletions
diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py
index 4b1ddc61..1e59d0a4 100644
--- a/scripts/helper_file_generator.py
+++ b/scripts/helper_file_generator.py
@@ -93,6 +93,15 @@ class HelperFileOutputGenerator(OutputGenerator):
self.StructType = namedtuple('StructType', ['name', 'value'])
self.CommandParam = namedtuple('CommandParam', ['type', 'name', 'ispointer', 'isstaticarray', 'isconst', 'iscount', 'len', 'extstructs', 'cdecl'])
self.StructMemberData = namedtuple('StructMemberData', ['name', 'members', 'ifdef_protect'])
+
+ self.custom_construct_params = {
+ # safe_VkGraphicsPipelineCreateInfo needs to know if subpass has color and\or depth\stencil attachments to use its pointers
+ 'VkGraphicsPipelineCreateInfo' :
+ ', const bool uses_color_attachment, const bool uses_depthstencil_attachment',
+ # safe_VkPipelineViewportStateCreateInfo needs to know if viewport and scissor is dynamic to use its pointers
+ 'VkPipelineViewportStateCreateInfo' :
+ ', const bool is_dynamic_viewports, const bool is_dynamic_scissors',
+ }
#
# Called once at the beginning of each run
def beginFile(self, genOpts):
@@ -580,13 +589,13 @@ class HelperFileOutputGenerator(OutputGenerator):
safe_struct_header += ' %s* %s;\n' % (member.type, member.name)
else:
safe_struct_header += '%s;\n' % member.cdecl
- safe_struct_header += ' safe_%s(const %s* in_struct);\n' % (item.name, item.name)
+ safe_struct_header += ' safe_%s(const %s* in_struct%s);\n' % (item.name, item.name, self.custom_construct_params.get(item.name, ''))
safe_struct_header += ' safe_%s(const safe_%s& src);\n' % (item.name, item.name)
safe_struct_header += ' safe_%s& operator=(const safe_%s& src);\n' % (item.name, item.name)
safe_struct_header += ' safe_%s();\n' % item.name
safe_struct_header += ' ~safe_%s();\n' % item.name
- safe_struct_header += ' void initialize(const %s* in_struct);\n' % item.name
- safe_struct_header += ' void initialize(const safe_%s* src);\n' % item.name
+ safe_struct_header += ' void initialize(const %s* in_struct%s);\n' % (item.name, self.custom_construct_params.get(item.name, ''))
+ safe_struct_header += ' void initialize(const safe_%s* src);\n' % (item.name)
safe_struct_header += ' %s *ptr() { return reinterpret_cast<%s *>(this); }\n' % (item.name, item.name)
safe_struct_header += ' %s const *ptr() const { return reinterpret_cast<%s const *>(this); }\n' % (item.name, item.name)
safe_struct_header += '};\n'
@@ -768,49 +777,196 @@ class HelperFileOutputGenerator(OutputGenerator):
init_func_txt = '' # Txt for initialize() function that takes struct ptr and inits members
construct_txt = '' # Body of constuctor as well as body of initialize() func following init_func_txt
destruct_txt = ''
- # VkWriteDescriptorSet is special case because pointers may be non-null but ignored
- custom_construct_txt = {'VkWriteDescriptorSet' :
- ' switch (descriptorType) {\n'
- ' case VK_DESCRIPTOR_TYPE_SAMPLER:\n'
- ' case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:\n'
- ' case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:\n'
- ' case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:\n'
- ' case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:\n'
- ' if (descriptorCount && in_struct->pImageInfo) {\n'
- ' pImageInfo = new VkDescriptorImageInfo[descriptorCount];\n'
- ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
- ' pImageInfo[i] = in_struct->pImageInfo[i];\n'
- ' }\n'
- ' }\n'
- ' break;\n'
- ' case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:\n'
- ' case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:\n'
- ' case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:\n'
- ' case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:\n'
- ' if (descriptorCount && in_struct->pBufferInfo) {\n'
- ' pBufferInfo = new VkDescriptorBufferInfo[descriptorCount];\n'
- ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
- ' pBufferInfo[i] = in_struct->pBufferInfo[i];\n'
- ' }\n'
- ' }\n'
- ' break;\n'
- ' case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:\n'
- ' case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:\n'
- ' if (descriptorCount && in_struct->pTexelBufferView) {\n'
- ' pTexelBufferView = new VkBufferView[descriptorCount];\n'
- ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
- ' pTexelBufferView[i] = in_struct->pTexelBufferView[i];\n'
- ' }\n'
- ' }\n'
- ' break;\n'
- ' default:\n'
- ' break;\n'
- ' }\n',
- 'VkShaderModuleCreateInfo' :
- ' if (in_struct->pCode) {\n'
- ' pCode = reinterpret_cast<uint32_t *>(new uint8_t[codeSize]);\n'
- ' memcpy((void *)pCode, (void *)in_struct->pCode, codeSize);\n'
- ' }\n'}
+
+ custom_construct_txt = {
+ # VkWriteDescriptorSet is special case because pointers may be non-null but ignored
+ 'VkWriteDescriptorSet' :
+ ' switch (descriptorType) {\n'
+ ' case VK_DESCRIPTOR_TYPE_SAMPLER:\n'
+ ' case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:\n'
+ ' case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:\n'
+ ' case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:\n'
+ ' case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:\n'
+ ' if (descriptorCount && in_struct->pImageInfo) {\n'
+ ' pImageInfo = new VkDescriptorImageInfo[descriptorCount];\n'
+ ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
+ ' pImageInfo[i] = in_struct->pImageInfo[i];\n'
+ ' }\n'
+ ' }\n'
+ ' break;\n'
+ ' case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:\n'
+ ' case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:\n'
+ ' case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:\n'
+ ' case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:\n'
+ ' if (descriptorCount && in_struct->pBufferInfo) {\n'
+ ' pBufferInfo = new VkDescriptorBufferInfo[descriptorCount];\n'
+ ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
+ ' pBufferInfo[i] = in_struct->pBufferInfo[i];\n'
+ ' }\n'
+ ' }\n'
+ ' break;\n'
+ ' case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:\n'
+ ' case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:\n'
+ ' if (descriptorCount && in_struct->pTexelBufferView) {\n'
+ ' pTexelBufferView = new VkBufferView[descriptorCount];\n'
+ ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
+ ' pTexelBufferView[i] = in_struct->pTexelBufferView[i];\n'
+ ' }\n'
+ ' }\n'
+ ' break;\n'
+ ' default:\n'
+ ' break;\n'
+ ' }\n',
+ 'VkShaderModuleCreateInfo' :
+ ' if (in_struct->pCode) {\n'
+ ' pCode = reinterpret_cast<uint32_t *>(new uint8_t[codeSize]);\n'
+ ' memcpy((void *)pCode, (void *)in_struct->pCode, codeSize);\n'
+ ' }\n',
+ # VkGraphicsPipelineCreateInfo is special case because its pointers may be non-null but ignored
+ 'VkGraphicsPipelineCreateInfo' :
+ ' if (stageCount && in_struct->pStages) {\n'
+ ' pStages = new safe_VkPipelineShaderStageCreateInfo[stageCount];\n'
+ ' for (uint32_t i=0; i<stageCount; ++i) {\n'
+ ' pStages[i].initialize(&in_struct->pStages[i]);\n'
+ ' }\n'
+ ' }\n'
+ ' if (in_struct->pVertexInputState)\n'
+ ' pVertexInputState = new safe_VkPipelineVertexInputStateCreateInfo(in_struct->pVertexInputState);\n'
+ ' else\n'
+ ' pVertexInputState = NULL;\n'
+ ' if (in_struct->pInputAssemblyState)\n'
+ ' pInputAssemblyState = new safe_VkPipelineInputAssemblyStateCreateInfo(in_struct->pInputAssemblyState);\n'
+ ' else\n'
+ ' pInputAssemblyState = NULL;\n'
+ ' bool has_tessellation_stage = false;\n'
+ ' if (stageCount && pStages)\n'
+ ' for (uint32_t i=0; i<stageCount && !has_tessellation_stage; ++i)\n'
+ ' if (pStages[i].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT || pStages[i].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT)\n'
+ ' has_tessellation_stage = true;\n'
+ ' if (in_struct->pTessellationState && has_tessellation_stage)\n'
+ ' pTessellationState = new safe_VkPipelineTessellationStateCreateInfo(in_struct->pTessellationState);\n'
+ ' else\n'
+ ' pTessellationState = NULL; // original pTessellationState pointer ignored\n'
+ ' bool has_rasterization = in_struct->pRasterizationState ? !in_struct->pRasterizationState->rasterizerDiscardEnable : false;\n'
+ ' if (in_struct->pViewportState && has_rasterization) {\n'
+ ' bool is_dynamic_viewports = false;\n'
+ ' bool is_dynamic_scissors = false;\n'
+ ' if (in_struct->pDynamicState && in_struct->pDynamicState->pDynamicStates) {\n'
+ ' for (uint32_t i = 0; i < in_struct->pDynamicState->dynamicStateCount && !is_dynamic_viewports; ++i)\n'
+ ' if (in_struct->pDynamicState->pDynamicStates[i] == VK_DYNAMIC_STATE_VIEWPORT)\n'
+ ' is_dynamic_viewports = true;\n'
+ ' for (uint32_t i = 0; i < in_struct->pDynamicState->dynamicStateCount && !is_dynamic_scissors; ++i)\n'
+ ' if (in_struct->pDynamicState->pDynamicStates[i] == VK_DYNAMIC_STATE_SCISSOR)\n'
+ ' is_dynamic_scissors = true;\n'
+ ' }\n'
+ ' pViewportState = new safe_VkPipelineViewportStateCreateInfo(in_struct->pViewportState, is_dynamic_viewports, is_dynamic_scissors);\n'
+ ' } else\n'
+ ' pViewportState = NULL; // original pViewportState pointer ignored\n'
+ ' if (in_struct->pRasterizationState)\n'
+ ' pRasterizationState = new safe_VkPipelineRasterizationStateCreateInfo(in_struct->pRasterizationState);\n'
+ ' else\n'
+ ' pRasterizationState = NULL;\n'
+ ' if (in_struct->pMultisampleState && has_rasterization)\n'
+ ' pMultisampleState = new safe_VkPipelineMultisampleStateCreateInfo(in_struct->pMultisampleState);\n'
+ ' else\n'
+ ' pMultisampleState = NULL; // original pMultisampleState pointer ignored\n'
+ ' // needs a tracked subpass state uses_depthstencil_attachment\n'
+ ' if (in_struct->pDepthStencilState && has_rasterization && uses_depthstencil_attachment)\n'
+ ' pDepthStencilState = new safe_VkPipelineDepthStencilStateCreateInfo(in_struct->pDepthStencilState);\n'
+ ' else\n'
+ ' pDepthStencilState = NULL; // original pDepthStencilState pointer ignored\n'
+ ' // needs a tracked subpass state usesColorAttachment\n'
+ ' if (in_struct->pColorBlendState && has_rasterization && uses_color_attachment)\n'
+ ' pColorBlendState = new safe_VkPipelineColorBlendStateCreateInfo(in_struct->pColorBlendState);\n'
+ ' else\n'
+ ' pColorBlendState = NULL; // original pColorBlendState pointer ignored\n'
+ ' if (in_struct->pDynamicState)\n'
+ ' pDynamicState = new safe_VkPipelineDynamicStateCreateInfo(in_struct->pDynamicState);\n'
+ ' else\n'
+ ' pDynamicState = NULL;\n',
+ # VkPipelineViewportStateCreateInfo is special case because its pointers may be non-null but ignored
+ 'VkPipelineViewportStateCreateInfo' :
+ ' if (in_struct->pViewports && !is_dynamic_viewports) {\n'
+ ' pViewports = new VkViewport[in_struct->viewportCount];\n'
+ ' memcpy ((void *)pViewports, (void *)in_struct->pViewports, sizeof(VkViewport)*in_struct->viewportCount);\n'
+ ' }\n'
+ ' else\n'
+ ' pViewports = NULL;\n'
+ ' if (in_struct->pScissors && !is_dynamic_scissors) {\n'
+ ' pScissors = new VkRect2D[in_struct->scissorCount];\n'
+ ' memcpy ((void *)pScissors, (void *)in_struct->pScissors, sizeof(VkRect2D)*in_struct->scissorCount);\n'
+ ' }\n'
+ ' else\n'
+ ' pScissors = NULL;\n',
+ }
+
+ custom_copy_txt = {
+ # VkGraphicsPipelineCreateInfo is special case because it has custom construct parameters
+ 'VkGraphicsPipelineCreateInfo' :
+ ' if (stageCount && src.pStages) {\n'
+ ' pStages = new safe_VkPipelineShaderStageCreateInfo[stageCount];\n'
+ ' for (uint32_t i=0; i<stageCount; ++i) {\n'
+ ' pStages[i].initialize(&src.pStages[i]);\n'
+ ' }\n'
+ ' }\n'
+ ' if (src.pVertexInputState)\n'
+ ' pVertexInputState = new safe_VkPipelineVertexInputStateCreateInfo(*src.pVertexInputState);\n'
+ ' else\n'
+ ' pVertexInputState = NULL;\n'
+ ' if (src.pInputAssemblyState)\n'
+ ' pInputAssemblyState = new safe_VkPipelineInputAssemblyStateCreateInfo(*src.pInputAssemblyState);\n'
+ ' else\n'
+ ' pInputAssemblyState = NULL;\n'
+ ' bool has_tessellation_stage = false;\n'
+ ' if (stageCount && pStages)\n'
+ ' for (uint32_t i=0; i<stageCount && !has_tessellation_stage; ++i)\n'
+ ' if (pStages[i].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT || pStages[i].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT)\n'
+ ' has_tessellation_stage = true;\n'
+ ' if (src.pTessellationState && has_tessellation_stage)\n'
+ ' pTessellationState = new safe_VkPipelineTessellationStateCreateInfo(*src.pTessellationState);\n'
+ ' else\n'
+ ' pTessellationState = NULL; // original pTessellationState pointer ignored\n'
+ ' bool has_rasterization = src.pRasterizationState ? !src.pRasterizationState->rasterizerDiscardEnable : false;\n'
+ ' if (src.pViewportState && has_rasterization) {\n'
+ ' pViewportState = new safe_VkPipelineViewportStateCreateInfo(*src.pViewportState);\n'
+ ' } else\n'
+ ' pViewportState = NULL; // original pViewportState pointer ignored\n'
+ ' if (src.pRasterizationState)\n'
+ ' pRasterizationState = new safe_VkPipelineRasterizationStateCreateInfo(*src.pRasterizationState);\n'
+ ' else\n'
+ ' pRasterizationState = NULL;\n'
+ ' if (src.pMultisampleState && has_rasterization)\n'
+ ' pMultisampleState = new safe_VkPipelineMultisampleStateCreateInfo(*src.pMultisampleState);\n'
+ ' else\n'
+ ' pMultisampleState = NULL; // original pMultisampleState pointer ignored\n'
+ ' if (src.pDepthStencilState && has_rasterization)\n'
+ ' pDepthStencilState = new safe_VkPipelineDepthStencilStateCreateInfo(*src.pDepthStencilState);\n'
+ ' else\n'
+ ' pDepthStencilState = NULL; // original pDepthStencilState pointer ignored\n'
+ ' if (src.pColorBlendState && has_rasterization)\n'
+ ' pColorBlendState = new safe_VkPipelineColorBlendStateCreateInfo(*src.pColorBlendState);\n'
+ ' else\n'
+ ' pColorBlendState = NULL; // original pColorBlendState pointer ignored\n'
+ ' if (src.pDynamicState)\n'
+ ' pDynamicState = new safe_VkPipelineDynamicStateCreateInfo(*src.pDynamicState);\n'
+ ' else\n'
+ ' pDynamicState = NULL;\n',
+ # VkPipelineViewportStateCreateInfo is special case because it has custom construct parameters
+ 'VkPipelineViewportStateCreateInfo' :
+ ' if (src.pViewports) {\n'
+ ' pViewports = new VkViewport[src.viewportCount];\n'
+ ' memcpy ((void *)pViewports, (void *)src.pViewports, sizeof(VkViewport)*src.viewportCount);\n'
+ ' }\n'
+ ' else\n'
+ ' pViewports = NULL;\n'
+ ' if (src.pScissors) {\n'
+ ' pScissors = new VkRect2D[src.scissorCount];\n'
+ ' memcpy ((void *)pScissors, (void *)src.pScissors, sizeof(VkRect2D)*src.scissorCount);\n'
+ ' }\n'
+ ' else\n'
+ ' pScissors = NULL;\n',
+ }
+
custom_destruct_txt = {'VkShaderModuleCreateInfo' :
' if (pCode)\n'
' delete[] reinterpret_cast<const uint8_t *>(pCode);\n' }
@@ -892,7 +1048,7 @@ class HelperFileOutputGenerator(OutputGenerator):
construct_txt = custom_construct_txt[item.name]
if item.name in custom_destruct_txt:
destruct_txt = custom_destruct_txt[item.name]
- safe_struct_body.append("\n%s::%s(const %s* in_struct) :%s\n{\n%s}" % (ss_name, ss_name, item.name, init_list, construct_txt))
+ safe_struct_body.append("\n%s::%s(const %s* in_struct%s) :%s\n{\n%s}" % (ss_name, ss_name, item.name, self.custom_construct_params.get(item.name, ''), init_list, construct_txt))
if '' != default_init_list:
default_init_list = " :%s" % (default_init_list[:-1])
safe_struct_body.append("\n%s::%s()%s\n{}" % (ss_name, ss_name, default_init_list))
@@ -901,11 +1057,13 @@ class HelperFileOutputGenerator(OutputGenerator):
copy_construct_txt = construct_txt.replace(' (in_struct->', ' (src.') # Exclude 'if' blocks from next line
copy_construct_txt = copy_construct_txt.replace('(in_struct->', '(*src.') # Pass object to copy constructors
copy_construct_txt = copy_construct_txt.replace('in_struct->', 'src.') # Modify remaining struct refs for src object
+ if item.name in custom_copy_txt:
+ copy_construct_txt = custom_copy_txt[item.name]
copy_assign_txt = ' if (&src == this) return *this;\n\n' + destruct_txt + '\n' + copy_construct_init + copy_construct_txt + '\n return *this;'
safe_struct_body.append("\n%s::%s(const %s& src)\n{\n%s%s}" % (ss_name, ss_name, ss_name, copy_construct_init, copy_construct_txt)) # Copy constructor
safe_struct_body.append("\n%s& %s::operator=(const %s& src)\n{\n%s\n}" % (ss_name, ss_name, ss_name, copy_assign_txt)) # Copy assignment operator
safe_struct_body.append("\n%s::~%s()\n{\n%s}" % (ss_name, ss_name, destruct_txt))
- safe_struct_body.append("\nvoid %s::initialize(const %s* in_struct)\n{\n%s%s}" % (ss_name, item.name, init_func_txt, construct_txt))
+ safe_struct_body.append("\nvoid %s::initialize(const %s* in_struct%s)\n{\n%s%s}" % (ss_name, item.name, self.custom_construct_params.get(item.name, ''), init_func_txt, construct_txt))
# Copy initializer uses same txt as copy constructor but has a ptr and not a reference
init_copy = copy_construct_init.replace('src.', 'src->')
init_construct = copy_construct_txt.replace('src.', 'src->')
diff --git a/scripts/parameter_validation_generator.py b/scripts/parameter_validation_generator.py
index 9c673fc4..ba825e28 100644
--- a/scripts/parameter_validation_generator.py
+++ b/scripts/parameter_validation_generator.py
@@ -154,6 +154,8 @@ class ParameterValidationOutputGenerator(OutputGenerator):
'vkCreateDebugReportCallbackEXT',
'vkDestroyDebugReportCallbackEXT',
'vkCreateCommandPool',
+ 'vkCreateRenderPass',
+ 'vkDestroyRenderPass',
]
# Structure fields to ignore
self.structMemberBlacklist = { 'VkWriteDescriptorSet' : ['dstSet'] }
diff --git a/scripts/unique_objects_generator.py b/scripts/unique_objects_generator.py
index 9cfa9546..c37bf0dc 100644
--- a/scripts/unique_objects_generator.py
+++ b/scripts/unique_objects_generator.py
@@ -150,6 +150,8 @@ class UniqueObjectsOutputGenerator(OutputGenerator):
'vkGetPhysicalDeviceDisplayProperties2KHR',
'vkGetPhysicalDeviceDisplayPlaneProperties2KHR',
'vkGetDisplayModeProperties2KHR',
+ 'vkCreateRenderPass',
+ 'vkDestroyRenderPass',
]
# Commands shadowed by interface functions and are not implemented
self.interface_functions = [