Hi vulkano people,
hope this is the right place to ask. I'm hacking on a small renderer and just can't get my head around the descriptor type of RenderPass<T>.
the RenderPass gets created as follows:
let render_pass = Arc::new(single_pass_renderpass!(device.clone(),
attachments: {
color: {
load: Clear,
store: Store,
format: swapchain.format(),
samples: 1,
}
},
pass: {
color: [color],
depth_stencil: {}
}
).unwrap());
and i would like to store it inside a struct
pub struct Renderer {
// ...
render_pass: Arc<RenderPass<_>>,
}
It looks like the macro creates a new type for the render pass. My main goal is to not have the loop { } inside the renderer as the examples do, but it feels like i'm programming against the library. Any suggestions would help a lot!
Cheers!
Same. The macro generates a private module with a CustomRenderPassDesc struct, which is not usable outside the function.
Weird, the $device was once removed from the macro and added back in commit https://github.com/tomaka/vulkano/commit/738b16cb0700f9747054327cffe593e7c5e15271
You can cast the Arc<_> into a Arc<RenderPassAbstract> in order to store it.
This is a problem I'm well aware of, and in fact many traits of vulkano exist for the sole purpose of being able to cast to Arc<Trait>.
I need to add a "real-world" example somewhere in order to show how things are designed.
Thanks, will try that later.
The hint to cast things to their trait type helped a lot! I think we can close this :D
Any chance of something like this for the GraphicsPipeline? I was trying to return one from a function, by tricking the compiling into telling me the expected return type I got as far as:
type Pipeline<L> = GraphicsPipeline<SingleBufferDefinition<VertexDefinition<vs::MainInput>>, Box<PipelineLayoutAbstract + Send + Sync>, Arc<L>>;
And it still needed some associated type hints. At that point I tried to give up and just wrapped it in a macro but ended up with the exact same problem.
Now I'm just blindly copying the genetics from the docs and trying to guess what the types are.
Really not convinced that Rusts safety warrant this kind of arcane syntax overhead and the Arcs everywhere, especially since any halfway sane drivers shouldn't crash or anything.
@dcbishop There's GraphicsPipelineAbstract.
Most helpful comment
You can cast the
Arc<_>into aArc<RenderPassAbstract>in order to store it.This is a problem I'm well aware of, and in fact many traits of vulkano exist for the sole purpose of being able to cast to
Arc<Trait>.I need to add a "real-world" example somewhere in order to show how things are designed.