I have been learning wgpu over the past few days and I have one point of confusion. When I browse athe wgpu examples (https://github.com/gfx-rs/wgpu/tree/master/wgpu/examples) they use this syntax for their shaders:
struct VertexOutput {
@location(0) color: vec4<f32>,
@builtin(position) position: vec4<f32>,
}
but I have to write my shaders like this:
struct VertexOutput {
[[location(0)]] color: vec4<f32>;
[[builtin(position)]] position: vec4<f32>;
};
I much prefer the @
syntax to the [[]]
syntax. My guess is that it is a feature I need to enable in my Cargo.toml but I have not been able to find out what feature this is. So if someone could tell me how to use the @
syntax in my wgsl shaders it would be much appreciated.
I guess you currently use
wgpu
version0.12.0
from crates.io?The
@
syntax is the new updated syntax from thewebgpu
spec. The latest released version ofwgpu
however still uses the old syntax.If you want to use the new syntax now, you can use the
master
branch from git like so (in yourCargo.toml
):Update
wgpu
version0.13
was released in the meantime, so you can now useto get the new wgsl syntax.