0

I am working on rendering some things with compute pipelines in Vulkan. Everything is working except some misunderstanding with command buffers

vk::CommandBufferBeginInfo beginInfo{};

    commandBuffers_[i].begin(beginInfo);

    commandBuffers_[i].pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eComputeShader, vk::DependencyFlags{}, {},
                                       std::vector<vk::BufferMemoryBarrier>{
                                           {vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, octreeBuffer_.buffer, 0, 65536}},
                                       std::vector<vk::ImageMemoryBarrier>{
                                           {vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eUndefined, vk::ImageLayout::eGeneral, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, images_[i], {vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_MIP_LEVELS}}});
    commandBuffers_[i].bindPipeline(vk::PipelineBindPoint::eCompute, raycastPipeline_);
    commandBuffers_[i].bindDescriptorSets(vk::PipelineBindPoint::eCompute, raycastPipelineLayout_, 0, 1, &raycastDescriptorSets_[i], 0, nullptr);
    commandBuffers_[i].dispatch(engine_->config_.window_width / 16 + 1, engine_->config_.window_height / 16 + 1, 1); // TODO

    commandBuffers_[i].pipelineBarrier(vk::PipelineStageFlagBits::eComputeShader, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlags{}, {},
                                       std::vector<vk::BufferMemoryBarrier>{
                                           {vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, lightingBuffer_.buffer, 0, 65536}},
                                       std::vector<vk::ImageMemoryBarrier>{
                                           {vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eGeneral, vk::ImageLayout::eGeneral, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, images_[i], {vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_MIP_LEVELS}}});
    commandBuffers_[i].bindPipeline(vk::PipelineBindPoint::eCompute, lightingPipeline_);
    commandBuffers_[i].bindDescriptorSets(vk::PipelineBindPoint::eCompute, lightingPipelineLayout_, 0, 1, &lightingDescriptorSets_[i], 0, nullptr);
    commandBuffers_[i].dispatch(65536, 1, 1); // TODO

    commandBuffers_[i].pipelineBarrier(vk::PipelineStageFlagBits::eComputeShader, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlags{}, {},
                                       std::vector<vk::BufferMemoryBarrier>{
                                           {vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, lightingBuffer_.buffer, 0, 65536}},
                                       std::vector<vk::ImageMemoryBarrier>{
                                           {vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eGeneral, vk::ImageLayout::eGeneral, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, images_[i], {vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_MIP_LEVELS}}});

    commandBuffers_[i].bindPipeline(vk::PipelineBindPoint::eCompute, renderPipeline_);
    commandBuffers_[i].bindDescriptorSets(vk::PipelineBindPoint::eCompute, renderPipelineLayout_, 0, 1, &renderDescriptorSets_[i], 0, nullptr);
    commandBuffers_[i].dispatch(engine_->config_.window_width / 16 + 1, engine_->config_.window_height / 16 + 1, 1); // TODO

    commandBuffers_[i].pipelineBarrier(vk::PipelineStageFlagBits::eComputeShader, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlags{}, {},
                                       std::vector<vk::BufferMemoryBarrier>{}, std::vector<vk::ImageMemoryBarrier>{{vk::AccessFlagBits::eMemoryWrite, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eGeneral, vk::ImageLayout::ePresentSrcKHR, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, images_[i], {vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_MIP_LEVELS}}});

    commandBuffers_[i].end();

This is my code to chain multiple pipelines. This is what the validation layers is returning

