amethyst/rendy

Two image attachments for SimpleGraphicsPipeline

Tsuguri opened this issue · 2 comments

Hi all!

Recently I've been trying to use Rendy in my little project (master thesis) and got some problems.

Once I try to use two images in my SimpleGraphicsPipeline implementation I've got panic during graph building in:

                if !link.access().exclusive() {
                    unimplemented!("This case is unimplemented");
                }

in chain/src/sync.rs: line 421

What I'm trying to achieve: render two images and then combine them in third pass.

    let pass3 = graph_builder.add_node(
        desc3.builder()
            .with_image(image1)
            .with_image(image2) // Once I add second image unimplemeted! is triggered
            .into_subpass()
            .with_dependency(pass1)
            .with_dependency(pass2)
            .with_color(final_output)
            .into_pass()
    );

Is there a way to work around this?
If anyone is willing to explain what the problem seems to be I can dig into Rendy and help implement missing functionality.

I couldn't find any example using more than one image used; if there is one I would love to see it.

Edit:

Actually this error was rather due to the fact that I wanted to use not written to image as an input image.

When actually using code I presented above I get different panic:

thread 'main' panicked at 'Transient image wasn't provided
in
node/render/pass.rs: 730.

                        let images: Vec<_> = group
                            .images()
                            .into_iter()
                            .map(|(id, _)| {
                                images
                                    .find(|i| i.id == id)
                                    .expect(format!("Transient image wasn't provided for {}", id))
                                    .clone()
                            })
                            .collect();

It looks like it can't find input image in map of all images. I'm investigating further.

You correctly understood first error.
Some configurations are not handled by synchronization mechanism in Graph, but most of them are degenerative configurations, like reading from resource no one writes to.

The second error you get is probably a real bug, as all images node references should be in that collection. Unless, maybe, you've tried to use same image as an attachment and as something else in the same node.

I've found the issue.
The problem lies in line 728 of node/render/pass.rs
Iterator of images is created there and then used for images lookup.

Snippet below shows the issue:

    let things = vec![2,3,4,1,5]; // not that 1 is after 2
    let mut things_iter = things.iter(); 

    let items2 = vec![1,2];
    let results : Vec<_> = items2.into_iter().map(|item| {
        things_iter.find(|i| **i==item).expect("sth went wrong");
    }).collect();

snippet above triggers panic as it can't find number 2 after it found number 1 as it's reusing the same iterator.

The same thing happens in Rendy if textures happen to be in wrong order in images iterator.
Solution is to clone iterator inside the lambda or just use collection directly.

I'll try to prepare pull request (never have done it before to open source project, is there any guide here?).