Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT

Hi,
I’m new to Vulkan. At present i have created basic rendering engine which just renders a cube. The object space has
been abstracted from vulkan rendering space.
Below is my gameobject class.

    class GameObject
    {
    protected:
        Transform* transform;
        VulkanManager * vulkanManagerObj;
        UniformBufferManager * uniformBufferManagerObj;
        VertexBuffer * vertexBufferObj;
        Shader * vertShaderObj, * fragShaderObj;
        glm::mat4 MVP;

        int NUM_OF_DESCRIPTOR_SETS;
        VkDescriptorSet * descriptorSetObj;
        VkDescriptorSetLayoutBinding bindingObj{};

        std::string name;

    public:
        GameObject(glm::vec3 position, glm::vec3 scale, glm::vec3 eulerAngles, std::string);
        GameObject(std::string name);
        void Init(VulkanManager* vulkanManagerObj);
        void LoadVertexData();
        void LoadShaders();
        void BindShaderResources(VkDescriptorSet* descriptorSetObj);
        void LoadTranformationMatrices();
        void Update();
        void Draw(VkCommandBuffer* commandBufferObj, VkPipelineLayout* pipelineLayoutObj);
        virtual ~GameObject();
    };

With the above setup a single cube gets rendered without any issues.
But when i try to create another GameObject object (duplicate the first object) it gives me
“Invalid Pipeline CreateInfo State: Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT”

It gives same error even for fragment shader.

I’m a bit stuck with this issue.

Welcome back to the forums @pacific_00 Hopefully someone will be able to help you soon with this question.

Hard to tell without the remaining code parts. If possible please post the relevant parts of your code for shader module creation and pipeline setup.

You probably aren’t clearing the pipeline creation structures properly, resulting in multiple shader modules passed to the pStages member of the pipeline creation state for the vertex stage, resulting in the above message.

Your VkGraphicsPipelineCreateInfo::pStages array is likely wrong (or stageCount). There would be two array elements that have VkPipelineShaderStageCreateInfo::stage with VK_SHADER_STAGE_VERTEX_BIT bit set (or at least that is what the validation error says).

At present i have just one pipeline. My doubt is whether can i use the same (single) pipeline layout throughout my entire application for multiple objects ( with either same or different per-object resources ).

Hence question gets narrowed to what are all per-object resources in vulkan. As you can see in the above gameobject class i have somewhat abstracted the resources.

Just starting off with vulkan hence i wanted to create a proper design code structure so that it could be scaled up later.

@krOoze

There would be two array elements that have VkPipelineShaderStageCreateInfo::stage with VK_SHADER_STAGE_VERTEX_BIT bit set

That’s true, i have pushed the shader modules into an array assigned to VkPipelineShaderStageCreateInfo::stage. I understand that vulkan is not accepting it but i want to understand the normal procedure of tackling multiple objects.

@Sascha_Willems and @krOoze , i have seen your work. Inspiring…!!

So, if you understand the API contract violation from your app, then I am not sure what the outstanding problem here is.

For learning purposes you can go with any app architecture you want. It won’t probably survive no matter what. It will only get in your way to think of scalability and such now when you learn.

Your GameObject has its own shaders. Unique set of shaders implies need for a new VkPipeline. That indicates your GameObject should also have VkPipeline member. That should fix your immediate issue.

Pipeline Layout (resp. Descriptor layouts) define the shader bindings (input points such as uniforms and textures). If your whole app needs only specific bind locations (or subset of), then it is viable to only have one Pipeline Layout for the whole app.

1 Like

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