summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-08-10 13:34:19 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-08-10 18:07:16 +0100
commit8e6902b03e0d11fe432200cf9c57b6613a8f874f (patch)
tree3535746c2b42f5260e69e1de83c0ead28264f61f
parentReduce the amount of unnecessary rebuilds on shader source changes (diff)
downloadilt-8e6902b03e0d11fe432200cf9c57b6613a8f874f.tar.bz2
ilt-8e6902b03e0d11fe432200cf9c57b6613a8f874f.tar.xz
ilt-8e6902b03e0d11fe432200cf9c57b6613a8f874f.zip
Create standalone composed shader file and format it and the C++ code
-rw-r--r--glsl.jam18
-rw-r--r--lib/embed-glsl.cpp.m42
2 files changed, 12 insertions, 8 deletions
diff --git a/glsl.jam b/glsl.jam
index 20ef180..a2a08c6 100644
--- a/glsl.jam
+++ b/glsl.jam
@@ -8,12 +8,13 @@ type.register GL_TESS_CONTROL_SHADER : tcs ;
type.register GL_TESS_EVALUATION_SHADER : tes ;
type.register GL_GEOMETRY_SHADER : gs ;
type.register GL_FRAGMENT_SHADER : fs ;
+type.register GL_GENERIC_SHADER : glsl ;
-generators.register-standard glsl.embed : GL_VERTEX_SHADER : CPP(vs-%) H(vs-%) ;
-generators.register-standard glsl.embed : GL_TESS_CONTROL_SHADER : CPP(tcs-%) H(tcs-%) ;
-generators.register-standard glsl.embed : GL_TESS_EVALUATION_SHADER : CPP(tes-%) H(tes-%) ;
-generators.register-standard glsl.embed : GL_GEOMETRY_SHADER : CPP(gs-%) H(gs-%) ;
-generators.register-standard glsl.embed : GL_FRAGMENT_SHADER : CPP(fs-%) H(fs-%) ;
+generators.register-standard glsl.embed : GL_VERTEX_SHADER : CPP(vs-%) H(vs-%) GL_GENERIC_SHADER(vs-%) ;
+generators.register-standard glsl.embed : GL_TESS_CONTROL_SHADER : CPP(tcs-%) H(tcs-%) GL_GENERIC_SHADER(tcs-%) ;
+generators.register-standard glsl.embed : GL_TESS_EVALUATION_SHADER : CPP(tes-%) H(tes-%) GL_GENERIC_SHADER(tes-%) ;
+generators.register-standard glsl.embed : GL_GEOMETRY_SHADER : CPP(gs-%) H(gs-%) GL_GENERIC_SHADER(gs-%) ;
+generators.register-standard glsl.embed : GL_FRAGMENT_SHADER : CPP(fs-%) H(fs-%) GL_GENERIC_SHADER(fs-%) ;
class m4-scanner : common-scanner {
rule pattern ( ) {
@@ -31,8 +32,11 @@ type.set-scanner GL_FRAGMENT_SHADER : m4-scanner ;
actions glsl.embed
{
- m4 -I$(2:D) -DNAME=$(2:B) -DTYPE=$(2:S) > $(1[2]) lib/embed-glsl.h.m4
- m4 -I$(2:D) -DSOURCE=$(2) -DNAME=$(2:B) -DTYPE=$(2:S) -DGLTYPE=$(OPTIONS) > $(1[1]) lib/embed-glsl.cpp.m4
+ m4 -I$(2:D) -DSOURCE=$(2) -DOUTPUT=$(1[3]) -DNAME=$(2:B) -DTYPE=$(2:S) -DGLTYPE=$(OPTIONS) $(2) > $(1[3])
+ clang-format -i $(1[3])
+ m4 -I$(2:D) -DSOURCE=$(1[3]) -DOUTPUT=$(1[3]) -DNAME=$(2:B) -DTYPE=$(2:S) -DGLTYPE=$(OPTIONS) lib/embed-glsl.h.m4 > $(1[2])
+ m4 -I$(2:D) -DSOURCE=$(1[3]) -DOUTPUT=$(1[3]) -DNAME=$(2:B) -DTYPE=$(2:S) -DGLTYPE=$(OPTIONS) lib/embed-glsl.cpp.m4 > $(1[1])
+ clang-format -i $(1[1]) $(1[2])
}
rule glsl.embed ( targets * : sources * : properties * )
diff --git a/lib/embed-glsl.cpp.m4 b/lib/embed-glsl.cpp.m4
index 9fe0b41..ecae004 100644
--- a/lib/embed-glsl.cpp.m4
+++ b/lib/embed-glsl.cpp.m4
@@ -5,5 +5,5 @@ changecom() dnl
#include <glad/gl.h>
constexpr Shader NAME`_'substr(TYPE,1) {
- R"GLSL-EMBED(dnl
+ R"GLSL-EMBED(// OUTPUT
include(SOURCE))GLSL-EMBED", GLTYPE };