I also created cargo-wgsl crate that validates your shaders.
Just run cargo install cargo-wgsl
to install it.
The extension will detect it in the path, and start a validation server for you.
VsCode Syntax highlight for WGSL files
License: MIT License
I also created cargo-wgsl crate that validates your shaders.
Just run cargo install cargo-wgsl
to install it.
The extension will detect it in the path, and start a validation server for you.
I tried to install this extension in VS Codium (FOSS fork of vs code without the telemetry), but it is not showing up:
Most other extensions show up just fine, but not all as some insist on a proprietary VS Code build. It would appear that this plugin is in that category (although it might be something else; I don't know enough about VS Code to know for sure), although that seems unusual for this sort of plugin, so perhaps it is an error?
I am using the bevy engine and it uses #import
. Here is an example shader.
In VS-Code I get this error when I enable v0.1.16
of vscode-wsgl
:
error: expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file, found '#'
┌─ wgsl:1:1
│
1 │ #import bevy_pbr::forward_io::VertexOutput;
│ ^ expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file
It would be nice if somehow this import
statement could be processed or ignored.
For some reason, the points of arrows in function returns are red...
Seems to be an issue in most colour schemes, except where the entire arrow is red (e.g. vscode default monokai scheme).
Seems not to be an issue when I use SpaceMono, maybe something to do with the ligatures.
Looking at the code, it should be fairly easy to add support for other shading languages such as HLSL based on DXC or GLSL based on glslangvalidator.
Is this something you would be interested in ? I was looking at it and could write some code for this, I like the base code & rust server
It would be very helpful if this extension could serve as a formatting server for VS Code so formatting could be applied on save.
Thanks for this extension, works well for most cases.
For large projects, we want to expend this extension to support more keywords in Autocompletion,but I'm new to vscode extenstions, how can we add custom autocompletions in this project? e.g. support struct inner vars?
Hope I can make some contribution to the Autocompletions
Hi,
first of all, this extension is great. GG
I tried to use in vscode but it seems that the validation produces errors when chrome canary is fine with the shader. It seems like the validation is not up to date with the shading language.
on this one the first line produces an error.
--> webgpu-experiment/src/node-functions.wgsl:2:1
error: error: expected global item ('struct', 'let', 'var', 'type', ';', 'fn') or the end of the file, found 'const'
┌─ wgsl:2:1
│
2 │ const NodeMaxLevel = 14;
│ ^^^^^ expected global item ('struct', 'let', 'var', 'type', ';', 'fn') or the end of the file
Note that this shader is injected a bit like include in a more complex compute shader and vertex shader. Still It feels that it validates on a different version and the language.
WGSL
has changed significantly since its inception, and syntax definitions in vscode-wgsl
became quite messy because of that, there are a lot of new cases that were not initially taken into account (good example of this would be #4)JSON
turned out to not be the best choice IMO, I would rather use YAML
and compile it to JSON
on every publishWGSL
specs in mind will yield a lot cleaner result.I have almost no experience with gulp and webpack. For my projects I have almost exclusively used Vite. I'd like to provide a way to develop this extension with Vite instead of webpack.
Maybe this might make contributing more accessible as many people seem to be more comfortable with Vite over webpack.
In the Stack Overflow developer survey Vite was admired by 78.94%, webpack only by 38.26%.
The WGSL standard declares some aliases for some vector types.
Among these are:
alias vec2i = vec2<i32>
alias vec3i = vec3<i32>
alias vec4i = vec4<i32>
alias vec2u = vec2<u32>
alias vec3u = vec3<u32>
alias vec4u = vec4<u32>
alias vec2f = vec2<f32>
alias vec3f = vec3<f32>
alias vec4f = vec4<f32>
alias vec2h = vec2<f16>
alias vec3h = vec3<f16>
alias vec4h = vec4<f16>
Sadly the extension currently doesn't recognize these as built-in types. Since they are used in some popular tutorials and are part of the standard, it would probably be good to include them.
If this is not the right repo to add these, please tell me where to look.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.