Description
You're making the exact same mistakes that OpenGL did -- having a source-level language (text) be your main shader input; and we all know how well that turned out.
There's a reason that Vulkan and DirectX use some form of bytecode representation for shaders.
There is no such thing as "trivially convertible to/from SPIR-V" when it's source-level like this because you actually need to write full on compiler for it (ie. parsing, tokenizing etc). It's feels like it's just the W3C making another terrible standard that's impossible for anyone without hundreds of developers (ie. Apple, Google, Mozilla) to implement in any rational way.
In fact, while I am here why are the W3C making a shading language, when you couldn't even be trusted with HTML?
The current spec as it stands is also inconsistent and randomly flips between GLSL, WGSL and HLSL semantics: eg. the float4 here
Why do some of these have ;
, some have ,
and some nothing at the end of their declarations.
The language looks genuinely terrible already:
I can read SPIR-V just fine by eye, but what the hell is a continuing
block? You're just making up random keywords no-one has heard before! Not to mention there's also unless
and regardless
whatever the hell they do. :v
Why is a simple loop so bloody complicated? This isn't how anyone thinks when they write a shader.
How can you look at this and expect anybody to write code for it?
Serious question: are you actually expecting anyone to write this by hand?
If you're not, then please for the love of god just use a bytecode representation. If you are, then please make it not so completely unusable for literally any purpose.
I agree that GLSL is kinda crap and we desperately need a new source level language but this really isn't it. Everything is needlessly verbose for a shading language, vec4<f32>
is going to get old very fast, and overall it just makes things unreadable, given there's going to be <>
cluttering up everywhere (C++ templates all over for everything is... ew).
It's just like someone saw Rust, thought it was cool, then tried to make some representation of SPIR-V using Rust syntax...
What problems does WGSL solve that SPIR-V doesn't? None. You're just wasting everyone's time by making them implement some stupid WGSL -> SPIR-V translator. Just take in SPIR-V on your end, and validate it if you have to and limit to some subset. Don't take in some high level source language that nobody is going to ever write in.
If you want to make a new source-level language, then that's fine too! GLSL sucks.
But nobody in their right mind is gonna write whatever the hell this is.