VkFormatProperties2* pFormatProperties)
{
GetPhysicalDeviceFormatProperties(physicalDevice, format, &pFormatProperties->formatProperties);
+ VkFormatProperties3KHR *props_3 = lvl_find_mod_in_chain<VkFormatProperties3KHR>(pFormatProperties->pNext);
+ if (props_3) {
+ props_3->linearTilingFeatures = pFormatProperties->formatProperties.linearTilingFeatures;
+ props_3->optimalTilingFeatures = pFormatProperties->formatProperties.optimalTilingFeatures;
+ props_3->bufferFeatures = pFormatProperties->formatProperties.bufferFeatures;
+ }
}
static VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceImageFormatProperties2KHR(
VkStructureType sType;
const LvlGenericHeader *pNext;
};
+struct LvlGenericModHeader {
+ VkStructureType sType;
+ LvlGenericModHeader *pNext;
+};
// Find an entry of the given type in the pNext chain
template <typename T> const T *lvl_find_in_chain(const void *next) {
}
return found;
}
+// Find an entry of the given type in the pNext chain
+template <typename T> T *lvl_find_mod_in_chain(void *next) {
+ LvlGenericModHeader *current = reinterpret_cast<LvlGenericModHeader *>(next);
+ T *found = nullptr;
+ while (current) {
+ if (LvlTypeMap<T>::kSType == current->sType) {
+ found = reinterpret_cast<T*>(current);
+ current = nullptr;
+ } else {
+ current = current->pNext;
+ }
+ }
+ return found;
+}
// Init the header of an sType struct with pNext
template <typename T> T lvl_init_struct(void *p_next) {
''',
'vkGetPhysicalDeviceFormatProperties2KHR': '''
GetPhysicalDeviceFormatProperties(physicalDevice, format, &pFormatProperties->formatProperties);
+ VkFormatProperties3KHR *props_3 = lvl_find_mod_in_chain<VkFormatProperties3KHR>(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
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((
' 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 <typename T> const T *{find_func}(const void *next) {{',
' }}',
' return found;',
'}}',
+ '// Find an entry of the given type in the pNext chain',
+ 'template <typename T> T *{find_mod_func}(void *next) {{',
+ ' {mod_header} *current = reinterpret_cast<{mod_header} *>(next);',
+ ' T *found = nullptr;',
+ ' while (current) {{',
+ ' if ({type_map}<T>::{id_member} == current->sType) {{',
+ ' found = reinterpret_cast<T*>(current);',
+ ' current = nullptr;',
+ ' }} else {{',
+ ' current = current->pNext;',
+ ' }}',
+ ' }}',
+ ' return found;',
+ '}}',
'',
'// Init the header of an sType struct with pNext',
'template <typename T> T {init_func}(void *p_next) {{',
# 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)