-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile shader at runtime #405
Comments
It's not a proper implementation, but I accomplished this here: Essentially I just changed main() into a function and started calling it from my engine. It's worked quite well for me. |
Watch out for fcpp closing stdout. Not very friendly behavior for a library. |
Fixed: ac6d6bd |
Is there any plan to support this other than via hacking shaderc? |
That's a local link though. But bgfx doesn't even have file system access (and I like it that way), how will you deal with include file? |
Link is fixed. Yeah it doesn't have file access, and that's one of problems with it. My plan is to make it utility library (basically what @andr3wmac suggested above), and not part of the bgfx library. Compiling shaders in runtime doesn't make any sense in real-world, it's more for tools or hobbyist projects where prebuilding is hassle to them. |
Hello! Any progress on this issue? |
I also wanted to use shaderc as a library and in case it's of any use to anyone else this worked for me (in Visual Studio):
To get around this...
You'll need to define compileShader() in the header file so you can call it and also expose methods to enable the caller to get at any compilation errors. andr3wmac's solution to this is: Add the following 3 function defintions to shaderc.h inside the bgfx namespace:
Modify shaderc.cpp by adding the definitions of the missing functions we declared above:
Modify compileShader() definition (and preceding lines) as follows:
Compile it to get a shaderc lib which you can then link along with bgfx lib into your app. |
Hey @bkaradzic, if a PR was made for this kind of feature, would you consider it? I ask, as I need runtime shader compilation (for faster development), and was thinking about implementing this. On your Kanban board I see you have a 'rewrite' of |
It looks like most of the code is implemented in I was also thinking about passing around an How do you feel about introducing some more |
bx uses Reader/Writer which can be anything: https://github.com/bkaradzic/bx/blob/master/include/bx/readerwriter.h Anyhow, preferable way to do this is to create |
Hey @bkaradzic, thanks for the feedback! I'm trying to do it by calling it as an external process, using the The code I'm running is:
when I run my program, I get the following output:
The error message is coming from the However, if I try to get the resulting output from the actual command, I get this:
I'm using |
If I append It seems as though I'm getting some extra data at the end (i.e. on the last line I see a repeat of |
Hmm...It's working more or less now, but if an error occurs, the exit code is If everything goes well, the exit code is Anyone have this happen to them? |
Gah, this was happening because I was calling |
should be:
Less code, and not Crazy++11 style. :) |
Haha fair enough :) |
for those looking for a library version. main advantages are :
|
Would be possible to compile shaders at runtime?
At the moment I saw there is the shaderc tool, but in scene graph there can be different light/shader permutation, how can this be achieved?
The text was updated successfully, but these errors were encountered: