He seems to just hand-wave and says "well just use C you idiots". He criticizes Metal for using a version of C++14 that doesn't allow recursion, but offers no alternate solutions
The reason GLSL isn't C is because you can't do everything C does on a low end cellphone GPU - so obviously you have to restrict the language. The "cognitive load" of knowing the restrictions is overblown but also unavoidable.
SPIRV isn't even mentioned. DSL's are dismissed.
I didn't really follow what he didn't like about the preset input/output variables that are predefined in the different shaders. It's a bit ugly.. but that's also pretty much a non issue.
GLSL limitations has nothing to do with lowend devices and performance (which now is becoming irrelevant compared to desktops).
But rather GLSL is executed on the GPU— typically across many stream processors— this type of parallelization makes using a general purpose language like C difficult.
I think you need to familiar yourself with some shader programming at least, before you critique the author's domain.
> He criticizes Metal for using a version of C++14 that doesn't allow recursion, but offers no alternate solutions
No, he criticizes GLSL and HLSL for extending C or C++ in an ad-hoc way which make them buggy and unreliable (myriad of small differences between implementations).
"The need for ad hoc language extension also complicates compiler implementations: current compilers either need to reinvent a complete C-like parser and compiler from scratch [28] or hack an existing frontend such as GCC or Clang. Both approaches are error prone: [...]"
This is just my observation after dealing with people in academia and industry, however, so my words should be taken with a huge amount of salt. I think it's unfortunate that it's in PL where this divide tends to be most harmful.
I don't think the author suggested anything like that. He recommended using C with some extensions, so it would be easy to write shaders in many different languages. Also, he criticized the poor implementation of Metal's shading language which requires a custom fork of Clang (which is apparently buggy), not necessarily the choice of using C++14.
> The reason GLSL isn't C is because you can't do everything C does on a low end cellphone GPU - so obviously you have to restrict the language.
That may be true in the early days of OpenGL, but now that's probably no longer the case.
looking at the metal language I'm not sure I'd personally call that C++ given all the restrictions
https://developer.apple.com/metal/metal-shading-language-spe...
I'd be curious if you can create static arrays, strings or static strings, do string compares etc. not that I'd want to do any of that on a GPU but rather if you tell me the language is C++ there are a ton of things I'd expect to be able to do that I'm pretty sure don't translate to GPUs
maybe I want to declare a local static array and modify it. maybe I want to create static arrays of colors and search for the closest match. I feel like having a more common language would just lead people to bang their heads against the impossible or implement horribly inefficient algos not really understanding what's going on under the hood
I completely disagree. The author is not really arguing for a "more common language" anyhow - he's arguing for a GPU language that avoids many of the inefficiencies and semantic problems with the current approach. To boot, he's arguing for an approach that allows better static error checking, which it's hard to argue against.
I have to say it's sad that Apple went with Metal rather than working to evolve Vulkan as an excellent standard. We'll see how that works out in the long run...
Good point.
Yes, but why create another language that looks like C but behaves subtly differently? Could the compiler not simply reject usage of C features which are problematic for GPUs?
The reason that GPU drivers/APIs have few safety checks is that in graphics code, performance is valued above all else. Even simple calls can introduce overhead that's undesirable when you're making thousands of the same type of calls.
His example of baked shaders doesn't really seem to hold much value since interactive shader builders(ShaderToy, UE3/4, etc) are all content driven anyway so the extra code generation isn't a limiting constraint.
Nice effort but I don't see it solving actual pain points in production.
In a wide sense that includes programmer productivity and end product robustness in the equation, well, safety checks sell themselves.
Bounds checking is very cheap on CPUs, but even more so on GPUs because GPUs are more rarely bottlenecked on simple local arithmetic.
People do program GPU natively on game consoles. However, with so many GPUs in use (at least three major manufacturers each with multiple architectures just for desktop) it's impractical to write native graphics code. It's exactly the same concern as people have for CPU programming - it would be the best to write ISA code but given the variety of available CPUs the C/C++ is the best compromise between performance and usability. All attempts to push "better" language with forced run-time costs have failed to displace it.
>Bounds checking is very cheap on CPUs, but even more so on GPUs because GPUs are more rarely bottlenecked on simple local arithmetic.
Good news. GPUs do bounds checking in hardware already. The errors people want OpenGL to find are not about out-of-bounds but mostly of "I want to draw this but instead it's drawing that, what to do?" kind, caused by the complex state and its dynamic nature.
> ...some interesting thoughts, but the shading language is the least broken part of OpenGL.
> Lots of people consider automating the computation rate determination between fragment and vertex shaders, but it is a terrible idea.
Stuff kind of just works because GLSL doesn't have unstructured control-flow (i.e., there's no goto), and people have a mental model of what the hardware actually does and use that for the semantics.
But a proper study of those semantics, and how to carry it over to unstructured control-flow, or to what extent it is possible, would be awesome.
I like this part.
https://developer.apple.com/metal/metal-shading-language-spe...
Microsoft's HLSL is now also based on LLVM:
https://blogs.msdn.microsoft.com/directx/2017/01/23/new-dire...
Khronos has an LLVM-based translator between LLVM bitcode and SPIR-V:
https://github.com/KhronosGroup/SPIRV-LLVM
So things are converging, may be one day GPU extensions will end up in the C++ standard ;)
However I have a an up to date fork of LLVM 5 (https://github.com/thewilsonator/llvm) that has Khronos' changes cleaned up a bit, i.e. the spirv triples are actually targets, but once I make the SPIRV OpenCL extension operations proper LLVM intrinsics instead of mangled C++ (and delete all the associated mangling code) then there is no reason that can't go upstream.
I don't think SPIRV graphics support will be all that difficult to add once the intrinsics nonsense is fixed.
> So things are converging, may be one day GPU extensions will end up in the C++ standard ;)
Not before D gets them ;) (Shameless plug: I will be speaking at DConf about this.)
Piglit isn't really a conformance test suite. It is a test suite, is usually extended when people add new features to Mesa, and collects regression tests over time. However, it actually started out in part as a way to modify glean tests that drivers couldn't pass because the hardware was lacking, for example, hardware didn't have enough precision in the blender... those were the days. The p in piglit stands for your choice of pragmatic or practical. I'm not sure if that's actually documented anywhere, but as the original author, I should know ;-)
I'm sure piglit has bugs, but it's also well known that certain closed source drivers have less than conformant GLSL compilers, for example - so the fact that drivers passing the Khronos conformance tests fail piglit tests in itself doesn't mean anything other than shit needs investigating, and occasionally needs spec clarifications.
if (some_constant_expression) { //...code... }
and some_constant_expression evaluates to false, the entire code block will be stripped from the result?
That may be true, but it's not standardized behavior, is it?
I think VTune can do OpenCL analyses, I don't know whether it has any graphics debugging capability (quite a lot of features are Windows-only or annoying to set up on Linux [because who needs a kernel with a stable ABI?], including managed analyses [1] :(
The simple truth here is that most development happens on Windows and thus most development tools are developed for Windows. This is almost universally true, with some notable exceptions (e.g. Valgrind can be a killer app; nodejs is so unportable that it requires a new Windows subsystem to run).
[1] That is, VTune detects whether and which invasive runtime you are using and is able to descend into and analyse what the runtime is doing. E.g. with a Python managed analysis VTune replaces all these recursive gibberish calls like PyEval_EvalFrameEx with the Python traces that it's executing. When I first used that mind=blown. Sadly, Windows only. But even then VTune is, without consciously trying to make this comment an advert, one of the best (if not the best) performance analysis tools I've ever used.