Skip descriptorCount == 0 bindings when applying initial state

* This could cause memory corruption if the final binding(s) were so empty as we
  write off the end of the array before eventually skipping.
This commit is contained in:
baldurk
2019-06-04 12:51:36 +01:00
parent 776b9d048f
commit bf4ea85470
+5 -2
View File
@@ -744,6 +744,11 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id,
for(uint32_t j = 0; j < initialContents.numDescriptors; j++)
{
uint32_t descriptorCount = layout.bindings[j].descriptorCount;
if(descriptorCount == 0)
continue;
writes[bind].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writes[bind].pNext = NULL;
@@ -756,8 +761,6 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id,
writes[bind].descriptorCount = 0;
writes[bind].descriptorType = layout.bindings[j].descriptorType;
uint32_t descriptorCount = layout.bindings[j].descriptorCount;
ResourceId *immutableSamplers = layout.bindings[j].immutableSampler;
DescriptorSetSlot *src = srcData;