bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.01k stars 1.94k forks source link

[Feature Request] shaderc option to return the compiled shader binary instead of writing it to a file #1012

Closed volcoma closed 1 year ago

volcoma commented 7 years ago

So would it be possible to add an option to shaderc to not write anything to a file but instead return the compiled memory to the user. This would be great for texturec and geometryc as well. This would make runtime compilation much easier and allow the user to serialize the data in any way he sees fit e.g to a database or to create a single file containing all the different dx9, dx11, opengl ... binaries or something else.

volcoma commented 7 years ago

I believe creating something like BinWriter and wrap everything else in a func should do the trick. something like

int main(int _argc, const char* _argv[])
{
    // check some args and use any of these
    //BinWriter writer;
    //CrtFileWriter writer;
    //Bin2cWriter writer;
    int result = compile(&writer, _argc, _argv);
    // the user can hook here with writer.getMemory or smth
}