5 ms·
Off the top of my head, I think there's some niche use in embedding shaders so that they don't need to be stored as strings (no IDE support) or read at runtime
by trinovantes 4y ago
Off the top of my head, I think there's some niche use in embedding shaders so that they don't need to be stored as strings (no IDE support) or read at runtime (slower performance).
- matthews2 4y agoNice for binary shaders too, e.g. SPIR-V bytecode generated by glslc.
- spicyjpeg 4y agoThere are a lot of use cases for baking binary data directly into the program, especially in embedded applications. For instance, if you are writing a bootloader for a device that has some kind of display you might want to include a splash screen, or a font to be able to show error messages before a filesystem or an external storage medium is initialized. Similarly, on a microcontroller with no external storage at all you need to embed all your assets into the binary; the current way to do that is to either use whatever non-standard tools the manufacturer's proprietary toolchain provides, or to use xxd to (inefficiently) generate a huge C source file from the contents of the binary file. Both require custom build steps and neither is ideal.
- phoboslab 4y agoYou can get some IDE support with a simple preprocessor macro[1]. It's a crutch, but at least you don't need to stuff the shader into multiple "strings" or have string continuations (\) at the end of every line. Plus you get some syntax highlighting from the embedding language. I.e. the shader is highlighted as C code, which for the most part seems to be close enough. [1] https://github.com/phoboslab/pl_mpeg/blob/master/pl_mpeg_player.c#L102-L131 https://github.com/phoboslab/pl_mpeg/blob/master/pl_mpeg_pla...
- trinovantes 4y agoThat's pretty clever Thanks, I'll remember to use that in my future shaders
- avianes 4y agoAnother typical use is embedding a public-key in an application or firmware.