#Multiple pipelines with the same descriptor sets

49 messages Β· Page 1 of 1 (latest)

frail bay
#

I want to make multimateral system (rust) so I need to use a unique pipeline for each material. I store a hashmap in a renderer struct with material types and pipelines (HashMap<TypeId, Pipeline>) and actual materials as vector of different materials (rust dynamic objects). As I want to have the same descriptor sets (camera, lights and textures) for multiple pipelines, I create descriptor sets and layouts first and push them into every my pipeline layout

device.begin_command_buffer(...);
device.cmd_begin_render_pass(...);

// Iterate over TypeIds of binded materials
for material_type in self.pipelines.keys() {
    // Get pipeline from HashMap
    let pipeline = self.pipelines.get(&material_type).unwrap();
    
    // Bind pipeline
    device.cmd_bind_pipeline(... pipeline ...);
    // Bind DescSets (they are the same and are stored in separate struct)
    device.cmd_bind_descriptor_sets(
    ...
    [
        descriptor_pool.descriptor_sets_camera[index],
        descriptor_pool.descriptor_sets_texture[index],
        descriptor_pool.descriptor_sets_light[index],
    ]
    ...
    );
    
    // ECS-iterate of models with materials and draw each
    for (_, (mesh, handle, transform)) in &mut world.query::<(
        &Mesh, &MaterialHandle, &Transform,
    )>(){
        // Get material from vector
        let material = self.materials[handle];
        // Compare found material type and binded material type 
        if material.type_id() == material_type {
            device.cmd_bind_index_buffer(...);
            device.cmd_bind_vertex_buffers(...);
            device.cmd_draw_indexed(...);
        }
    }    
}

device.cmd_end_render_pass(...);
device.end_command_buffer(...)?;
#

On start I must get 4 cubes with 2 different binded materials and 2 variants:

  1. Coloured, dark-red (0.7, 0.0, 0.0)
  2. Coloured, cyan (0.0, 0.7, 1.0)
  3. Textured, txt1
  4. Textured, txt2

But at each program running I get arbitrary results like:

  1. Nothing
  2. Two purple? cubes
  3. 3 or 4 cube with texture1

What am I doing wrong first of all? Maybe I am using descriptor sets in a wrong way?

frail bay
#

Ash && Rust ?

#

😍

frail bay
#

I'm newbie aswell.
Always nice to see a Rust && Vulkan enjoyer

#

πŸ˜‹

frail bay
# frail bay I'm newbie aswell. Always nice to see a Rust && Vulkan enjoyer

I like programming in Rust as well as using Vulkan, but it is really sad, that there is no good ECS game engine in Rust yet. The single engine which exists now, Bevy, will not be able to be used for a long time... 😦
Because developers are not even going to elaborate graphics, while wasting time for stuff, which can be solved by users themselves

#

Yeah that is sad.
That is partially why I use C++πŸ˜”

#

Hopefully things develop more for Rust

#

Rust Cargo and Borrow Checker are really good

#

And some of the syntax I think is better than c++
And community is also good

#

Tho it's sadly not as developed for things like gp

#

But for lots of general use case things it good to use imo

frail bay
# frail bay Ash && Rust ?

I hope someone will help me, because this topic is one of the main ones which are on my way to the best engine in the world 😁 developing the engine and games on it

frail bay
#

You're further than me with making an engine lol

#

I get caught up with all sorts of things & "optimizations" & good code

slate yacht
#

do you have the validation layer enabled? otherwise try debugging in renderdoc

slate yacht
cunning crow
#

does some of your pipelines uses push constants and other don't ? this can cause descriptorSets to unbound

frail bay
frail bay
# slate yacht also I use bevy myself, can you explain what you mean by this?

I enjoyed Bevy, but when I decided to create something at least not terrible graphically, I faced with a problem: I can't do that. Shadows were awful and stroked, lighting was also really bad and I hadn't any idea how to fix that, because I didn't know anything about graphics programming... I asked developers on discord and they said, that it maybe will be fixed once upon a time, while issue about shadows is already 2021 year posted.
And now I see. Its developer earns about 8k$ a month, which is great money, but do not dedicate any time to really important things like graphics, because without it you can't make any 3D game. And to start any development now, until developers decide to do anything with graphics, while on every update Bevy becomes ANOTHER GAME ENGINE, and one need to rewrite his code almost fully, is bad idea. And I even don't now, how much time it will take. Will I have at least not terrifying shadows in 0.12.0 update or slt?

frail bay
frail bay
cunning crow
frail bay
#

There is already push constants for every pipeline layout as they used to push transform matrix to a vertex shader

#

So is using same descriptor sets and layouts for multiple pipelines appropriate?

cunning crow
#

Yea it should

frail bay
# cunning crow Yea it should

But if I had pipeline layout passed in cmd_bind_descriptor_sets function, can I just create only 1 pipeline layout for all pipelines, then change command buffer order: firstly cmd_bind_descriptor_sets with this layout and then bind pipelines instead of binding desc sets in every iteration?

cunning crow
#

yea if the pipeline layouts are the same you can bind pipelines without binding again the last desc sets

frail bay
frail bay
#

Yeah, it works, but it haven't changed anything 😁😭

frail bay
#

For someone's interest, here is repo with not-working "engine" https://github.com/konceptosociala/despero
Here are, maybe, main issue files src/render/renderer.rs, src/ecs/systems.ecs
But, as nobody even checked my old OpenGL 300-sloc quasi engine in 2020 on Stackoverflow, this tremendous rubbish will be visited by no one 😁

GitHub

Rustlingva ludmotoro por Komunterio. Contribute to konceptosociala/despero development by creating an account on GitHub.

slate yacht
frail bay
#

Although the implementation has deviated well from the guide

hoary ether
#

Have you enabled the validation layers

#

The easiest way is the vkconfig tool

frail bay
hoary ether
#

Have you neabled some of the off-by-default features like gpu-assisted and sync?

#

Note: They can make your application run painfully slow (which is why they are off by default)

frail bay
#

Are they Vulkan features or cargo crate features, as I have never used them?

hoary ether
#

They are flags you pass on instance creation. (Again, vkconfig is the easiest way to set them)

frail bay
#

An interesting thing, I'll figure it out later (because it is late night in my country now). But also my os or PC for some reason doesn't support debug printf so it can make some difficulties. Or I just set it up in a wrong way

#

Β―_(ツ)_/Β―

#

(thx)