gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 547 forks source link

Dectect PSO component name collisions #1042

Closed kvark closed 5 years ago

kvark commented 8 years ago

Something like this shouldn't be legal:

pipeline pipe {
    vbuf: gfx::VertexBuffer<Vertex> = (),
    vr_left: gfx::RenderTarget<ColorFormat> = "pixcolor",
    vr_right: gfx::RenderTarget<ColorFormat> = "pixcolor",
    monitor: gfx::RenderTarget<ColorFormat> = "pixcolor",
}

cc @Bastacyclop @jaredr

eugene2k commented 7 years ago

I haven't even the slightest clue as to how to do it with rust's macros. Are you sure it's possible?

Bastacyclop commented 7 years ago

@eugene2k I don't think that you can do it with simple macro_rules!, but it should be easy with procedural macros / compiler plugins, we might need those for other features as well. I lost track of what is happening in that area, a new macro API should step in someday and make procedural macros a lot more attractive ?

eugene2k commented 7 years ago

Currently "Macros 2.0" is far from being stabilized and there's also work on the "Macros 1.1" api, which AFAIK only works for #[derive()] attributes. In other words, I don't think this bug is possible to resolve unless some sort of compiler/translator is added to gfx ecosystem to translate from DSL and into rust. Such a tool would probably solve other problems with current PSO definitions.

kvark commented 7 years ago

I was wondering if something like an artificial match through these names in the macro-generated code would force Rust to ensure the arms (= names) are unique, even if the match result will be unused.

eugene2k commented 7 years ago

The error in that case would be "unreachable pattern", which would probably be very confusing.

kvark commented 5 years ago

not happened in pre-ll