From d3cdb64f2ef5e806f2b3ac43c5428105514ae838 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 9 Dec 2021 17:43:51 +0200 Subject: scripts: Fix codegen to support VK_KHR_format_feature_flags2 If the implementation reports that it supports this feature, it should fill out VkFormatProperties3KHR properly. --- scripts/mock_icd_generator.py | 6 ++++++ scripts/vulkan_tools_helper_file_generator.py | 25 +++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py index 8cc94621..a2360b5f 100644 --- a/scripts/mock_icd_generator.py +++ b/scripts/mock_icd_generator.py @@ -761,6 +761,12 @@ CUSTOM_C_INTERCEPTS = { ''', 'vkGetPhysicalDeviceFormatProperties2KHR': ''' GetPhysicalDeviceFormatProperties(physicalDevice, format, &pFormatProperties->formatProperties); + VkFormatProperties3KHR *props_3 = lvl_find_mod_in_chain(pFormatProperties->pNext); + if (props_3) { + props_3->linearTilingFeatures = pFormatProperties->formatProperties.linearTilingFeatures; + props_3->optimalTilingFeatures = pFormatProperties->formatProperties.optimalTilingFeatures; + props_3->bufferFeatures = pFormatProperties->formatProperties.bufferFeatures; + } ''', 'vkGetPhysicalDeviceImageFormatProperties': ''' // A hardcoded unsupported format diff --git a/scripts/vulkan_tools_helper_file_generator.py b/scripts/vulkan_tools_helper_file_generator.py index 42ce0199..b0e486ef 100644 --- a/scripts/vulkan_tools_helper_file_generator.py +++ b/scripts/vulkan_tools_helper_file_generator.py @@ -1102,9 +1102,11 @@ class HelperFileOutputGenerator(OutputGenerator): id_member = 'kSType' id_decl = 'static const VkStructureType ' generic_header = prefix + 'GenericHeader' + generic_mod_header = prefix + 'GenericModHeader' typename_func = fprefix + 'typename' idname_func = fprefix + 'stype_name' find_func = fprefix + 'find_in_chain' + find_mod_func = fprefix + 'find_mod_in_chain' init_func = fprefix + 'init_struct' explanatory_comment = '\n'.join(( @@ -1130,6 +1132,10 @@ class HelperFileOutputGenerator(OutputGenerator): ' VkStructureType sType;', ' const {header} *pNext;', '}};', + 'struct {mod_header} {{', + ' VkStructureType sType;', + ' {mod_header} *pNext;', + '}};', '', '// Find an entry of the given type in the pNext chain', 'template const T *{find_func}(const void *next) {{', @@ -1145,6 +1151,20 @@ class HelperFileOutputGenerator(OutputGenerator): ' }}', ' return found;', '}}', + '// Find an entry of the given type in the pNext chain', + 'template T *{find_mod_func}(void *next) {{', + ' {mod_header} *current = reinterpret_cast<{mod_header} *>(next);', + ' T *found = nullptr;', + ' while (current) {{', + ' if ({type_map}::{id_member} == current->sType) {{', + ' found = reinterpret_cast(current);', + ' current = nullptr;', + ' }} else {{', + ' current = current->pNext;', + ' }}', + ' }}', + ' return found;', + '}}', '', '// Init the header of an sType struct with pNext', 'template T {init_func}(void *p_next) {{', @@ -1194,8 +1214,9 @@ class HelperFileOutputGenerator(OutputGenerator): # Generate utilities for all types code.append('\n'.join(( utilities_format.format(id_member=id_member, id_map=idmap, type_map=typemap, - type_member=type_member, header=generic_header, typename_func=typename_func, idname_func=idname_func, - find_func=find_func, init_func=init_func), '' + type_member=type_member, header=generic_header, mod_header=generic_mod_header, + typename_func=typename_func, idname_func=idname_func, find_func=find_func, + find_mod_func=find_mod_func, init_func=init_func), '' ))) return "\n".join(code) -- cgit v1.2.3