[osg-users] Pragmatic shader - a new #pragma directive proposition

Robert Osfield robert.osfield at gmail.com
Thu Jan 14 07:34:07 PST 2016


On 14 January 2016 at 14:56, Robert Milharcic
<robert.milharcic at ib-caddy.si> wrote:
> If I'm not mistaken, the #pragma directive is used by the C/C++ preprocessor
> for providing additional information, beyond what the language itself can
> offer. I thought this was the main inspiration for #pragma(tic) shader
> composition. Anyway, based on feedback I'm now convinced that my proposition
> isn't that useful as I thought :)  and on that note, I rest my case.

#pragma is indeed the C/C++ mechanism for providing extra hints to
specific compilers.

In terms of coming up with #pragma(tic) shader composition I started
with the observation that C/C++ macro's and #define's that could do
much of the job of shader composition, but then I needed a mechanism
for the shader to specify which #define's it required as input to the
shaders. After a bit of head scratching it occurred to me that #pragma
was support by GLSL and since it's a language feature I could piggy
back the extra information specification into the shaders.  Once I
spotted this missing bit of jigsaw it was just too elegant not to
work, thankfully the implementation ended up being relatively tidy
too.

I'm still open to making the shader parsing extensible, it seems like
an interesting experimental tool.

Robert.


More information about the osg-users mailing list