vulkan/properties: Handle unsized arrays properly
Sadly we cannot autogenerate handling for them, so fall back to hand
written handling instead.
Fixes: eaee792
("vulkan: Add a generated vk_properties struct")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25055>
This commit is contained in:

committed by
Marge Bot

parent
b235e8fc9a
commit
9e37631aa5
@@ -58,6 +58,10 @@ RENAMED_PROPERTIES = {
|
|||||||
("SubgroupProperties", "quadOperationsInAllStages"): "subgroupQuadOperationsInAllStages",
|
("SubgroupProperties", "quadOperationsInAllStages"): "subgroupQuadOperationsInAllStages",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPECIALIZED_PROPERTY_STRUCTS = [
|
||||||
|
"HostImageCopyPropertiesEXT",
|
||||||
|
]
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Property:
|
class Property:
|
||||||
decl: str
|
decl: str
|
||||||
@@ -89,10 +93,10 @@ class PropertyStruct:
|
|||||||
properties: typing.List[Property]
|
properties: typing.List[Property]
|
||||||
|
|
||||||
def copy_property(dst, src, decl, length="1"):
|
def copy_property(dst, src, decl, length="1"):
|
||||||
|
assert "*" not in decl
|
||||||
|
|
||||||
if "[" in decl:
|
if "[" in decl:
|
||||||
return "memcpy(%s, %s, sizeof(%s));" % (dst, src, dst)
|
return "memcpy(%s, %s, sizeof(%s));" % (dst, src, dst)
|
||||||
elif "*" in decl:
|
|
||||||
return "if (%s) memcpy(%s, %s, sizeof(%s[0] * %s));" % (dst, dst, src, dst, length)
|
|
||||||
else:
|
else:
|
||||||
return "%s = %s;" % (dst, src)
|
return "%s = %s;" % (dst, src)
|
||||||
|
|
||||||
@@ -140,6 +144,7 @@ vk_common_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||||||
vk_foreach_struct(ext, pProperties) {
|
vk_foreach_struct(ext, pProperties) {
|
||||||
switch (ext->sType) {
|
switch (ext->sType) {
|
||||||
% for property_struct in property_structs:
|
% for property_struct in property_structs:
|
||||||
|
% if property_struct.name not in SPECIALIZED_PROPERTY_STRUCTS:
|
||||||
case ${property_struct.s_type}: {
|
case ${property_struct.s_type}: {
|
||||||
${property_struct.c_type} *properties = (void *)ext;
|
${property_struct.c_type} *properties = (void *)ext;
|
||||||
% for prop in property_struct.properties:
|
% for prop in property_struct.properties:
|
||||||
@@ -147,7 +152,39 @@ vk_common_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
|||||||
% endfor
|
% endfor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
|
/* Specialized propery handling defined in vk_physical_device_properties_gen.py */
|
||||||
|
|
||||||
|
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT: {
|
||||||
|
VkPhysicalDeviceHostImageCopyPropertiesEXT *properties = (void *)ext;
|
||||||
|
|
||||||
|
if (properties->pCopySrcLayouts) {
|
||||||
|
uint32_t written_layout_count = MIN2(properties->copySrcLayoutCount,
|
||||||
|
pdevice->properties.copySrcLayoutCount);
|
||||||
|
memcpy(properties->pCopySrcLayouts, pdevice->properties.pCopySrcLayouts,
|
||||||
|
sizeof(VkImageLayout) * written_layout_count);
|
||||||
|
properties->copySrcLayoutCount = written_layout_count;
|
||||||
|
} else {
|
||||||
|
properties->copySrcLayoutCount = pdevice->properties.copySrcLayoutCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties->pCopyDstLayouts) {
|
||||||
|
uint32_t written_layout_count = MIN2(properties->copyDstLayoutCount,
|
||||||
|
pdevice->properties.copyDstLayoutCount);
|
||||||
|
memcpy(properties->pCopyDstLayouts, pdevice->properties.pCopyDstLayouts,
|
||||||
|
sizeof(VkImageLayout) * written_layout_count);
|
||||||
|
properties->copyDstLayoutCount = written_layout_count;
|
||||||
|
} else {
|
||||||
|
properties->copyDstLayoutCount = pdevice->properties.copyDstLayoutCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(properties->optimalTilingLayoutUUID, pdevice->properties.optimalTilingLayoutUUID, VK_UUID_SIZE);
|
||||||
|
properties->identicalMemoryTypeRequirements = pdevice->properties.identicalMemoryTypeRequirements;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -274,7 +311,8 @@ def main():
|
|||||||
"pdev_properties": pdev_properties,
|
"pdev_properties": pdev_properties,
|
||||||
"property_structs": property_structs,
|
"property_structs": property_structs,
|
||||||
"all_properties": all_properties,
|
"all_properties": all_properties,
|
||||||
"copy_property": copy_property
|
"copy_property": copy_property,
|
||||||
|
"SPECIALIZED_PROPERTY_STRUCTS": SPECIALIZED_PROPERTY_STRUCTS,
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user