winevulkan: Don't try to convert ignored VkWriteDescriptorSet members.

Fixes crash in wined3d_unordered_access_view_vk_clear().
This commit is contained in:
Jacek Caban 2022-11-10 22:54:22 +01:00 committed by Alexandre Julliard
parent 897ab8c6ec
commit 1e3d0c863c
2 changed files with 34 additions and 11 deletions

View file

@ -267,6 +267,25 @@ STRUCT_CHAIN_CONVERSIONS = {
"VkInstanceCreateInfo": ["VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO"],
}
# Some struct members are conditionally ignored and callers are free to leave them uninitialized.
# We can't deduce that from XML, so we allow expressing it here.
MEMBER_LENGTH_EXPRESSIONS = {
"VkWriteDescriptorSet": {
"pImageInfo":
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM ? {len} : 0",
"pBufferInfo":
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC || " +
"{struct}descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ? {len} : 0",
}
}
class Direction(Enum):
""" Parameter direction: input, output, input_output. """
@ -1129,12 +1148,16 @@ class VkVariable(object):
parent = var.struct.members
len += len_str
if not len_str in parent:
return len
if len_str in parent:
var = parent[parent.index(len_str)]
if var.is_pointer():
len = "*" + len
if isinstance(self.parent, VkStruct) and self.parent.name in MEMBER_LENGTH_EXPRESSIONS:
exprs = MEMBER_LENGTH_EXPRESSIONS[self.parent.name]
if self.name in exprs:
len = exprs[self.name].format(struct=prefix, len=len)
var = parent[parent.index(len_str)]
if var.is_pointer():
len = "*" + len
return len
def is_const(self):
@ -1786,12 +1809,12 @@ class VkStruct(Sequence):
structextends = struct.attrib.get("structextends")
structextends = structextends.split(",") if structextends else []
members = []
s = VkStruct(name, [], returnedonly, structextends, union=union)
for member in struct.findall("member"):
vk_member = VkMember.from_xml(member, returnedonly, members)
members.append(vk_member)
vk_member = VkMember.from_xml(member, returnedonly, s)
s.members.append(vk_member)
return VkStruct(name, members, returnedonly, structextends, union=union)
return s
@staticmethod
def decouple_structs(structs):

View file

@ -3327,8 +3327,8 @@ static inline void convert_VkWriteDescriptorSet_win32_to_host(struct conversion_
out->dstArrayElement = in->dstArrayElement;
out->descriptorCount = in->descriptorCount;
out->descriptorType = in->descriptorType;
out->pImageInfo = convert_VkDescriptorImageInfo_array_win32_to_host(ctx, in->pImageInfo, in->descriptorCount);
out->pBufferInfo = convert_VkDescriptorBufferInfo_array_win32_to_host(ctx, in->pBufferInfo, in->descriptorCount);
out->pImageInfo = convert_VkDescriptorImageInfo_array_win32_to_host(ctx, in->pImageInfo, in->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || in->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER || in->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE || in->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE || in->descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT || in->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM || in->descriptorType == VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM ? in->descriptorCount : 0);
out->pBufferInfo = convert_VkDescriptorBufferInfo_array_win32_to_host(ctx, in->pBufferInfo, in->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || in->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER || in->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC || in->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ? in->descriptorCount : 0);
out->pTexelBufferView = in->pTexelBufferView;
}
#endif /* USE_STRUCT_CONVERSION */