use nightshade::ecs::world::World;
use nightshade::prelude::wgpu;
use nightshade::render::wgpu::passes;
use nightshade::render::wgpu::rendergraph::{RenderGraph, render_graph_pass};
use nightshade::run::RenderResources;

pub fn configure_graph(
    graph: &mut RenderGraph<World>,
    device: &wgpu::Device,
    resources: RenderResources,
) {
    let ssr_pass = passes::SsrPass::new(device);
    render_graph_pass(graph, Box::new(ssr_pass))
        .read("depth", resources.depth)
        .read("view_normals", resources.view_normals)
        .read("scene_color", resources.scene_color)
        .write("ssr_raw", resources.ssr_raw)
        .add()
        .expect("failed to add ssr_pass");

    let ssr_blur_pass = passes::SsrBlurPass::new(device);
    render_graph_pass(graph, Box::new(ssr_blur_pass))
        .read("ssr_raw", resources.ssr_raw)
        .read("depth", resources.depth)
        .read("view_normals", resources.view_normals)
        .write("ssr", resources.ssr)
        .add()
        .expect("failed to add ssr_blur_pass");
}
