Skip to content

Changing the access descriptor for a Uniform multiple times within the same pass. #71

@DGriffin91

Description

@DGriffin91

I'm trying to figure out the best way to bind a different uniform buffer for each draw where each uniform has the same layout, and the rest of the pass/pipeline remains consistent.

Another example would be changing texture bindings for each draw within the same pass.

This is what I've tried, but it's very slow as it results in a new subpass for every draw. It's my understanding that in vulkan, pipelines and bindings can change within a subpass (but not attachments).

let mut pass = frame
    .render_graph
    .begin_pass("Triangle Example")
    .bind_pipeline(&triangle_pipeline)
    .access_node(index_node, AccessType::IndexBuffer)
    .access_node(vertex_node, AccessType::VertexBuffer)
    .clear_color(0, frame.swapchain_image)
    .store_color(0, frame.swapchain_image);

for (i, uniform_node) in uniform_nodes.iter().enumerate() {
    pass = pass
        .access_descriptor(
            5,
            uniform_node.clone(),
            AccessType::VertexShaderReadUniformBuffer,
        )
        .record_subpass(move |subpass, _| {
            subpass.bind_index_buffer(index_node, vk::IndexType::UINT16);
            subpass.bind_vertex_buffer(vertex_node);
            subpass.draw_indexed(3, 1, 0, 0, i as u32);
        });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions