vkCreateComputePipeline causes VK_ERROR_OUT_OF_HOST_MEMORY

Hey all together!

I recently started learning vulkan for a project at my college but I ran into a problem i cannot figure out. Maybe some of you can and may help me :slight_smile: I would really appreciate that because I’ve got no one else to ask for …

I want to create a compute pipeline, but I get the error VK_ERROR_OUT_OF_HOST_MEMORY. Memory is enough available so I think it is a another problem not showing to me …

I followed a small example which works (cloned and ran). But doing it on myself (changed for my purposes) isn’t working but I do not know why.

I attached a bit of my code. The last code line ist the problem causing one.

If you need more Information or more Code feel free to ask :slight_smile:

Thanks a lot if you can help me! This is so frustrating when not knowing anything because of no much feedback …

Here is a bit of my code:
void createComputePipeline(Compute *compute)
long computeShaderSourceSize;
char *computeShaderSource = readFile("./vulkan/comp.spv", “rb”, &computeShaderSourceSize);

    VkShaderModuleCreateInfo shaderModuleCreateInfo = {};
    shaderModuleCreateInfo.pCode = (uint32_t *) computeShaderSource;
    shaderModuleCreateInfo.codeSize = computeShaderSourceSize;

    ASSERT_VK(vkCreateShaderModule(compute->device, &shaderModuleCreateInfo, NULL, &(compute->shaderModule)))


    VkPipelineShaderStageCreateInfo pipelineShaderStageCreateInfo = {};
    pipelineShaderStageCreateInfo.stage = VK_SHADER_STAGE_COMPUTE_BIT;
    pipelineShaderStageCreateInfo.module = compute->shaderModule;
    pipelineShaderStageCreateInfo.pName = "main";

    VkDescriptorSetLayout descriptorSetLayouts[] = {
    VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {};
    pipelineLayoutCreateInfo.setLayoutCount = 3;
    pipelineLayoutCreateInfo.pSetLayouts = descriptorSetLayouts;

    ASSERT_VK(vkCreatePipelineLayout(compute->device, &pipelineLayoutCreateInfo, NULL, &(compute->pipelineLayout)));

    VkComputePipelineCreateInfo pipelineCreateInfo = {};
    pipelineCreateInfo.stage = pipelineShaderStageCreateInfo;
    pipelineCreateInfo.layout = compute->pipelineLayout;

    ASSERT_VK(vkCreateComputePipelines(compute->device, VK_NULL_HANDLE, 1, &pipelineCreateInfo, NULL, &(compute->pipeline)))

Can you run the sample with validation layers enabled and see if they output and warnings or errors that may help you locate the problem? The error you get is probably a result of a wrong setup before the call to creating the compute pipeline, and in most cases validation layers will point you to the problem causing this.

1 Like

Sascha Willems himself, what a pleasure :slight_smile:

Okey, I activated the validation layer and I got a few Errors.
The first ones were that I did not set the dstBinding in VkWriteDescriptorSet correctly.
I fixed that, but I also get (two) errors which I do not understand:

 UNASSIGNED-CoreValidation-Shader-MissingDescriptor(ERROR / SPEC): 
 msgNum: 0 - Shader uses descriptor slot 0.2 
 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT`) but not declared in pipeline layout
    Objects: 1
        [0] 0, type: 0, name: NULL

That message tells you that your pipeline layout and shader inputs don’t match. The 0.2 is the position. The shader expects one of the types mentioned in that layer message to be bound to set 0 binding 2, which is not the case.

1 Like

Okey, for explanation:
My Shader have three bindings, all set0.
But I created three different DescriptorSets, for each buffer one (with own setlayout and so on).
So I had set0, set1 and set2

So instead of bindings like set0->0, set1->0, set2->0 mine was set0->0, set0->1, set0->2 and this did not match.

Maybe not best solution, but I changed the layout field in shader with set0, set1 and set2 and bound the buffers to binding 0.

Now the compute pipeline can be created.
(If you know any bugs that can occur by my solution please tell me :))

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