4 ms·
> You give it regular C# structures and methods, and it automatically converts them to HLSL, GLSL SPIR-V, and Metal shaders. Code introspection is one of the h
by Const-me 8y ago
> You give it regular C# structures and methods, and it automatically converts them to HLSL, GLSL SPIR-V, and Metal shaders.
Code introspection is one of the huge strengths of .NET ecosystem.
You can even do it multiple levels of abstraction: bytecode (using e.g. Mono.Cecil), with built-in reflection API, with built-in expressions API since .NET 3.5, and apparently this project uses even higher-level approach, Roslyn.
I have never transformed C# code into shaders, when I’m working on something similar I usually prefer traditional GPU languages like HLSL or CUDA, because tooling (e.g. visual studio can debug both).
I transformed expressions into NoSQL database queries, worked well. Here’s the main parts: https://github.com/Const-me/EsentSerialize/blob/master/Core/EsentSerialize81/Linq/FilterQuery.cs https://github.com/Const-me/EsentSerialize/blob/master/Core/...
- pjmlp 8y agoWhile it is great feature that I enjoy a lot, it isn't the only eco-system with it. :)
- seanmcdirmid 8y agoYou can also roll your own expression language using operator overloading and then plug that into the DLR or HSL, or whatever as needed (I did this in https://archive.codeplex.com/?p=bling https://archive.codeplex.com/?p=bling). It doesn’t allow for statements, however, which introspection gives you. It is much harder in the new UWP, however, where dynamic features (reflection, introspection, native JIT via the DLR) are no longer guaranteed to be present.
- zamalek 8y agoDon't forget that Linq operates over duck-typed extension methods, so you can also define your own wizardry there.
- seanmcdirmid 8y agoExtension methods are important to doing an EDSL in C#. Link syntax is mostly a dud, however.
- megaman22 8y agoHopefully the weird special-case LINQ syntax will die out soon. The only time I've found it remotely more helpful than method-chaining is when doing some nasty joins that I probably shouldn't have been doing in the first place.