From 939e484bf0116f2430177a12725beddc01a74bb9 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Fri, 8 Jan 2016 14:52:49 -0700 Subject: layers: Gitlab 41 & 61, Fix invalid descriptor dereferences in helper codegen Descriptor type arrays should only be dereferenced depending on the specified descriptorType parameter. Caused crashes in api_dump. --- vk_helper.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/vk_helper.py b/vk_helper.py index 6dfced67..fd5c96e0 100755 --- a/vk_helper.py +++ b/vk_helper.py @@ -884,6 +884,22 @@ class StructWrapperGen: else: sh_funcs.append('%sif (pStruct->sharingMode == VK_SHARING_MODE_CONCURRENT) {' % (indent)) indent += ' ' + if (stp_list[index]['name'] == 'pImageInfo'): + sh_funcs.append('%sif ((pStruct->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE)) {' % (indent)) + indent += ' ' + elif (stp_list[index]['name'] == 'pBufferInfo'): + sh_funcs.append('%sif ((pStruct->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {' % (indent)) + indent += ' ' + elif (stp_list[index]['name'] == 'pTexelBufferView'): + sh_funcs.append('%sif ((pStruct->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||' % (indent)) + sh_funcs.append('%s (pStruct->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {' % (indent)) + indent += ' ' sh_funcs.append('%sif (pStruct->%s) {' % (indent, stp_list[index]['name'])) indent += ' ' sh_funcs.append('%sfor (uint32_t i = 0; i < %s; i++) {' % (indent, array_count)) @@ -921,7 +937,7 @@ class StructWrapperGen: indent = indent[4:] sh_funcs.append('%s}' % (indent)) #endif - if (stp_list[index]['name'] == 'pQueueFamilyIndices'): + if (stp_list[index]['name'] == 'pQueueFamilyIndices') or (stp_list[index]['name'] == 'pImageInfo') or (stp_list[index]['name'] == 'pBufferInfo') or (stp_list[index]['name'] == 'pTexelBufferView'): indent = indent[4:] sh_funcs.append('%s}' % (indent)) elif (stp_list[index]['ptr']): -- cgit v1.2.3