Setting up two consecutive compute shaders

I am trying to make a simulation that involves two steps of computation before rendering. I currently have working a compute pipeline that calculate basic physics, and then a graphics pipeline. I would like to be able to add a second compute shader to be run after the first.

First, is it possible to have two consecutive compute shaders in Vulkan?

I have tried a few different variations of trying to get the second compute shader. The method I thought to be most promising was when calling vkCreateComputePipelines, passing in arrays of VkComputePipelineCreateInfo’s and VkPipeline’s, and changing the createInfoCount to 2. According to the documentation, it seemed like the createInfoCount referred to the number of both the createInfo’s and pipelines, which led us to believe it was possible to have multiple pipelines, however this causes a crash. With just a single compute shader, instead of passing in length-1 array, I directly pass in the address of the createInfo and the pipeline. Changing the createInfo to an array works fine, but as soon as I try to change the pipeline parameter to point to an array (even with just a single pipeline in that array), it causes a crash. Is there a flag or parameter I’d need to adjust to allow multiple pipelines to be created?

Another method I considered was to add multiple computeShaderStageInfo’s to the VkComputePipelineCreateInfo, and then only have one createInfo and one compute pipeline. However, unlike VkGraphicsPipelineCreateInfo, it only seems to allow for a single stage, rather than an array of stages.

I also tried creating a second VkCommandBuffer for the second compute shader. I were able to bind the descriptor sets to both command buffers, but only the one dispatched last was run.


Cross-posted at SO.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.