Compatibility error reported by vkCmdDispatch

I am trying to implement a simple Compute application and I get an error when I call vkCmdDispatch :
Validation Error: [ VUID-vkCmdDispatch-None-08600 ] Object 0: handle = 0xf443490000000006, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0x3450abd3 | vkCmdDispatch(): The VkPipeline 0xf443490000000006 (created with VkPipelineLayout 0xe7f79a0000000005) statically uses descriptor set 0, but set 0 is not compatible with the pipeline layout bound with INVALID_EMPTY (VkNonDispatchableHandle 0x0) The set (0) is out of bounds for the number of sets bound (0)

my shader is a very simple compute with 1 descriptor with 2 bindings:
#version 450
layout (local_size_x = 1) in;
layout (binding = 0) buffer InputBuffer {
float inputData;
};
layout (binding = 1) buffer OutputBuffer {
float outputData;
};
void main() {
uint idx = gl_GlobalInvocationID.x;
outputData[idx] = inputData[idx] * 2.0;
}

and I create a VkDescriptorSetLayoutCreateInfo with those 2 bindings:

void createComputeDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout * descriptorSetLayout) {
VkDescriptorSetLayoutBinding storageBufferLayoutBinding_0 = {};
storageBufferLayoutBinding_0.binding = 0;
storageBufferLayoutBinding_0.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
storageBufferLayoutBinding_0.descriptorCount = 1;
storageBufferLayoutBinding_0.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
//storageBufferLayoutBinding_0.pImmutableSamplers = nullptr; // Optional

VkDescriptorSetLayoutBinding storageBufferLayoutBinding_1 = {};
storageBufferLayoutBinding_1.binding = 1;
storageBufferLayoutBinding_1.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
storageBufferLayoutBinding_1.descriptorCount = 1;
storageBufferLayoutBinding_1.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
//storageBufferLayoutBinding_1.pImmutableSamplers = nullptr; // Optional

std::array<VkDescriptorSetLayoutBinding, 2> storageBufferLayoutBindings = { storageBufferLayoutBinding_0, storageBufferLayoutBinding_1 };

VkDescriptorSetLayoutCreateInfo layoutInfo = {};
layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
layoutInfo.bindingCount = static_cast<uint32_t>(storageBufferLayoutBindings.size());
layoutInfo.pBindings = storageBufferLayoutBindings.data();

if (vkCreateDescriptorSetLayout(device, &layoutInfo, nullptr, descriptorSetLayout) != VK_SUCCESS) {
    throw std::runtime_error("failed to create descriptor set layout!");
}

}

I create VkPipelineLayoutCreateInfo using above descriptor set:

createComputeDescriptorSetLayout(device, &descriptorSetLayout);
std::array<VkDescriptorSetLayout, 1> descriptorSetLayouts = { descriptorSetLayout };
VkPipelineLayoutCreateInfo pipelineLayoutInfo = {};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = static_cast<uint32_t>(descriptorSetLayouts.size());
pipelineLayoutInfo.pSetLayouts = descriptorSetLayouts.data();
if (vkCreatePipelineLayout(device, &pipelineLayoutInfo, nullptr, &pipelineLayout) != VK_SUCCESS) {
    throw std::runtime_error("failed to create pipeline layout!");
}

I create the pipeline using the shader and the pipeline descriptor:

VkComputePipelineCreateInfo pipelineInfo = {};
pipelineInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
pipelineInfo.stage = shaderStageInfo;
pipelineInfo.layout = pipelineLayout;

if (vkCreateComputePipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &computePipeline) != VK_SUCCESS) {
    throw std::runtime_error("failed to create compute pipeline!");
}

I call Dispatch in this way:

VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
vkBeginCommandBuffer(commandBuffer, &beginInfo);
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, computePipeline);
vkCmdDispatch(commandBuffer, 1, 0, 0);

and I get the error. I dont understand why set 0 is not available since I created the pipeline with one descriptor set which should have index 0.

Any help greatly appreciated!

Thank You,
Andrei

And where do you bind that descriptor set? Your last code snippet begins a command buffer and does a dispatch, but nowhere does it actually bind a descriptor set. That’s basically what the validation error is telling you.

Thank You so much, the binding is missing!