[ERROR] Validation Error: [ UNASSIGNED-CoreValidation-DrawState-PipelineLayoutsIncompatible ] Object 0: handle = 0xcfcda0000000001e, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x33073516 | vkCmdDispatch(): VkDescriptorSet 0xcfcda0000000001e[] bound as set #0 is not compatible with overlapping VkPipelineLayout 0x301e6c0000000022[] due to: VkDescriptorSetLayout 0xdd3a8a0000000015[] from pipeline layout has 3 total descriptors, but VkDescriptorSetLayout 0x84c0580000000017[], which is bound, has 2 total descriptors.
[ERROR] Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0: handle = 0xb9181f0000000029, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xb9181f0000000029[] defined with VkPipelineLayout 0x301e6c0000000022[] is not compatible for maximum set statically used 0 with bound descriptor sets, last bound with VkPipelineLayout 0x3fbcd60000000028[] The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDispatch-None-02697)
[ERROR] Validation Error: [ UNASSIGNED-CoreValidation-DrawState-PipelineLayoutsIncompatible ] Object 0: handle = 0x2e2941000000001f, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x33073516 | vkCmdDispatch(): VkDescriptorSet 0x2e2941000000001f[] bound as set #0 is not compatible with overlapping VkPipelineLayout 0x301e6c0000000022[] due to: VkDescriptorSetLayout 0xdd3a8a0000000015[] from pipeline layout has 3 total descriptors, but VkDescriptorSetLayout 0x84c0580000000017[], which is bound, has 2 total descriptors.
[ERROR] Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0: handle = 0xb9181f0000000029, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xb9181f0000000029[] defined with VkPipelineLayout 0x301e6c0000000022[] is not compatible for maximum set statically used 0 with bound descriptor sets, last bound with VkPipelineLayout 0x3fbcd60000000028[] The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDispatch-None-02697)
[ERROR] Validation Error: [ UNASSIGNED-CoreValidation-DrawState-PipelineLayoutsIncompatible ] Object 0: handle = 0xab64de0000000020, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x33073516 | vkCmdDispatch(): VkDescriptorSet 0xab64de0000000020[] bound as set #0 is not compatible with overlapping VkPipelineLayout 0x301e6c0000000022[] due to: VkDescriptorSetLayout 0xdd3a8a0000000015[] from pipeline layout has 3 total descriptors, but VkDescriptorSetLayout 0x84c0580000000017[], which is bound, has 2 total descriptors.
[INFO] First command buffers recorded[ERROR] Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0: handle = 0xb9181f0000000029, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xb9181f0000000029[] defined with VkPipelineLayout 0x301e6c0000000022[] is not compatible for maximum set statically used 0 with bound descriptor sets, last bound with VkPipelineLayout 0x3fbcd60000000028[] The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDispatch-None-02697)
[ERROR] Validation Error: [ UNASSIGNED-CoreValidation-DrawState-PipelineLayoutsIncompatible ] Object 0: handle = 0xcfcda0000000001e, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x33073516 | vkCmdDispatch(): VkDescriptorSet 0xcfcda0000000001e[] bound as set #0 is not compatible with overlapping VkPipelineLayout 0x301e6c0000000022[] due to: VkDescriptorSetLayout 0xdd3a8a0000000015[] from pipeline layout has 3 total descriptors, but VkDescriptorSetLayout 0x84c0580000000017[], which is bound, has 2 total descriptors.
[ERROR] Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0: handle = 0xb9181f0000000029, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xb9181f0000000029[] defined with VkPipelineLayout 0x301e6c0000000022[] is not compatible for maximum set statically used 0 with bound descriptor sets, last bound with VkPipelineLayout 0x3fbcd60000000028[] The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDispatch-None-02697)
[ERROR] Validation Error: [ UNASSIGNED-CoreValidation-DrawState-PipelineLayoutsIncompatible ] Object 0: handle = 0x2e2941000000001f, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x33073516 | vkCmdDispatch(): VkDescriptorSet 0x2e2941000000001f[] bound as set #0 is not compatible with overlapping VkPipelineLayout 0x301e6c0000000022[] due to: VkDescriptorSetLayout 0xdd3a8a0000000015[] from pipeline layout has 3 total descriptors, but VkDescriptorSetLayout 0x84c0580000000017[], which is bound, has 2 total descriptors.
[ERROR] Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0: handle = 0xb9181f0000000029, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xb9181f0000000029[] defined with VkPipelineLayout 0x301e6c0000000022[] is not compatible for maximum set statically used 0 with bound descriptor sets, last bound with VkPipelineLayout 0x3fbcd60000000028[] The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDispatch-None-02697)
[ERROR] Validation Error: [ UNASSIGNED-CoreValidation-DrawState-PipelineLayoutsIncompatible ] Object 0: handle = 0xab64de0000000020, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x33073516 | vkCmdDispatch(): VkDescriptorSet 0xab64de0000000020[] bound as set #0 is not compatible with overlapping VkPipelineLayout 0x301e6c0000000022[] due to: VkDescriptorSetLayout 0xdd3a8a0000000015[] from pipeline layout has 3 total descriptors, but VkDescriptorSetLayout 0x84c0580000000017[], which is bound, has 2 total descriptors.

What is wrong with my descriptor sets?

  • 1
    It looks like you trying to bind a VkDescriptorSet using a VkDescriptorSetLayout incompatible with the one used to create some of your VkPipelineLayout : The validation layer says there are 3 bindings in the VkDescriptorSetLayout #0 of a VkPipelineLayout but there is only 2 in the VkDescriptorSetLayout of the VkDescritptorSet you are trying to bind. – Siliace Sep 21 '22 at 10:34
  • @Siliace Comment should be answerized? – krOoze Oct 10 '22 at 14:31
  • @Siliace thank you very much it was a problem with the VkDescriptorLayout – Maftei Albert-Alexandru Oct 11 '22 at 16:57

0 Answers0