Skip to content

Commit

Permalink
Don't modify descriptor update template while writing. Closes #1765
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Mar 9, 2020
1 parent 107f890 commit a56af58
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
16 changes: 12 additions & 4 deletions renderdoc/driver/vulkan/vk_serialise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4045,12 +4045,20 @@ void DoSerialise(SerialiserType &ser, VkDescriptorUpdateTemplateEntry &el)
if(ser.VersionAtLeast(0xE))
#endif
{
uint64_t offset = el.offset;
uint64_t stride = el.stride;
uint64_t offset = 0;
uint64_t stride = 0;
if(ser.IsWriting())
{
offset = el.offset;
stride = el.stride;
}
ser.Serialise("offset"_lit, offset);
ser.Serialise("stride"_lit, stride);
el.offset = (size_t)offset;
el.stride = (size_t)stride;
if(ser.IsReading())
{
el.offset = (size_t)offset;
el.stride = (size_t)stride;
}
}
#if DISABLED(RDOC_APPLE)
else
Expand Down
11 changes: 11 additions & 0 deletions util/test/demos/vk/vk_parameter_zoo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

#include "vk_test.h"

static const VkDescriptorUpdateTemplateEntryKHR constEntry = {
4, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 0, 16,
};

RD_TEST(VK_Parameter_Zoo, VulkanGraphicsTest)
{
static constexpr const char *Description =
Expand Down Expand Up @@ -678,6 +682,13 @@ void main()

vkDestroyDescriptorUpdateTemplateKHR(device, templ, NULL);

// try with constant entry
createInfo.descriptorUpdateEntryCount = 1;
createInfo.pDescriptorUpdateEntries = &constEntry;
vkCreateDescriptorUpdateTemplateKHR(device, &createInfo, NULL, &templ);
vkUpdateDescriptorSetWithTemplateKHR(device, descset, templ, &data);
vkDestroyDescriptorUpdateTemplateKHR(device, templ, NULL);

entries = {
{0, 0, 1, VK_DESCRIPTOR_TYPE_SAMPLER, offsetof(refdatastruct, sampler), sizeof(data)},
{1, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, offsetof(refdatastruct, combined),
Expand Down

0 comments on commit a56af58

Please sign in to comment.