Skip to content

Commit

Permalink
Ensure descriptors are cleanly serialised and initialised for all types
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Jan 16, 2025
1 parent e8abd69 commit 7840000
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions renderdoc/driver/vulkan/vk_serialise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5367,31 +5367,49 @@ void DoSerialise(SerialiserType &ser, DescriptorSetSlot &el)
// mutable descriptor path

// serialise the type as VkDescriptorType
VkDescriptorType type = convert(el.type);
VkDescriptorType type;
if(ser.IsWriting())
type = convert(el.type);
SERIALISE_ELEMENT(type);
el.type = convert(type);
if(ser.IsReading())
el.type = convert(type);

// serialise sampler, if the type needs it
if(el.type == DescriptorSlotType::Sampler || el.type == DescriptorSlotType::CombinedImageSampler)
{
SERIALISE_MEMBER(sampler);
}
else if(ser.IsReading())
{
el.sampler = ResourceId();
}

// almost all types have a resource, serialise that
if(el.type != DescriptorSlotType::Unwritten && el.type != DescriptorSlotType::InlineBlock &&
el.type != DescriptorSlotType::Count)
{
SERIALISE_MEMBER(resource);
}
else if(ser.IsReading())
{
el.resource = ResourceId();
}

// serialise image layout, for image types
if(el.type == DescriptorSlotType::CombinedImageSampler ||
el.type == DescriptorSlotType::SampledImage || el.type == DescriptorSlotType::StorageImage ||
el.type == DescriptorSlotType::InputAttachment)
{
VkImageLayout imageLayout = convert(el.imageLayout);
VkImageLayout imageLayout;
if(ser.IsWriting())
imageLayout = convert(el.imageLayout);
SERIALISE_ELEMENT(imageLayout);
el.imageLayout = convert(imageLayout);
if(ser.IsReading())
el.imageLayout = convert(imageLayout);
}
else if(ser.IsReading())
{
el.imageLayout = DescriptorSlotImageLayout::Undefined;
}

// serialise buffer range, for buffer types and inline block
Expand All @@ -5401,12 +5419,25 @@ void DoSerialise(SerialiserType &ser, DescriptorSetSlot &el)
el.type == DescriptorSlotType::StorageBufferDynamic ||
el.type == DescriptorSlotType::InlineBlock)
{
VkDeviceSize offset = el.offset;
VkDeviceSize range = el.GetRange();
VkDeviceSize offset;
VkDeviceSize range;
if(ser.IsWriting())
{
offset = el.offset;
range = el.GetRange();
}
SERIALISE_ELEMENT(offset).OffsetOrSize();
SERIALISE_ELEMENT(range).OffsetOrSize();
el.offset = offset;
el.range = range;
if(ser.IsReading())
{
el.offset = offset;
el.range = range;
}
}
else if(ser.IsReading())
{
el.offset = 0;
el.range = 0;
}
}
else
Expand Down

0 comments on commit 7840000

Please sign in to comment.