shaders are perfectly suited for functional programming and yet every major shader language is brutally imperative. it’s horrible. does anyone know how one might go about writing an alternative shader language? is there a shader version of assembly i can compile to???
-
-
Replying to @beka_valentine @ManishEarth
I don’t consider GLSL that imperative though, at least if you don’t use Image Load/Store and SSBOs. What do you mean by brutally imperative?
1 reply 0 retweets 5 likes -
For GLSL, that it's `void main() { ... }` and not `OutData main(InData input) { ... }` is fairly, err, imperative. (Although, since HLSL *is* that way, this probably isn't what she meant, perhaps the C legacy...)
1 reply 0 retweets 0 likes -
the entire thing is imperative, there's like not one bit of it that supports proper functional programming, which really sucks
1 reply 0 retweets 0 likes -
Are you referring to first-class functions? GLSL actually has a lot of immutability and minimal shared mutable state, which is nice…
1 reply 0 retweets 0 likes -
the entire style of programming. it's just terribly imperative
1 reply 0 retweets 1 like -
Replying to @beka_valentine @pcwalton and
but just as a trivial example, in principle it ought to be very simple to define a handful of combinators for doing standard things -- drawing shapes, transformations on shaders, etc etc. but you basically cant
2 replies 0 retweets 2 likes -
Replying to @beka_valentine @pcwalton and
you *ought* to be able to write something like main = scale(3, translate(-10, 20, mask(noise, circle))) and it'd just work exactly like it says but you really can't do that at all
2 replies 1 retweet 2 likes
Well, keep in mind indirect calls are very expensive (if not impossible depending on GPU u-arch), so to make that performant you would need to have uniquely-typed closures and monomorphization like Rust. Not saying it can’t be done, but it’s a pretty unusual FP environment.
-
-
if i ever make something, i'll be sure to let you know so you can pick apart its flaws :)
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.