Handle garbage descriptor set in vkCmdPushDescriptorSetKHR. Closes #3461

This commit is contained in:
baldurk
2024-10-25 10:37:38 +01:00
parent 0d98343eca
commit 8a6c3a73f7
2 changed files with 15 additions and 2 deletions
@@ -5643,7 +5643,7 @@ void WrappedVulkan::vkCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
for(uint32_t i = 0; i < descriptorWriteCount; i++)
{
unwrappedWrites[i] = pDescriptorWrites[i];
unwrappedWrites[i].dstSet = Unwrap(unwrappedWrites[i].dstSet);
unwrappedWrites[i].dstSet = VK_NULL_HANDLE; // ignored, may be invalid
VkDescriptorBufferInfo *bufInfos = nextDescriptors;
VkDescriptorImageInfo *imInfos = (VkDescriptorImageInfo *)bufInfos;
@@ -5716,9 +5716,16 @@ void WrappedVulkan::vkCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
CACHE_THREAD_SERIALISER();
// sanitise the descriptor set writes in case there is an invalid set which must be ignored
VkWriteDescriptorSet *sanitised =
(VkWriteDescriptorSet *)GetTempMemory(sizeof(VkWriteDescriptorSet) * descriptorWriteCount);
memcpy(sanitised, pDescriptorWrites, sizeof(VkWriteDescriptorSet) * descriptorWriteCount);
for(uint32_t i = 0; i < descriptorWriteCount; i++)
sanitised[i].dstSet = VK_NULL_HANDLE;
SCOPED_SERIALISE_CHUNK(VulkanChunk::vkCmdPushDescriptorSetKHR);
Serialise_vkCmdPushDescriptorSetKHR(ser, commandBuffer, pipelineBindPoint, layout, set,
descriptorWriteCount, pDescriptorWrites);
descriptorWriteCount, sanitised);
record->AddChunk(scope.Get(&record->cmdInfo->alloc));
record->MarkResourceFrameReferenced(GetResID(layout), eFrameRef_Read);
+6
View File
@@ -1780,6 +1780,12 @@ void main()
vkCmdPushDescriptorSetWithTemplateKHR(cmd, pushtempl, layout, 1, &pushdata);
vkCmdDraw(cmd, 3, 1, 0, 0);
if(KHR_push_descriptor)
vkCmdPushDescriptorSetKHR(
cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 1, 1,
vkh::WriteDescriptorSet((VkDescriptorSet)0x1234, 20,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, validBufInfos));
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, immutpipe);
vkh::cmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, immutlayout, 0,
{immutdescset}, {});