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.05k stars 1.94k forks source link

Feature Request: Allow shader code to override version #2977

Open cykoder opened 1 year ago

cykoder commented 1 year ago

I have my pipeline setup well so that I only need to invoke shaderc from a single source (like the example shader Makefiles). Works great, but for only a few shaders I require a higher shader version. Setting the standard GLSL #version 430 or whatever doesnt work and produces errors when trying to compile.

I don't see that shaderc checks for existing version definitions, could it? I'm not sure how to best address defining the versions across different compilation targets. Perhaps it'd require something like:

#version_glsl 430
#version_hlsl xyz
...etc

(but i find this ugly)

Thoughts/concerns? I am happy to try contribute this feature if a decision can be made on above

SnapperTT commented 1 year ago

Shaderc does not check the source for shader versions, the shader version is set when you invoke shaderc

Eg: shaderc -platform linux -p 120 compiles a GLSL 120 shader.

The best way to have diverging shader versions would be to have diverging shaderc invocations in your makefile

cykoder commented 1 year ago

Shaderc does not check the source for shader versions, the shader version is set when you invoke shaderc

This I am aware of, thats the feature request. While its easy to say just diverge in the makefile its a bit of a pain to setup for just one or two shaders. Atleast the way I have it atm, on make the shaders are compiled from directory structure like: engine/shaders/xyz1, engine/shaders/xyz2, engine/shaders/xyz3

if xyz2 uses a diff version, exlcuding it and invoking shaderc again is a bit painful. especially when its only GLSL/OpenGL that needs updating